@luscii-healthtech/web-ui 18.0.1 → 18.1.0

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.
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ export declare const weekdayValues: readonly ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
3
+ export type Weekday = (typeof weekdayValues)[number];
4
+ /**
5
+ * The previous implementation of this component used the index of the
6
+ * weekday to indicate which days were selected. This function converts
7
+ * the `Weekday` value from the new API to the `number` value of the
8
+ * old API, for ease of migration.
9
+ */
10
+ declare function weekdayNameToIndex(weekday: Weekday): 0 | 1 | 2 | 3 | 4 | 5 | 6;
11
+ declare function weekdayNameToIndex(weekdays: Weekday[]): 0 | 1 | 2 | 3 | 4 | 5 | 6;
12
+ /**
13
+ * The previous implementation of this component used the index of the
14
+ * weekday to indicate which days were selected. This function converts
15
+ * the `number` value from the old API to the `Weekday` value of the
16
+ * new API, for ease of migration.
17
+ */
18
+ declare function indexToWeekdayName(index: number): Weekday;
19
+ declare function indexToWeekdayName(indexes: number[]): Weekday[];
20
+ export type Props = React.HTMLAttributes<HTMLDivElement> & {
21
+ /**
22
+ * The locale in which the weekday letters are displayed. Also
23
+ * affects the screen reader text.
24
+ */
25
+ locale: string;
26
+ /**
27
+ * This component is controlled, so it needs to be fed in
28
+ * state. The result of `onChange` can be passed back in here
29
+ * to make the component function as a controlled component.
30
+ */
31
+ selectedOptions: Weekday[];
32
+ onChange: (weekdayValues: Weekday[]) => void;
33
+ };
34
+ type StaticProperties = {
35
+ weekdayNameToIndex: typeof weekdayNameToIndex;
36
+ indexToWeekdayName: typeof indexToWeekdayName;
37
+ };
38
+ /**
39
+ * A component that allows the user to select multiple weekdays.
40
+ */
41
+ export declare const WeekdaysPicker: React.FC<Props> & StaticProperties;
42
+ export {};
package/dist/index.d.ts CHANGED
@@ -78,4 +78,5 @@ export { FullPageModal } from "./components/Modal/FullPageModal";
78
78
  export { Card, type Props as CardProps } from "./components/Card/Card";
79
79
  export { Dropzone, DropzoneProps } from "./components/Dropzone";
80
80
  export { FilterBar, FilterBarUtils } from "./components/FilterBar";
81
+ export { type Weekday, WeekdaysPicker, } from "./components/WeekdaysPicker/WeekdaysPicker";
81
82
  export { default as DragHandle, DragHandleProps, } from "./components/DragHandle";
@@ -25,6 +25,7 @@ var pick = require('lodash/pick');
25
25
  var index_ie11 = require('react-hook-form/dist/index.ie11');
26
26
  var react = require('@headlessui/react');
27
27
  var solid = require('@heroicons/react/20/solid');
28
+ var ToggleGroup = require('@radix-ui/react-toggle-group');
28
29
 
29
30
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
30
31
 
@@ -60,6 +61,7 @@ var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
60
61
  var debounce__default = /*#__PURE__*/_interopDefault(debounce);
61
62
  var ReactQuill__default = /*#__PURE__*/_interopDefault(ReactQuill);
62
63
  var pick__default = /*#__PURE__*/_interopDefault(pick);
64
+ var ToggleGroup__namespace = /*#__PURE__*/_interopNamespace(ToggleGroup);
63
65
 
64
66
  /******************************************************************************
65
67
  Copyright (c) Microsoft Corporation.
@@ -5610,6 +5612,100 @@ var FilterBar_utils = /*#__PURE__*/Object.freeze({
5610
5612
  getFilterGroups: getFilterGroups
5611
5613
  });
5612
5614
 
