UNPKG

@pnp/spfx-property-controls

Version:

Reusable property pane controls for SharePoint Framework solutions

52 lines 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const IPropertyFieldDateTimePicker_1 = require("./IPropertyFieldDateTimePicker"); const react_1 = require("@fluentui/react"); /** * Hours component, this renders the hours dropdown */ class HoursComponent extends React.Component { render() { // Constructs a Date type object from the initalDate string property const hours = []; for (let i = 0; i < 24; i++) { let digit; if (this.props.timeConvention === IPropertyFieldDateTimePicker_1.TimeConvention.Hours24) { // 24 hours time convention if (i < 10) { digit = '0' + i; } else { digit = i.toString(); } } else { // 12 hours time convention if (i === 0) { digit = '12 am'; } else if (i < 12) { digit = i + ' am'; } else { if (i === 12) { digit = '12 pm'; } else { digit = (i % 12) + ' pm'; } } } let selected = false; if (i === this.props.value) { selected = true; } hours.push({ key: i, text: digit, isSelected: selected }); } return (React.createElement(react_1.Dropdown, { disabled: this.props.disabled, label: '', options: hours, onChanged: this.props.onChange, dropdownWidth: 110 })); } } exports.default = HoursComponent; //# sourceMappingURL=HoursComponent.js.map