@fluentui/react-timepicker-compat 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +15 -0
  3. package/README.md +38 -0
  4. package/dist/index.d.ts +147 -0
  5. package/lib/TimePicker.js +1 -0
  6. package/lib/TimePicker.js.map +1 -0
  7. package/lib/components/TimePicker/TimePicker.js +15 -0
  8. package/lib/components/TimePicker/TimePicker.js.map +1 -0
  9. package/lib/components/TimePicker/TimePicker.types.js +1 -0
  10. package/lib/components/TimePicker/TimePicker.types.js.map +1 -0
  11. package/lib/components/TimePicker/index.js +5 -0
  12. package/lib/components/TimePicker/index.js.map +1 -0
  13. package/lib/components/TimePicker/timeMath.js +169 -0
  14. package/lib/components/TimePicker/timeMath.js.map +1 -0
  15. package/lib/components/TimePicker/useTimePicker.js +193 -0
  16. package/lib/components/TimePicker/useTimePicker.js.map +1 -0
  17. package/lib/components/TimePicker/useTimePickerStyles.styles.js +32 -0
  18. package/lib/components/TimePicker/useTimePickerStyles.styles.js.map +1 -0
  19. package/lib/index.js +1 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib-commonjs/TimePicker.js +6 -0
  22. package/lib-commonjs/TimePicker.js.map +1 -0
  23. package/lib-commonjs/components/TimePicker/TimePicker.js +24 -0
  24. package/lib-commonjs/components/TimePicker/TimePicker.js.map +1 -0
  25. package/lib-commonjs/components/TimePicker/TimePicker.types.js +6 -0
  26. package/lib-commonjs/components/TimePicker/TimePicker.types.js.map +1 -0
  27. package/lib-commonjs/components/TimePicker/index.js +16 -0
  28. package/lib-commonjs/components/TimePicker/index.js.map +1 -0
  29. package/lib-commonjs/components/TimePicker/timeMath.js +141 -0
  30. package/lib-commonjs/components/TimePicker/timeMath.js.map +1 -0
  31. package/lib-commonjs/components/TimePicker/useTimePicker.js +196 -0
  32. package/lib-commonjs/components/TimePicker/useTimePicker.js.map +1 -0
  33. package/lib-commonjs/components/TimePicker/useTimePickerStyles.styles.js +48 -0
  34. package/lib-commonjs/components/TimePicker/useTimePickerStyles.styles.js.map +1 -0
  35. package/lib-commonjs/index.js +28 -0
  36. package/lib-commonjs/index.js.map +1 -0
  37. package/package.json +73 -0
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useTimePicker_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useTimePicker_unstable;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _reactutilities = require("@fluentui/react-utilities");
14
+ const _keyboardkeys = require("@fluentui/keyboard-keys");
15
+ const _reactcombobox = require("@fluentui/react-combobox");
16
+ const _reactfield = require("@fluentui/react-field");
17
+ const _timeMath = require("./timeMath");
18
+ const useTimePicker_unstable = (props, ref)=>{
19
+ const { dateAnchor: dateAnchorInProps, defaultSelectedTime: defaultSelectedTimeInProps, endHour = 24, formatDateToTimeString = _timeMath.formatDateToTimeString, hourCycle, increment = 30, onTimeChange, selectedTime: selectedTimeInProps, showSeconds = false, startHour = 0, parseTimeStringToDate: parseTimeStringToDateInProps, ...rest } = props;
20
+ const { freeform = false } = rest;
21
+ var _ref;
22
+ const { dateStartAnchor, dateEndAnchor } = useStableDateAnchor((_ref = dateAnchorInProps !== null && dateAnchorInProps !== void 0 ? dateAnchorInProps : selectedTimeInProps) !== null && _ref !== void 0 ? _ref : defaultSelectedTimeInProps, startHour, endHour);
23
+ const options = _react.useMemo(()=>(0, _timeMath.getTimesBetween)(dateStartAnchor, dateEndAnchor, increment).map((time)=>({
24
+ date: time,
25
+ key: (0, _timeMath.dateToKey)(time),
26
+ text: formatDateToTimeString(time, {
27
+ showSeconds,
28
+ hourCycle
29
+ })
30
+ })), [
31
+ dateEndAnchor,
32
+ dateStartAnchor,
33
+ formatDateToTimeString,
34
+ hourCycle,
35
+ increment,
36
+ showSeconds
37
+ ]);
38
+ const [selectedTime, setSelectedTime] = (0, _reactutilities.useControllableState)({
39
+ state: selectedTimeInProps,
40
+ defaultState: defaultSelectedTimeInProps,
41
+ initialState: null
42
+ });
43
+ const [submittedText, setSubmittedText] = _react.useState(undefined);
44
+ const selectTime = (0, _reactutilities.useEventCallback)((e, data)=>{
45
+ setSelectedTime(data.selectedTime);
46
+ setSubmittedText(data.selectedTimeText);
47
+ onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(e, data);
48
+ });
49
+ const selectedOptions = _react.useMemo(()=>{
50
+ const selectedTimeKey = (0, _timeMath.dateToKey)(selectedTime);
51
+ const selectedOption = options.find((date)=>date.key === selectedTimeKey);
52
+ return selectedOption ? [
53
+ selectedOption.key
54
+ ] : [];
55
+ }, [
56
+ options,
57
+ selectedTime
58
+ ]);
59
+ const handleOptionSelect = (0, _reactutilities.useEventCallback)((e, data)=>{
60
+ if (freeform && data.optionValue === undefined) {
61
+ // Combobox clears selection when input value not matching any option; but we allow this case in freeform TimePicker.
62
+ return;
63
+ }
64
+ var _data_optionValue;
65
+ const timeSelectionData = {
66
+ selectedTime: (0, _timeMath.keyToDate)((_data_optionValue = data.optionValue) !== null && _data_optionValue !== void 0 ? _data_optionValue : ''),
67
+ selectedTimeText: data.optionText,
68
+ errorType: undefined
69
+ };
70
+ selectTime(e, timeSelectionData);
71
+ });
72
+ const baseState = (0, _reactcombobox.useCombobox_unstable)({
73
+ autoComplete: 'off',
74
+ ...rest,
75
+ selectedOptions,
76
+ onOptionSelect: handleOptionSelect,
77
+ children: options.map((date)=>/*#__PURE__*/ _react.createElement(_reactcombobox.Option, {
78
+ key: date.key,
79
+ value: date.key
80
+ }, date.text))
81
+ }, ref);
82
+ const defaultParseTimeStringToDate = _react.useCallback((time)=>(0, _timeMath.getDateFromTimeString)(time, dateStartAnchor, dateEndAnchor, {
83
+ hourCycle,
84
+ showSeconds
85
+ }), [
86
+ dateEndAnchor,
87
+ dateStartAnchor,
88
+ hourCycle,
89
+ showSeconds
90
+ ]);
91
+ const state = {
92
+ ...baseState,
93
+ freeform,
94
+ parseTimeStringToDate: parseTimeStringToDateInProps !== null && parseTimeStringToDateInProps !== void 0 ? parseTimeStringToDateInProps : defaultParseTimeStringToDate,
95
+ submittedText
96
+ };
97
+ useDefaultChevronIconLabel(state);
98
+ useSelectTimeFromValue(state, selectTime);
99
+ return state;
100
+ };
101
+ /**
102
+ * Provides stable start and end date anchors based on the provided date and time parameters.
103
+ * The hook ensures that the memoization remains consistent even if new Date objects representing the same date are provided.
104
+ */ const useStableDateAnchor = (providedDate, startHour, endHour)=>{
105
+ const [fallbackDateAnchor] = _react.useState(()=>new Date());
106
+ const providedDateKey = (0, _timeMath.dateToKey)(providedDate !== null && providedDate !== void 0 ? providedDate : null);
107
+ return _react.useMemo(()=>{
108
+ const dateAnchor = providedDate !== null && providedDate !== void 0 ? providedDate : fallbackDateAnchor;
109
+ const dateStartAnchor = (0, _timeMath.getDateStartAnchor)(dateAnchor, startHour);
110
+ const dateEndAnchor = (0, _timeMath.getDateEndAnchor)(dateAnchor, startHour, endHour);
111
+ return {
112
+ dateStartAnchor,
113
+ dateEndAnchor
114
+ };
115
+ // `providedDate`'s stable key representation is used as dependency instead of the Date object. This ensures that the memoization remains stable when a new Date object representing the same date is passed in.
116
+ // eslint-disable-next-line react-hooks/exhaustive-deps
117
+ }, [
118
+ endHour,
119
+ fallbackDateAnchor,
120
+ providedDateKey,
121
+ startHour
122
+ ]);
123
+ };
124
+ /**
125
+ * Mimics the behavior of the browser's change event for a freeform TimePicker.
126
+ * The provided callback is called when input changed and:
127
+ * - Enter/Tab key is pressed on the input.
128
+ * - TimePicker loses focus, signifying a possible change.
129
+ */ const useSelectTimeFromValue = (state, callback)=>{
130
+ const { activeOption, freeform, parseTimeStringToDate, submittedText, setActiveOption, value } = state;
131
+ // Base Combobox has activeOption default to first option in dropdown even if it doesn't match input value, and Enter key will select it.
132
+ // This effect ensures that the activeOption is cleared when the input doesn't match any option.
133
+ // This behavior is specific to a freeform TimePicker where the input value is treated as a valid time even if it's not in the dropdown.
134
+ _react.useEffect(()=>{
135
+ if (freeform && value) {
136
+ setActiveOption((prevActiveOption)=>{
137
+ if ((prevActiveOption === null || prevActiveOption === void 0 ? void 0 : prevActiveOption.text) && prevActiveOption.text.toLowerCase().indexOf(value.toLowerCase()) === 0) {
138
+ return prevActiveOption;
139
+ }
140
+ return undefined;
141
+ });
142
+ }
143
+ }, [
144
+ freeform,
145
+ setActiveOption,
146
+ value
147
+ ]);
148
+ const selectTimeFromValue = (0, _reactutilities.useEventCallback)((e)=>{
149
+ if (!freeform) {
150
+ return;
151
+ }
152
+ const { date: selectedTime, errorType } = parseTimeStringToDate(value);
153
+ // Only triggers callback when the text in input has changed.
154
+ if (submittedText !== value) {
155
+ callback === null || callback === void 0 ? void 0 : callback(e, {
156
+ selectedTime,
157
+ selectedTimeText: value,
158
+ errorType
159
+ });
160
+ }
161
+ });
162
+ const handleKeyDown = (0, _reactutilities.useEventCallback)((e)=>{
163
+ if (!activeOption && e.key === _keyboardkeys.Enter) {
164
+ selectTimeFromValue(e);
165
+ }
166
+ });
167
+ state.root.onKeyDown = (0, _reactutilities.mergeCallbacks)(handleKeyDown, state.root.onKeyDown);
168
+ const rootRef = _react.useRef(null);
169
+ state.root.ref = (0, _reactutilities.useMergedRefs)(state.root.ref, rootRef);
170
+ if (state.listbox) {
171
+ state.listbox.tabIndex = -1; // allows it to be the relatedTarget of a blur event.
172
+ }
173
+ if (state.expandIcon) {
174
+ state.expandIcon.tabIndex = -1; // allows it to be the relatedTarget of a blur event.
175
+ }
176
+ const handleInputBlur = (0, _reactutilities.useEventCallback)((e)=>{
177
+ const isOutside = e.relatedTarget ? !(0, _reactutilities.elementContains)(rootRef.current, e.relatedTarget) : true;
178
+ if (isOutside) {
179
+ selectTimeFromValue(e);
180
+ }
181
+ });
182
+ state.input.onBlur = (0, _reactutilities.mergeCallbacks)(handleInputBlur, state.input.onBlur);
183
+ };
184
+ /**
185
+ * Provides a default aria-labelledby for the chevron icon if the TimePicker is wrapped in a Field.
186
+ */ const useDefaultChevronIconLabel = (state)=>{
187
+ var _state_expandIcon;
188
+ const fieldContext = (0, _reactfield.useFieldContext_unstable)();
189
+ const chevronDefaultId = (0, _reactutilities.useId)('timepicker-chevron-');
190
+ const defaultLabelFromCombobox = 'Open';
191
+ if ((fieldContext === null || fieldContext === void 0 ? void 0 : fieldContext.labelId) && ((_state_expandIcon = state.expandIcon) === null || _state_expandIcon === void 0 ? void 0 : _state_expandIcon['aria-label']) === defaultLabelFromCombobox) {
192
+ var _state_expandIcon_id;
193
+ const chevronId = (_state_expandIcon_id = state.expandIcon.id) !== null && _state_expandIcon_id !== void 0 ? _state_expandIcon_id : chevronDefaultId;
194
+ state.expandIcon['aria-labelledby'] = `${chevronId} ${fieldContext.labelId}`;
195
+ }
196
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useTimePicker.js"],"sourcesContent":["import * as React from 'react';\nimport { elementContains, mergeCallbacks, useControllableState, useEventCallback, useId, useMergedRefs } from '@fluentui/react-utilities';\nimport { Enter } from '@fluentui/keyboard-keys';\nimport { useCombobox_unstable, Option } from '@fluentui/react-combobox';\nimport { useFieldContext_unstable as useFieldContext } from '@fluentui/react-field';\nimport { dateToKey, keyToDate, formatDateToTimeString as defaultFormatDateToTimeString, getDateStartAnchor, getDateEndAnchor, getTimesBetween, getDateFromTimeString } from './timeMath';\n/**\n * Create the state required to render TimePicker.\n *\n * The returned state can be modified with hooks such as useTimePickerStyles_unstable,\n * before being passed to renderTimePicker_unstable.\n *\n * @param props - props from this instance of TimePicker\n * @param ref - reference to root HTMLElement of TimePicker\n */ export const useTimePicker_unstable = (props, ref)=>{\n const { dateAnchor: dateAnchorInProps, defaultSelectedTime: defaultSelectedTimeInProps, endHour = 24, formatDateToTimeString = defaultFormatDateToTimeString, hourCycle, increment = 30, onTimeChange, selectedTime: selectedTimeInProps, showSeconds = false, startHour = 0, parseTimeStringToDate: parseTimeStringToDateInProps, ...rest } = props;\n const { freeform = false } = rest;\n var _ref;\n const { dateStartAnchor, dateEndAnchor } = useStableDateAnchor((_ref = dateAnchorInProps !== null && dateAnchorInProps !== void 0 ? dateAnchorInProps : selectedTimeInProps) !== null && _ref !== void 0 ? _ref : defaultSelectedTimeInProps, startHour, endHour);\n const options = React.useMemo(()=>getTimesBetween(dateStartAnchor, dateEndAnchor, increment).map((time)=>({\n date: time,\n key: dateToKey(time),\n text: formatDateToTimeString(time, {\n showSeconds,\n hourCycle\n })\n })), [\n dateEndAnchor,\n dateStartAnchor,\n formatDateToTimeString,\n hourCycle,\n increment,\n showSeconds\n ]);\n const [selectedTime, setSelectedTime] = useControllableState({\n state: selectedTimeInProps,\n defaultState: defaultSelectedTimeInProps,\n initialState: null\n });\n const [submittedText, setSubmittedText] = React.useState(undefined);\n const selectTime = useEventCallback((e, data)=>{\n setSelectedTime(data.selectedTime);\n setSubmittedText(data.selectedTimeText);\n onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(e, data);\n });\n const selectedOptions = React.useMemo(()=>{\n const selectedTimeKey = dateToKey(selectedTime);\n const selectedOption = options.find((date)=>date.key === selectedTimeKey);\n return selectedOption ? [\n selectedOption.key\n ] : [];\n }, [\n options,\n selectedTime\n ]);\n const handleOptionSelect = useEventCallback((e, data)=>{\n if (freeform && data.optionValue === undefined) {\n // Combobox clears selection when input value not matching any option; but we allow this case in freeform TimePicker.\n return;\n }\n var _data_optionValue;\n const timeSelectionData = {\n selectedTime: keyToDate((_data_optionValue = data.optionValue) !== null && _data_optionValue !== void 0 ? _data_optionValue : ''),\n selectedTimeText: data.optionText,\n errorType: undefined\n };\n selectTime(e, timeSelectionData);\n });\n const baseState = useCombobox_unstable({\n autoComplete: 'off',\n ...rest,\n selectedOptions,\n onOptionSelect: handleOptionSelect,\n children: options.map((date)=>/*#__PURE__*/ React.createElement(Option, {\n key: date.key,\n value: date.key\n }, date.text))\n }, ref);\n const defaultParseTimeStringToDate = React.useCallback((time)=>getDateFromTimeString(time, dateStartAnchor, dateEndAnchor, {\n hourCycle,\n showSeconds\n }), [\n dateEndAnchor,\n dateStartAnchor,\n hourCycle,\n showSeconds\n ]);\n const state = {\n ...baseState,\n freeform,\n parseTimeStringToDate: parseTimeStringToDateInProps !== null && parseTimeStringToDateInProps !== void 0 ? parseTimeStringToDateInProps : defaultParseTimeStringToDate,\n submittedText\n };\n useDefaultChevronIconLabel(state);\n useSelectTimeFromValue(state, selectTime);\n return state;\n};\n/**\n * Provides stable start and end date anchors based on the provided date and time parameters.\n * The hook ensures that the memoization remains consistent even if new Date objects representing the same date are provided.\n */ const useStableDateAnchor = (providedDate, startHour, endHour)=>{\n const [fallbackDateAnchor] = React.useState(()=>new Date());\n const providedDateKey = dateToKey(providedDate !== null && providedDate !== void 0 ? providedDate : null);\n return React.useMemo(()=>{\n const dateAnchor = providedDate !== null && providedDate !== void 0 ? providedDate : fallbackDateAnchor;\n const dateStartAnchor = getDateStartAnchor(dateAnchor, startHour);\n const dateEndAnchor = getDateEndAnchor(dateAnchor, startHour, endHour);\n return {\n dateStartAnchor,\n dateEndAnchor\n };\n // `providedDate`'s stable key representation is used as dependency instead of the Date object. This ensures that the memoization remains stable when a new Date object representing the same date is passed in.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n endHour,\n fallbackDateAnchor,\n providedDateKey,\n startHour\n ]);\n};\n/**\n * Mimics the behavior of the browser's change event for a freeform TimePicker.\n * The provided callback is called when input changed and:\n * - Enter/Tab key is pressed on the input.\n * - TimePicker loses focus, signifying a possible change.\n */ const useSelectTimeFromValue = (state, callback)=>{\n const { activeOption, freeform, parseTimeStringToDate, submittedText, setActiveOption, value } = state;\n // Base Combobox has activeOption default to first option in dropdown even if it doesn't match input value, and Enter key will select it.\n // This effect ensures that the activeOption is cleared when the input doesn't match any option.\n // This behavior is specific to a freeform TimePicker where the input value is treated as a valid time even if it's not in the dropdown.\n React.useEffect(()=>{\n if (freeform && value) {\n setActiveOption((prevActiveOption)=>{\n if ((prevActiveOption === null || prevActiveOption === void 0 ? void 0 : prevActiveOption.text) && prevActiveOption.text.toLowerCase().indexOf(value.toLowerCase()) === 0) {\n return prevActiveOption;\n }\n return undefined;\n });\n }\n }, [\n freeform,\n setActiveOption,\n value\n ]);\n const selectTimeFromValue = useEventCallback((e)=>{\n if (!freeform) {\n return;\n }\n const { date: selectedTime, errorType } = parseTimeStringToDate(value);\n // Only triggers callback when the text in input has changed.\n if (submittedText !== value) {\n callback === null || callback === void 0 ? void 0 : callback(e, {\n selectedTime,\n selectedTimeText: value,\n errorType\n });\n }\n });\n const handleKeyDown = useEventCallback((e)=>{\n if (!activeOption && e.key === Enter) {\n selectTimeFromValue(e);\n }\n });\n state.root.onKeyDown = mergeCallbacks(handleKeyDown, state.root.onKeyDown);\n const rootRef = React.useRef(null);\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n if (state.listbox) {\n state.listbox.tabIndex = -1; // allows it to be the relatedTarget of a blur event.\n }\n if (state.expandIcon) {\n state.expandIcon.tabIndex = -1; // allows it to be the relatedTarget of a blur event.\n }\n const handleInputBlur = useEventCallback((e)=>{\n const isOutside = e.relatedTarget ? !elementContains(rootRef.current, e.relatedTarget) : true;\n if (isOutside) {\n selectTimeFromValue(e);\n }\n });\n state.input.onBlur = mergeCallbacks(handleInputBlur, state.input.onBlur);\n};\n/**\n * Provides a default aria-labelledby for the chevron icon if the TimePicker is wrapped in a Field.\n */ const useDefaultChevronIconLabel = (state)=>{\n var _state_expandIcon;\n const fieldContext = useFieldContext();\n const chevronDefaultId = useId('timepicker-chevron-');\n const defaultLabelFromCombobox = 'Open';\n if ((fieldContext === null || fieldContext === void 0 ? void 0 : fieldContext.labelId) && ((_state_expandIcon = state.expandIcon) === null || _state_expandIcon === void 0 ? void 0 : _state_expandIcon['aria-label']) === defaultLabelFromCombobox) {\n var _state_expandIcon_id;\n const chevronId = (_state_expandIcon_id = state.expandIcon.id) !== null && _state_expandIcon_id !== void 0 ? _state_expandIcon_id : chevronDefaultId;\n state.expandIcon['aria-labelledby'] = `${chevronId} ${fieldContext.labelId}`;\n }\n};\n"],"names":["useTimePicker_unstable","props","ref","dateAnchor","dateAnchorInProps","defaultSelectedTime","defaultSelectedTimeInProps","endHour","formatDateToTimeString","defaultFormatDateToTimeString","hourCycle","increment","onTimeChange","selectedTime","selectedTimeInProps","showSeconds","startHour","parseTimeStringToDate","parseTimeStringToDateInProps","rest","freeform","_ref","dateStartAnchor","dateEndAnchor","useStableDateAnchor","options","React","useMemo","getTimesBetween","map","time","date","key","dateToKey","text","setSelectedTime","useControllableState","state","defaultState","initialState","submittedText","setSubmittedText","useState","undefined","selectTime","useEventCallback","e","data","selectedTimeText","selectedOptions","selectedTimeKey","selectedOption","find","handleOptionSelect","optionValue","_data_optionValue","timeSelectionData","keyToDate","optionText","errorType","baseState","useCombobox_unstable","autoComplete","onOptionSelect","children","createElement","Option","value","defaultParseTimeStringToDate","useCallback","getDateFromTimeString","useDefaultChevronIconLabel","useSelectTimeFromValue","providedDate","fallbackDateAnchor","Date","providedDateKey","getDateStartAnchor","getDateEndAnchor","callback","activeOption","setActiveOption","useEffect","prevActiveOption","toLowerCase","indexOf","selectTimeFromValue","handleKeyDown","Enter","root","onKeyDown","mergeCallbacks","rootRef","useRef","useMergedRefs","listbox","tabIndex","expandIcon","handleInputBlur","isOutside","relatedTarget","elementContains","current","input","onBlur","_state_expandIcon","fieldContext","useFieldContext","chevronDefaultId","useId","defaultLabelFromCombobox","labelId","_state_expandIcon_id","chevronId","id"],"mappings":";;;;+BAciBA;;;eAAAA;;;;iEAdM;gCACuF;8BACxF;+BACuB;4BACe;0BACgH;AASjK,MAAMA,yBAAyB,CAACC,OAAOC;IAC9C,MAAM,EAAEC,YAAYC,iBAAiB,EAAEC,qBAAqBC,0BAA0B,EAAEC,UAAU,EAAE,EAAEC,yBAAyBC,gCAA6B,EAAEC,SAAS,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D,KAAM,AAAC,CAAA,AAACN,CAAAA,oBAAoBpE,MAAM4D,UAAU,AAAD,MAAO,QAAQQ,sBAAsB,KAAK,IAAI,KAAK,IAAIA,iBAAiB,CAAC,aAAa,AAAD,MAAOK,0BAA0B;QACjP,IAAIE;QACJ,MAAMC,YAAY,AAACD,CAAAA,uBAAuB3E,MAAM4D,UAAU,CAACiB,EAAE,AAAD,MAAO,QAAQF,yBAAyB,KAAK,IAAIA,uBAAuBJ;QACpIvE,MAAM4D,UAAU,CAAC,kBAAkB,GAAG,CAAC,EAAEgB,UAAU,CAAC,EAAEP,aAAaK,OAAO,CAAC,CAAC;IAChF;AACJ"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ timePickerClassNames: function() {
13
+ return timePickerClassNames;
14
+ },
15
+ useTimePickerStyles_unstable: function() {
16
+ return useTimePickerStyles_unstable;
17
+ }
18
+ });
19
+ const _react = require("@griffel/react");
20
+ const _reactcombobox = require("@fluentui/react-combobox");
21
+ const timePickerClassNames = {
22
+ root: 'fui-TimePicker',
23
+ input: 'fui-TimePicker__input',
24
+ expandIcon: 'fui-TimePicker__expandIcon',
25
+ listbox: 'fui-TimePicker__listbox'
26
+ };
27
+ const useStyles = /*#__PURE__*/ (0, _react.__styles)({
28
+ listbox: {
29
+ Bxyxcbc: "f1vfnyiv"
30
+ }
31
+ }, {
32
+ d: [
33
+ ".f1vfnyiv{max-height:min(80vh, 416px);}"
34
+ ]
35
+ });
36
+ const useTimePickerStyles_unstable = (state)=>{
37
+ const styles = useStyles();
38
+ state.root.className = (0, _react.mergeClasses)(timePickerClassNames.root, state.root.className);
39
+ state.input.className = (0, _react.mergeClasses)(timePickerClassNames.input, state.input.className);
40
+ if (state.expandIcon) {
41
+ state.expandIcon.className = (0, _react.mergeClasses)(timePickerClassNames.expandIcon, state.expandIcon.className);
42
+ }
43
+ if (state.listbox) {
44
+ state.listbox.className = (0, _react.mergeClasses)(timePickerClassNames.listbox, styles.listbox, state.listbox.className);
45
+ }
46
+ (0, _reactcombobox.useComboboxStyles_unstable)(state);
47
+ return state;
48
+ }; //# sourceMappingURL=useTimePickerStyles.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useTimePickerStyles.styles.js"],"sourcesContent":["import { __styles, mergeClasses } from '@griffel/react';\nimport { useComboboxStyles_unstable } from '@fluentui/react-combobox';\nexport const timePickerClassNames = {\n root: 'fui-TimePicker',\n input: 'fui-TimePicker__input',\n expandIcon: 'fui-TimePicker__expandIcon',\n listbox: 'fui-TimePicker__listbox'\n};\nconst useStyles = /*#__PURE__*/__styles({\n listbox: {\n Bxyxcbc: \"f1vfnyiv\"\n }\n}, {\n d: [\".f1vfnyiv{max-height:min(80vh, 416px);}\"]\n});\n/**\n * Apply styling to the TimePicker slots based on the state\n */\nexport const useTimePickerStyles_unstable = state => {\n const styles = useStyles();\n state.root.className = mergeClasses(timePickerClassNames.root, state.root.className);\n state.input.className = mergeClasses(timePickerClassNames.input, state.input.className);\n if (state.expandIcon) {\n state.expandIcon.className = mergeClasses(timePickerClassNames.expandIcon, state.expandIcon.className);\n }\n if (state.listbox) {\n state.listbox.className = mergeClasses(timePickerClassNames.listbox, styles.listbox, state.listbox.className);\n }\n useComboboxStyles_unstable(state);\n return state;\n};\n//# sourceMappingURL=useTimePickerStyles.styles.js.map"],"names":["timePickerClassNames","useTimePickerStyles_unstable","root","input","expandIcon","listbox","useStyles","__styles","Bxyxcbc","d","state","styles","className","mergeClasses","useComboboxStyles_unstable"],"mappings":";;;;;;;;;;;IAEaA,oBAAoB;eAApBA;;IAgBAC,4BAA4B;eAA5BA;;;uBAlB0B;+BACI;AACpC,MAAMD,uBAAuB;IAClCE,MAAM;IACNC,OAAO;IACPC,YAAY;IACZC,SAAS;AACX;AACA,MAAMC,YAAY,WAAW,GAAEC,IAAAA,eAAQ,EAAC;IACtCF,SAAS;QACPG,SAAS;IACX;AACF,GAAG;IACDC,GAAG;QAAC;KAA0C;AAChD;AAIO,MAAMR,+BAA+BS,CAAAA;IAC1C,MAAMC,SAASL;IACfI,MAAMR,IAAI,CAACU,SAAS,GAAGC,IAAAA,mBAAY,EAACb,qBAAqBE,IAAI,EAAEQ,MAAMR,IAAI,CAACU,SAAS;IACnFF,MAAMP,KAAK,CAACS,SAAS,GAAGC,IAAAA,mBAAY,EAACb,qBAAqBG,KAAK,EAAEO,MAAMP,KAAK,CAACS,SAAS;IACtF,IAAIF,MAAMN,UAAU,EAAE;QACpBM,MAAMN,UAAU,CAACQ,SAAS,GAAGC,IAAAA,mBAAY,EAACb,qBAAqBI,UAAU,EAAEM,MAAMN,UAAU,CAACQ,SAAS;IACvG;IACA,IAAIF,MAAML,OAAO,EAAE;QACjBK,MAAML,OAAO,CAACO,SAAS,GAAGC,IAAAA,mBAAY,EAACb,qBAAqBK,OAAO,EAAEM,OAAON,OAAO,EAAEK,MAAML,OAAO,CAACO,SAAS;IAC9G;IACAE,IAAAA,yCAA0B,EAACJ;IAC3B,OAAOA;AACT,GACA,sDAAsD"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ TimePicker: function() {
13
+ return _TimePicker.TimePicker;
14
+ },
15
+ timePickerClassNames: function() {
16
+ return _TimePicker.timePickerClassNames;
17
+ },
18
+ useTimePickerStyles_unstable: function() {
19
+ return _TimePicker.useTimePickerStyles_unstable;
20
+ },
21
+ useTimePicker_unstable: function() {
22
+ return _TimePicker.useTimePicker_unstable;
23
+ },
24
+ formatDateToTimeString: function() {
25
+ return _TimePicker.formatDateToTimeString;
26
+ }
27
+ });
28
+ const _TimePicker = require("./TimePicker");
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { TimePicker, timePickerClassNames, useTimePickerStyles_unstable, useTimePicker_unstable, formatDateToTimeString } from './TimePicker';\n"],"names":["TimePicker","timePickerClassNames","useTimePickerStyles_unstable","useTimePicker_unstable","formatDateToTimeString"],"mappings":";;;;;;;;;;;IAASA,UAAU;eAAVA,sBAAU;;IAAEC,oBAAoB;eAApBA,gCAAoB;;IAAEC,4BAA4B;eAA5BA,wCAA4B;;IAAEC,sBAAsB;eAAtBA,kCAAsB;;IAAEC,sBAAsB;eAAtBA,kCAAsB;;;4BAAQ"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@fluentui/react-timepicker-compat",
3
+ "version": "0.0.1",
4
+ "description": "Fluent UI TimePicker Compat Component",
5
+ "main": "lib-commonjs/index.js",
6
+ "module": "lib/index.js",
7
+ "typings": "./dist/index.d.ts",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "*.md",
11
+ "dist/*.d.ts",
12
+ "lib",
13
+ "lib-commonjs"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/microsoft/fluentui"
18
+ },
19
+ "license": "MIT",
20
+ "scripts": {
21
+ "build": "just-scripts build",
22
+ "bundle-size": "monosize measure",
23
+ "clean": "just-scripts clean",
24
+ "e2e": "cypress run --component",
25
+ "e2e:local": "cypress open --component",
26
+ "generate-api": "just-scripts generate-api",
27
+ "lint": "just-scripts lint",
28
+ "start": "yarn storybook",
29
+ "storybook": "start-storybook",
30
+ "test": "jest --passWithNoTests",
31
+ "test-ssr": "test-ssr \"./stories/**/*.stories.tsx\"",
32
+ "type-check": "tsc -b tsconfig.json"
33
+ },
34
+ "devDependencies": {
35
+ "@fluentui/eslint-plugin": "*",
36
+ "@fluentui/react-conformance": "*",
37
+ "@fluentui/react-conformance-griffel": "*",
38
+ "@fluentui/scripts-api-extractor": "*",
39
+ "@fluentui/scripts-tasks": "*"
40
+ },
41
+ "dependencies": {
42
+ "@fluentui/keyboard-keys": "^9.0.7",
43
+ "@fluentui/react-combobox": "^9.5.37",
44
+ "@fluentui/react-field": "^9.1.46",
45
+ "@fluentui/react-jsx-runtime": "^9.0.23",
46
+ "@fluentui/react-shared-contexts": "^9.13.2",
47
+ "@fluentui/react-theme": "^9.1.16",
48
+ "@fluentui/react-utilities": "^9.15.5",
49
+ "@griffel/react": "^1.5.14",
50
+ "@swc/helpers": "^0.5.1"
51
+ },
52
+ "peerDependencies": {
53
+ "@types/react": ">=16.8.0 <19.0.0",
54
+ "@types/react-dom": ">=16.8.0 <19.0.0",
55
+ "react": ">=16.8.0 <19.0.0",
56
+ "react-dom": ">=16.8.0 <19.0.0"
57
+ },
58
+ "exports": {
59
+ ".": {
60
+ "types": "./dist/index.d.ts",
61
+ "node": "./lib-commonjs/index.js",
62
+ "import": "./lib/index.js",
63
+ "require": "./lib-commonjs/index.js"
64
+ },
65
+ "./package.json": "./package.json"
66
+ },
67
+ "beachball": {
68
+ "disallowedChangeTypes": [
69
+ "major",
70
+ "prerelease"
71
+ ]
72
+ }
73
+ }