5615
+ const getLocalizedWeekdays = (args) => {
5616
+ const dates = [
5617
+ new Date(Date.UTC(2e3, 4, 1)),
5618
+ new Date(Date.UTC(2e3, 4, 2)),
5619
+ new Date(Date.UTC(2e3, 4, 3)),
5620
+ new Date(Date.UTC(2e3, 4, 4)),
5621
+ new Date(Date.UTC(2e3, 4, 5)),
5622
+ new Date(Date.UTC(2e3, 4, 6)),
5623
+ new Date(Date.UTC(2e3, 4, 7))
5624
+ // sunday
5625
+ ];
5626
+ const formatDayToEnglishName = (date) => new Intl.DateTimeFormat("en-US", { weekday: "long" }).format(date);
5627
+ const formatDateToLocalizedWeekdayLetter = (date) => new Intl.DateTimeFormat(args.locale, { weekday: "narrow" }).format(date);
5628
+ const formatDateToLocalizedFullWeekdayName = (date) => new Intl.DateTimeFormat(args.locale, { weekday: "long" }).format(date);
5629
+ return dates.map((date) => ({
5630
+ /**
5631
+ * The en-US name of the weekday. We'll use this as the value of the checkbox.
5632
+ */
5633
+ englishName: formatDayToEnglishName(date).toLowerCase(),
5634
+ /**
5635
+ * The localized name of the weekday. We'll use this for the screen reader.
5636
+ */
5637
+ localizedFullWeekdayName: formatDateToLocalizedFullWeekdayName(date),
5638
+ /**
5639
+ * The localized single letter indicator of the weekday. We'll use this for the visual indicator.
5640
+ */
5641
+ localizedWeekdayLetter: formatDateToLocalizedWeekdayLetter(date)
5642
+ }));
5643
+ };
5644
+ const oldApiDayToIndexMapping = {
5645
+ sunday: 0,
5646
+ monday: 1,
5647
+ tuesday: 2,
5648
+ wednesday: 3,
5649
+ thursday: 4,
5650
+ friday: 5,
5651
+ saturday: 6
5652
+ };
5653
+ const oldApiIndexToDayMapping = {
5654
+ 0: "sunday",
5655
+ 1: "monday",
5656
+ 2: "tuesday",
5657
+ 3: "wednesday",
5658
+ 4: "thursday",
5659
+ 5: "friday",
5660
+ 6: "saturday"
5661
+ };
5662
+ function weekdayNameToIndex(w) {
5663
+ if (Array.isArray(w)) {
5664
+ return w.map((weekday) => oldApiDayToIndexMapping[weekday]);
5665
+ } else {
5666
+ return oldApiDayToIndexMapping[w];
5667
+ }
5668
+ }
5669
+ function indexToWeekdayName(idx) {
5670
+ if (Array.isArray(idx)) {
5671
+ return idx.map((index) => oldApiIndexToDayMapping[index]);
5672
+ } else {
5673
+ return oldApiIndexToDayMapping[idx];
5674
+ }
5675
+ }
5676
+ const WeekdaysPicker = (props) => {
5677
+ const {
5678
+ locale,
5679
+ selectedOptions,
5680
+ onChange,
5681
+ className,
5682
+ id,
5683
+ /**
5684
+ * Filter out some attributes of `div` that are incompatible with
5685
+ * the type of `ToggleGroup.Root`.
5686
+ */
5687
+ children: _,
5688
+ defaultValue: __,
5689
+ dir: ___
5690
+ } = props, rest = __rest(props, ["locale", "selectedOptions", "onChange", "className", "id", "children", "defaultValue", "dir"]);
5691
+ const options = getLocalizedWeekdays({ locale });
5692
+ return React__namespace.default.createElement(ToggleGroup__namespace.Root, Object.assign({}, rest, { id, className: classNames__default.default("ui-flex ui-gap-2", className), type: "multiple", value: selectedOptions, onValueChange: onChange }), options.map(({ englishName, localizedFullWeekdayName, localizedWeekdayLetter }) => {
5693
+ return React__namespace.default.createElement(ToggleGroup__namespace.Item, { key: englishName, value: englishName, "aria-label": localizedFullWeekdayName, className: classNames__default.default(
5694
+ "ui-transition-[color,background_color,border-color,transform] ui-duration-150 ui-ease-out",
5695
+ "ui-flex ui-h-11 ui-w-11 ui-select-none ui-items-center ui-justify-center ui-rounded-full",
5696
+ /**
5697
+ * Only keyboard users will see this. Black is properly visible
5698
+ * on both selected/unselected states.
5699
+ **/
5700
+ "ui-outline-1 ui-outline-black",
5701
+ "ui-bg-slate-200 hover:ui-bg-slate-300 active:ui-scale-95",
5702
+ "data-[state=on]:ui-bg-blue-800 data-[state=on]:ui-text-white data-[state=on]:hover:ui-bg-blue-900"
5703
+ ) }, localizedWeekdayLetter);
5704
+ }));
5705
+ };
5706
+ WeekdaysPicker.weekdayNameToIndex = weekdayNameToIndex;
5707
+ WeekdaysPicker.indexToWeekdayName = indexToWeekdayName;
5708
+
5613
5709
  exports.AccordionList = AccordionList;
5614
5710
  exports.AddIcon = AddIcon;
5615
5711
  exports.AlertsIcon = AlertsIcon;
@@ -5738,6 +5834,7 @@ exports.UList = UnorderedList;
5738
5834
  exports.UnorderedList = UnorderedList;
5739
5835
  exports.ViewItem = ViewItem;
5740
5836
  exports.WarningIcon = WarningIcon;
5837
+ exports.WeekdaysPicker = WeekdaysPicker;
5741
5838
  exports.getDndListItemProps = getDndListItemProps;
5742
5839
  exports.toast = toast;
5743
5840
  //# sourceMappingURL=index.development.js.map