@loadsmart/loadsmart-ui 8.0.0 → 8.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.
- package/dist/DragDropFile.context-oKnUu6d3.js.map +1 -1
- package/dist/common/BackButton/BackButton.d.ts +2 -1
- package/dist/common/CloseButton/CloseButton.d.ts +3 -2
- package/dist/common/SelectionWrapper.d.ts +8 -8
- package/dist/components/Accordion/Accordion.context.d.ts +6 -6
- package/dist/components/Accordion/Accordion.d.ts +11 -11
- package/dist/components/Accordion/Accordion.stories.d.ts +5 -4
- package/dist/components/Banner/Banner.d.ts +14 -14
- package/dist/components/Banner/Banner.stories.d.ts +11 -11
- package/dist/components/Breadcrumbs/Breadcrumb.d.ts +5 -5
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +6 -6
- package/dist/components/Button/Button.d.ts +8 -8
- package/dist/components/Button/Button.stories.d.ts +7 -7
- package/dist/components/Calendar/Calendar.d.ts +3 -2
- package/dist/components/Calendar/Calendar.stories.d.ts +3 -2
- package/dist/components/Calendar/Calendar.types.d.ts +4 -4
- package/dist/components/Calendar/Date.helper.d.ts +27 -54
- package/dist/components/Calendar/DateFormat.helper.d.ts +1 -3
- package/dist/components/Calendar/Month.helper.d.ts +5 -5
- package/dist/components/Calendar/PickerModeToggle.d.ts +2 -1
- package/dist/components/Calendar/Pickers/DayPicker.d.ts +2 -1
- package/dist/components/Calendar/Pickers/MonthPicker.d.ts +2 -1
- package/dist/components/Calendar/Pickers/YearPicker.d.ts +2 -1
- package/dist/components/Calendar/useCalendar.d.ts +4 -9
- package/dist/components/Card/Card.d.ts +5 -5
- package/dist/components/Card/CardTitle.d.ts +3 -3
- package/dist/components/Checkbox/Checkbox.d.ts +6 -6
- package/dist/components/Checkbox/Checkbox.stories.d.ts +2 -1
- package/dist/components/DatePicker/DatePicker.d.ts +2 -2
- package/dist/components/DatePicker/DatePicker.stories.d.ts +2 -1
- package/dist/components/DatePicker/DateRangePicker.d.ts +2 -1
- package/dist/components/DatePicker/DateRangePicker.stories.d.ts +2 -1
- package/dist/components/Dialog/Dialog.d.ts +13 -13
- package/dist/components/Dialog/Dialog.stories.d.ts +10 -9
- package/dist/components/DragDropFile/DragDropFile.context.d.ts +1 -1
- package/dist/components/DragDropFile/DragDropFile.d.ts +2 -2
- package/dist/components/DragDropFile/DragDropFile.stories.d.ts +5 -4
- package/dist/components/DragDropFile/components/DropZone.d.ts +2 -1
- package/dist/components/DragDropFile/components/FileItem.d.ts +2 -1
- package/dist/components/DragDropFile/components/FileList.d.ts +2 -1
- package/dist/components/DragDropFile/types.d.ts +4 -4
- package/dist/components/Drawer/Drawer.d.ts +7 -7
- package/dist/components/Dropdown/Dropdown.d.ts +2 -5
- package/dist/components/Dropdown/Dropdown.types.d.ts +1 -1
- package/dist/components/Dropdown/DropdownMenu.d.ts +2 -2
- package/dist/components/Dropdown/DropdownTrigger.d.ts +9 -9
- package/dist/components/EmptyState/EmptyState.d.ts +1 -1
- package/dist/components/EmptyState/EmptyState.stories.d.ts +8 -7
- package/dist/components/EmptyState/EmptyState.types.d.ts +2 -2
- package/dist/components/EmptyState/index.d.ts +1 -1
- package/dist/components/ErrorMessage/ErrorMessage.stories.d.ts +3 -2
- package/dist/components/HighlightMatch/HighlightMatch.d.ts +4 -4
- package/dist/components/IconFactory/IconFactory.d.ts +8 -8
- package/dist/components/IconFactory/IconFactory.fixtures.d.ts +6 -6
- package/dist/components/Label/Label.d.ts +9 -9
- package/dist/components/Label/Label.stories.d.ts +2 -1
- package/dist/components/Layout/Box.d.ts +8 -9
- package/dist/components/Layout/Grid.d.ts +4 -5
- package/dist/components/Layout/Group.d.ts +5 -6
- package/dist/components/Layout/Layout.stories.d.ts +8 -7
- package/dist/components/Layout/Sidebar.d.ts +6 -7
- package/dist/components/Layout/Stack.d.ts +5 -6
- package/dist/components/Layout/Switcher.d.ts +5 -6
- package/dist/components/Link/Link.d.ts +3 -3
- package/dist/components/Link/Link.stories.d.ts +2 -1
- package/dist/components/Loaders/LoadingBar.d.ts +6 -6
- package/dist/components/Loaders/LoadingDots.d.ts +4 -3
- package/dist/components/Loaders/Spinner.d.ts +4 -3
- package/dist/components/Modal/Modal.d.ts +3 -3
- package/dist/components/Modal/Modal.stories.d.ts +4 -3
- package/dist/components/Pagination/Pagination.d.ts +2 -1
- package/dist/components/Pagination/Pagination.types.d.ts +4 -4
- package/dist/components/Pagination/PaginationItem.d.ts +2 -1
- package/dist/components/Popover/Popover.d.ts +4 -3
- package/dist/components/ProgressBar/ProgressBar.d.ts +6 -6
- package/dist/components/ProgressBar/ProgressBar.stories.d.ts +2 -1
- package/dist/components/Radio/Radio.d.ts +6 -6
- package/dist/components/Radio/Radio.stories.d.ts +2 -1
- package/dist/components/Section/Section.d.ts +4 -4
- package/dist/components/Section/Sections.stories.d.ts +2 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/Select.fixtures.d.ts +4 -4
- package/dist/components/Select/Select.types.d.ts +14 -14
- package/dist/components/Select/SelectCreatableOption.d.ts +2 -1
- package/dist/components/Select/SelectEmpty.d.ts +2 -1
- package/dist/components/Select/SelectOption.d.ts +2 -1
- package/dist/components/Select/useSelect.d.ts +0 -2
- package/dist/components/SideNavigation/Logo/Logo.d.ts +4 -4
- package/dist/components/SideNavigation/Menu/Menu.d.ts +5 -5
- package/dist/components/SideNavigation/Menu/MenuBaseItem.d.ts +7 -7
- package/dist/components/SideNavigation/Menu/MenuExpandable.d.ts +3 -3
- package/dist/components/SideNavigation/Menu/MenuLink.d.ts +5 -5
- package/dist/components/SideNavigation/Separator/Separator.d.ts +3 -2
- package/dist/components/SideNavigation/SideNavigation.d.ts +13 -13
- package/dist/components/SideNavigation/SideNavigation.stories.d.ts +2 -1
- package/dist/components/Steps/ProgressSteps/ProgressStep.d.ts +5 -5
- package/dist/components/Steps/ProgressSteps/ProgressSteps.d.ts +4 -3
- package/dist/components/Steps/Steps.d.ts +7 -7
- package/dist/components/Steps/Steps.types.d.ts +2 -2
- package/dist/components/Steps/StepsStep.d.ts +4 -4
- package/dist/components/Steps/useSteps.d.ts +2 -2
- package/dist/components/Switch/Switch.d.ts +6 -6
- package/dist/components/Table/Selection.d.ts +5 -5
- package/dist/components/Table/Table.d.ts +14 -13
- package/dist/components/Table/Table.stories.d.ts +7 -6
- package/dist/components/Table/Table.types.d.ts +5 -5
- package/dist/components/Table/TableSortHandle.d.ts +3 -2
- package/dist/components/Table/useSortBy.d.ts +3 -3
- package/dist/components/TablePagination/RowsPerPage.d.ts +2 -1
- package/dist/components/TablePagination/TablePagination.d.ts +2 -1
- package/dist/components/TablePagination/TablePaginationActions.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +10 -10
- package/dist/components/Tabs/Tabs.stories.d.ts +3 -2
- package/dist/components/Tag/Tag.d.ts +11 -11
- package/dist/components/Tag/Tag.stories.d.ts +5 -5
- package/dist/components/TextField/TextField.d.ts +7 -7
- package/dist/components/TextField/TextField.stories.d.ts +2 -1
- package/dist/components/Textarea/Textarea.d.ts +7 -7
- package/dist/components/Textarea/Textarea.stories.d.ts +2 -1
- package/dist/components/Toast/Toast.d.ts +7 -7
- package/dist/components/Toast/Toast.stories.d.ts +2 -1
- package/dist/components/ToggleGroup/Toggle.d.ts +2 -1
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +3 -2
- package/dist/components/Tooltip/Tooltip.d.ts +6 -6
- package/dist/components/Tooltip/Tooltip.stories.d.ts +4 -3
- package/dist/components/TopNavigation/Logo/Logo.d.ts +4 -4
- package/dist/components/TopNavigation/Menu/Menu.d.ts +7 -7
- package/dist/components/TopNavigation/Menu/MenuItemDropdown.d.ts +8 -8
- package/dist/components/TopNavigation/Menu/MenuItemIcon.d.ts +7 -7
- package/dist/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.d.ts +6 -5
- package/dist/components/TopNavigation/TopNavigation.d.ts +5 -5
- package/dist/components/TopNavigation/TopNavigation.stories.d.ts +2 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.stories.d.ts +2 -1
- package/dist/hooks/useDidMount/useDidMount.d.ts +1 -1
- package/dist/hooks/useFingerprint/useFingerprint.d.ts +0 -1
- package/dist/hooks/useFocusTrap/useFocusTrap.d.ts +7 -8
- package/dist/hooks/useFocusWithin/useFocusWithin.d.ts +1 -1
- package/dist/hooks/useHeightExpansionToggler/useHeightExpansionToggler.d.ts +3 -3
- package/dist/hooks/useSelectable/SelectableStrategy.d.ts +4 -4
- package/dist/hooks/useSelectable/useSelectable.types.d.ts +2 -2
- package/dist/index.js +316 -257
- package/dist/index.js.map +1 -1
- package/dist/{miranda-compatibility.theme-kYNEZ7mW.js → miranda-compatibility.theme-CIu9fa89.js} +2 -2
- package/dist/miranda-compatibility.theme-CIu9fa89.js.map +1 -0
- package/dist/{prop-K2Z3EsyG.js → prop-Fs2axl9W.js} +12 -18
- package/dist/prop-Fs2axl9W.js.map +1 -0
- package/dist/styles/activatable.d.ts +2 -3
- package/dist/styles/disableable.d.ts +3 -3
- package/dist/styles/ellipsizable.d.ts +1 -2
- package/dist/styles/focusable.d.ts +3 -3
- package/dist/styles/font.d.ts +0 -1
- package/dist/styles/hidden.d.ts +1 -2
- package/dist/styles/hoverable.d.ts +3 -3
- package/dist/styles/transition.d.ts +0 -1
- package/dist/styles/typography.d.ts +6 -7
- package/dist/testing/DatePickerEvent/DatePickerEvent.d.ts +7 -12
- package/dist/testing/DatePickerEvent/DateRangePickerEvent.d.ts +7 -12
- package/dist/testing/SelectEvent/SelectEvent.d.ts +11 -19
- package/dist/testing/getInterpolatedStyles/getInterpolatedStyles.d.ts +2 -2
- package/dist/testing/index.js +7 -9
- package/dist/testing/index.js.map +1 -1
- package/dist/tests/generator.d.ts +2 -2
- package/dist/tests/renderer.d.ts +5 -4
- package/dist/theming/index.d.ts +3 -3
- package/dist/theming/index.js +2 -2
- package/dist/theming/index.js.map +1 -1
- package/dist/theming/theming.helpers.d.ts +2 -2
- package/dist/toArray-BJJzFRD1.js +13 -0
- package/dist/toArray-BJJzFRD1.js.map +1 -0
- package/dist/tools/conditional.d.ts +3 -3
- package/dist/tools/index.js +1 -1
- package/dist/tools/prop.d.ts +1 -1
- package/dist/utils/toolset/getID.d.ts +0 -6
- package/dist/utils/toolset/highlightMatch.d.ts +5 -6
- package/dist/utils/toolset/keyboard.d.ts +3 -4
- package/dist/utils/toolset/toArray.d.ts +7 -1
- package/package.json +53 -56
- package/dist/miranda-compatibility.theme-kYNEZ7mW.js.map +0 -1
- package/dist/prop-K2Z3EsyG.js.map +0 -1
- package/dist/toArray-Dxb1kUxx.js +0 -14
- package/dist/toArray-Dxb1kUxx.js.map +0 -1
- package/dist/utils/toolset/flatten.d.ts +0 -2
- package/dist/utils/toolset/isThenable.d.ts +0 -5
- package/dist/utils/toolset/isThenable.test.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-Fs2axl9W.js","sources":["../src/tools/conditional.ts","../src/tools/prop.ts"],"sourcesContent":["import { isObject } from '@loadsmart/utils-object'\nimport { isFunction } from '@loadsmart/utils-function'\nimport type { F } from 'ts-toolbelt'\n\nimport { getToken } from 'theming'\nimport type { ThemeToken, ThemedProps } from 'theming'\nimport get from 'utils/toolset/get'\nimport toArray from 'utils/toolset/toArray'\n\ntype WhenProps<K> = K | undefined | ((value: K) => boolean | undefined)\n\nexport type When<P> = {\n [Key in keyof P]?: WhenProps<P[Key]> | WhenProps<P[Key]>[] | undefined\n}\n\n/**\n * Utility to generate style/class name conditions based on a components props.\n * Expected prop values can be a single value, an array of values or a function/callback.\n * @example\n * ```jsx\n * whenProps({\n * 'prop-a': true, // checks `props['prop-a']` === true`\n * 'prop-b': [1, 2], // checks `toArray([1, 2]).includes(props['prop-b'])`\n * 'prop-c': (value) => value + 1 // checks `Boolean(callback(props['prop-c']))`\n * 'prop-d': Boolean // checks `Boolean(Boolean(props['prop-d']))`\n * })\n * ```\n * @param conditions\n * @returns Returns function that consumes component props.\n */\nexport function whenProps<P>(conditions: When<F.Narrow<P>> | When<F.Narrow<P>>[]) {\n return function (props: P): boolean {\n const safeConditions = toArray(conditions)\n\n return safeConditions.some((condition) => {\n const keys = Object.keys(condition)\n\n return keys.every((key) => {\n const propValue = get(props, key) as P[keyof P]\n const conditionValue = condition[key as keyof typeof condition]\n\n if (Array.isArray(conditionValue)) {\n return toArray(conditionValue).includes(propValue)\n }\n if (isFunction(conditionValue)) {\n return Boolean(conditionValue(propValue))\n }\n return (conditionValue as unknown) === propValue\n })\n })\n }\n}\n\ntype ConditionObject<P> = Record<\n string,\n string | number | boolean | ((props: P) => boolean) | undefined\n>\n\nfunction handleConditionObject<P>(condition: ConditionObject<P>, props: P): string {\n const keys = Object.keys(condition)\n\n const res = keys.reduce<string[]>((acc, key) => {\n let value = condition[key]\n\n if (isFunction(value)) {\n value = value(props)\n }\n\n if (value) {\n const tokenKey = key as ThemeToken\n\n const result = (getToken(tokenKey, props as unknown as ThemedProps) ?? key) as string\n return [...acc, result]\n }\n\n return acc\n }, [])\n\n return res.join(' ')\n}\n\ntype Condition<P> = number | string | ConditionObject<P> | ((props: P) => string)\n\n/**\n * Concatenate style properties or class names conditionally.\n * Conditions can be functions that consume components props,\n * objects, strings, or numbers (that will be coerced to strings).\n * @example\n * ```jsx\n * conditional(1, 'some-class', {\n * 'class-a': true,\n * 'class-b': (props) => props.showClassB,\n * }, (props) => props.className)\n * ```\n * @param conditions\n * @returns Returns function that consumes component props.\n */\nfunction conditional<P>(...conditions: Condition<P>[]) {\n return function (props: P): string {\n let classes: string[] = []\n\n for (let i = 0; i < conditions.length; i++) {\n const condition = conditions[i]\n\n if (isFunction(condition)) {\n classes.push(condition(props))\n } else if (isObject(condition)) {\n classes = classes.concat(handleConditionObject<P>(condition, props))\n } else if (condition) {\n classes.push(String(condition))\n }\n }\n\n return classes.join(' ')\n }\n}\n\nexport default conditional\n","function compare(...args: any[]): unknown {\n const [value, defaultValue] = args\n\n if (value == null || value === false || Number.isNaN(value)) {\n return defaultValue || value\n }\n\n if (typeof value === 'string' && value.length === 0) {\n return defaultValue || value\n }\n\n return value\n}\n\n/**\n * Retrieve the key value from the props object\n * @example\n * ```jsx\n * -transform: scaleY(${(props) => props.$height || 1});\n * +transform: scaleY(${prop('$height', 1)});\n * ```\n * @param name a valid property name from the object\n * @param defaultValue a fallback value in case the property value is invalid\n * @param comparatorFn a function to be used to decide between value or defaultValue\n * @returns Returns function that consumes component props.\n */\nfunction prop<P, K extends keyof P = keyof P>(\n name: K,\n defaultValue?: NonNullable<P[K]>,\n comparatorFn = compare\n) {\n return (props: P): P[K] => comparatorFn(props[name], defaultValue) as P[K]\n}\n\nexport default prop\n"],"names":["whenProps","conditions","props","safeConditions","toArray","some","condition","keys","Object","every","key","propValue","get","conditionValue","Array","isArray","includes","isFunction","Boolean","handleConditionObject","res","reduce","acc","value","tokenKey","result","getToken","join","conditional","classes","i","length","push","isObject","concat","String","compare","args","defaultValue","Number","isNaN","prop","name","comparatorFn"],"mappings":";;;;;AA8BO,SAASA,UAAaC,YAAqD;AAChF,SAAO,SAAUC,OAAmB;AAClC,UAAMC,iBAAiBC,QAAQH,UAAU;AAEzC,WAAOE,eAAeE,KAAMC,CAAAA,cAAc;AACxC,YAAMC,OAAOC,OAAOD,KAAKD,SAAS;AAElC,aAAOC,KAAKE,MAAOC,CAAAA,QAAQ;AACzB,cAAMC,YAAYC,IAAIV,OAAOQ,GAAG;AAChC,cAAMG,iBAAiBP,UAAUI,GAA6B;AAE9D,YAAII,MAAMC,QAAQF,cAAc,GAAG;AACjC,iBAAOT,QAAQS,cAAc,EAAEG,SAASL,SAAS;AAAA,QACnD;AACA,YAAIM,WAAWJ,cAAc,GAAG;AAC9B,iBAAOK,QAAQL,eAAeF,SAAS,CAAC;AAAA,QAC1C;AACA,eAAQE,mBAA+BF;AAAAA,MACzC,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;AAOA,SAASQ,sBAAyBb,WAA+BJ,OAAkB;AACjF,QAAMK,OAAOC,OAAOD,KAAKD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O,CAAClC,UAAmByC,aAAazC,MAAMwC,IAAI,GAAGJ,YAAY;AACnE;"}
|
|
@@ -2,9 +2,8 @@ import { InterpolatedStyle } from '../utils/types/InterpolatedStyle';
|
|
|
2
2
|
/**
|
|
3
3
|
* Add basic CSS style wrapping block for `:active` state.
|
|
4
4
|
* It returns an array to allow handling of nested interpolation
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @returns {any[]}
|
|
5
|
+
* @param strings - String parts for the interpolation.
|
|
6
|
+
* @param args - Interpolated items.
|
|
8
7
|
*/
|
|
9
8
|
declare function activatableStyle(strings?: ReadonlyArray<string> | Array<string>, ...args: any[]): InterpolatedStyle;
|
|
10
9
|
export default activatableStyle;
|
|
@@ -2,9 +2,9 @@ import { InterpolatedStyle } from '../utils/types/InterpolatedStyle';
|
|
|
2
2
|
/**
|
|
3
3
|
* Add basic CSS style wrapping block for `:disabled` state or `.is-disabled` class.
|
|
4
4
|
* It returns an array to allow handling of nested interpolation
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
5
|
+
* @param strings - String parts for the interpolation.
|
|
6
|
+
* @param args - Interpolated items.
|
|
7
|
+
* @returns Interpolated style array.
|
|
8
8
|
*/
|
|
9
9
|
declare function disableableStyle(strings?: ReadonlyArray<string> | Array<string>, ...args: any[]): InterpolatedStyle;
|
|
10
10
|
export default disableableStyle;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add basic CSS style for ellipsizing the content of an element.
|
|
3
|
-
* Setting `max-width` is a
|
|
4
|
-
* @returns {string}
|
|
3
|
+
* Setting `max-width` is a responsibility of the caller.
|
|
5
4
|
*/
|
|
6
5
|
declare function ellipsizableStyle(): string;
|
|
7
6
|
export default ellipsizableStyle;
|
|
@@ -2,9 +2,9 @@ import { InterpolatedStyle } from '../utils/types/InterpolatedStyle';
|
|
|
2
2
|
/**
|
|
3
3
|
* Add basic CSS style wrapping block for `:active` state.
|
|
4
4
|
* It returns an array to allow handling of nested interpolation
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
5
|
+
* @param strings - String parts for the interpolation.
|
|
6
|
+
* @param args - Interpolated items.
|
|
7
|
+
* @returns Interpolated style array.
|
|
8
8
|
*/
|
|
9
9
|
declare function focusableStyle(strings?: ReadonlyArray<string> | Array<string>, ...args: any[]): InterpolatedStyle;
|
|
10
10
|
export default focusableStyle;
|
package/dist/styles/font.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ interface FontStyleOptions {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Add basic CSS style for default font
|
|
13
|
-
* @returns {FlattenInterpolation}
|
|
14
13
|
*/
|
|
15
14
|
declare function fontStyle({ color, weight, size, family, height, transform, }: FontStyleOptions): FlattenInterpolation<ThemedProps>;
|
|
16
15
|
export default fontStyle;
|
package/dist/styles/hidden.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add basic CSS style for hide elements
|
|
3
|
-
* @param
|
|
4
|
-
* @returns {string}
|
|
3
|
+
* @param accessible - should keep element visible for screen readers
|
|
5
4
|
*/
|
|
6
5
|
declare function hiddenStyle(accessible?: boolean): string;
|
|
7
6
|
export default hiddenStyle;
|
|
@@ -2,9 +2,9 @@ import { InterpolatedStyle } from '../utils/types/InterpolatedStyle';
|
|
|
2
2
|
/**
|
|
3
3
|
* Add basic CSS style wrapping block for `:hover` state; it includes check for non-disabled (`:enabled` or not `.is-disabled`) elements.
|
|
4
4
|
* It returns an array to allow handling of nested interpolation
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
5
|
+
* @param strings - String parts for the interpolation.
|
|
6
|
+
* @param args - Interpolated items.
|
|
7
|
+
* @returns Interpolated style array.
|
|
8
8
|
*/
|
|
9
9
|
declare function hoverableStyle(strings?: ReadonlyArray<string> | Array<string>, ...args: any[]): InterpolatedStyle;
|
|
10
10
|
export default hoverableStyle;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { ThemeToken } from '../theming';
|
|
2
|
-
export
|
|
2
|
+
export interface TypographyOptions {
|
|
3
3
|
italic?: boolean;
|
|
4
4
|
color?: ThemeToken;
|
|
5
|
-
}
|
|
6
|
-
|
|
5
|
+
}
|
|
6
|
+
interface PropertiesToken {
|
|
7
7
|
fontSize: ThemeToken;
|
|
8
8
|
lineHeight: ThemeToken;
|
|
9
9
|
fontWeight: ThemeToken;
|
|
10
10
|
fontFamily?: ThemeToken;
|
|
11
11
|
textTransform?: 'none' | 'uppercase';
|
|
12
12
|
color?: ThemeToken;
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
export type TypographyVariants = 'heading-lg' | 'heading-md' | 'heading-md-bold' | 'heading-sm' | 'heading-sm-bold' | 'body' | 'body-bold' | 'caption' | 'caption-bold' | 'number-sm' | 'number-md' | 'button-sm' | 'button-md' | 'button-lg' | 'table-header-sm' | 'table-header-md' | 'chips-sm' | 'link';
|
|
15
15
|
type TypographyProperties = Record<TypographyVariants, PropertiesToken>;
|
|
16
16
|
export declare const typographyProperties: TypographyProperties;
|
|
17
17
|
/**
|
|
18
18
|
* Standard styles for screen-rendered text
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @returns {FlattenInterpolation}
|
|
19
|
+
* @param variant Name of the variant
|
|
20
|
+
* @param options Add boldness, italics and color
|
|
22
21
|
*/
|
|
23
22
|
declare function typography<P>(variant?: TypographyVariants | ((props: P) => string), options?: TypographyOptions): import('styled-components').FlattenInterpolation<import('styled-components').ThemedStyledProps<import('../theming').ThemedProps, any>> | ((props: P) => import('styled-components').FlattenInterpolation<import('styled-components').ThemedStyledProps<import('../theming').ThemedProps, any>> | ((props: unknown) => import('styled-components').FlattenInterpolation<import('styled-components').ThemedStyledProps<import('../theming').ThemedProps, any>> | /*elided*/ any));
|
|
24
23
|
export default typography;
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
declare function getContainerFromInput(input: HTMLElement): HTMLElement;
|
|
2
2
|
/**
|
|
3
3
|
* Expand the `DatePicker` calendar, if it not already expanded.
|
|
4
|
-
* @param
|
|
5
|
-
* @returns {Promise<void>}
|
|
4
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
6
5
|
*/
|
|
7
6
|
declare function expand(input: HTMLElement): Promise<void>;
|
|
8
7
|
/**
|
|
9
8
|
* Collapse the `DatePicker` calendar, if it not already collapsed.
|
|
10
|
-
* @param
|
|
11
|
-
* @returns {Promise<void>}
|
|
9
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
12
10
|
*/
|
|
13
11
|
declare function collapse(input: HTMLElement): Promise<void>;
|
|
14
12
|
/**
|
|
15
13
|
* Pick (select) the provided day in the current month/year.
|
|
16
|
-
* Notice that we
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @returns {Promise<void>}
|
|
14
|
+
* Notice that we programmatically expand the `DatePicker` calendar before picking the date.
|
|
15
|
+
* @param day - Label for the day to be picked, formatted as mm/dd/yyyy.
|
|
16
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
20
17
|
*/
|
|
21
18
|
declare function pick(day: string, input: HTMLElement): Promise<void>;
|
|
22
19
|
/**
|
|
23
20
|
* Clear the selection, if there are any options selected.
|
|
24
|
-
* @param
|
|
25
|
-
* @returns {Promise<void>}
|
|
21
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
26
22
|
*/
|
|
27
23
|
declare function clear(input: HTMLElement): Promise<void>;
|
|
28
24
|
/**
|
|
29
25
|
* Get options elements currently selected in the `DatePicker` calendar.
|
|
30
|
-
* @param
|
|
31
|
-
* @returns {Promise<HTMLElement[]>}
|
|
26
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
32
27
|
*/
|
|
33
28
|
declare function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]>;
|
|
34
29
|
declare const datePickerEvent: {
|
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Expand the `DatePicker` calendar, if it not already expanded.
|
|
3
|
-
* @param
|
|
4
|
-
* @returns {Promise<void>}
|
|
3
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
5
4
|
*/
|
|
6
5
|
declare function expand(input: HTMLElement): Promise<void>;
|
|
7
6
|
/**
|
|
8
7
|
* Collapse the `DatePicker` calendar, if it not already collapsed.
|
|
9
|
-
* @param
|
|
10
|
-
* @returns {Promise<void>}
|
|
8
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
11
9
|
*/
|
|
12
10
|
declare function collapse(input: HTMLElement): Promise<void>;
|
|
13
11
|
/**
|
|
14
12
|
* Pick (select) the provided day in the current month/year.
|
|
15
|
-
* Notice that we
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @returns {Promise<void>}
|
|
13
|
+
* Notice that we programmatically expand the `DatePicker` calendar before picking the date.
|
|
14
|
+
* @param day - Label for the day to be picked, formatted as mm/dd/yyyy.
|
|
15
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
19
16
|
*/
|
|
20
17
|
declare function pick(range: [string | null, string | null], input: HTMLElement): Promise<void>;
|
|
21
18
|
/**
|
|
22
19
|
* Clear the selection, if there are any options selected.
|
|
23
|
-
* @param
|
|
24
|
-
* @returns {Promise<void>}
|
|
20
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
25
21
|
*/
|
|
26
22
|
declare function clear(input: HTMLElement): Promise<void>;
|
|
27
23
|
/**
|
|
28
24
|
* Get options elements currently selected in the `DatePicker` calendar.
|
|
29
|
-
* @param
|
|
30
|
-
* @returns {Promise<HTMLElement[]>}
|
|
25
|
+
* @param input - You can refer to this element by the label you applied to the `DatePicker`
|
|
31
26
|
*/
|
|
32
27
|
declare function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]>;
|
|
33
28
|
export declare const dateRangePickerEvent: {
|
|
@@ -1,55 +1,47 @@
|
|
|
1
1
|
declare function isSelectMenuExpanded(input: HTMLElement): boolean;
|
|
2
2
|
/**
|
|
3
3
|
* Expand the `Select` menu, if it not already expanded.
|
|
4
|
-
*
|
|
5
|
-
* @returns {Promise<void>}
|
|
4
|
+
* input - You can refer to this element by the label you applied to the `Select`.
|
|
6
5
|
*/
|
|
7
6
|
declare function expand(input: HTMLElement): Promise<void>;
|
|
8
7
|
/**
|
|
9
8
|
* Collapse the `Select` menu, if it not already collapsed.
|
|
10
|
-
* @param
|
|
11
|
-
* @returns {Promise<void>}
|
|
9
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
12
10
|
*/
|
|
13
11
|
declare function collapse(input: HTMLElement): Promise<void>;
|
|
14
12
|
/**
|
|
15
13
|
* Select the provided option(s), if they are present in the menu.
|
|
16
14
|
* Notice that we programatically expand the `Select` menu before select the item
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @returns {Promise<void>}
|
|
15
|
+
* @param option - Label for the option to be selected.
|
|
16
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
20
17
|
*/
|
|
21
18
|
declare function select(option: string | RegExp, input: HTMLElement): Promise<void>;
|
|
22
19
|
/**
|
|
23
20
|
* Unselect the provided option(s), if they are present in the menu AND are selected.
|
|
24
21
|
* Notice that we programatically expand the `Select` menu before select the item
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @returns {Promise<void>}
|
|
22
|
+
* @param option - Label for the option to be unselected.
|
|
23
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
28
24
|
*/
|
|
29
25
|
declare function unselect(option: string, input: HTMLElement): Promise<void>;
|
|
30
26
|
/**
|
|
31
27
|
* Clear the selection, if there are any options selected.
|
|
32
|
-
* @param
|
|
33
|
-
* @returns {Promise<void>}
|
|
28
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
34
29
|
*/
|
|
35
30
|
declare function clear(input: HTMLElement): Promise<void>;
|
|
36
31
|
/**
|
|
37
32
|
* Perform search based on the given `query`. It will fail if the option is not found.
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
40
|
-
* @returns {Promise<void>}
|
|
33
|
+
* @param query - Search term.
|
|
34
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
41
35
|
*/
|
|
42
36
|
declare function search(query: string, input: HTMLElement): Promise<void>;
|
|
43
37
|
/**
|
|
44
38
|
* Get options elements currently available in the `Select` menu.
|
|
45
|
-
* @param
|
|
46
|
-
* @returns {Promise<HTMLElement[]>}
|
|
39
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
47
40
|
*/
|
|
48
41
|
declare function getOptions(input: HTMLElement): Promise<HTMLElement[]>;
|
|
49
42
|
/**
|
|
50
43
|
* Get options elements currently selected in the `Select` menu.
|
|
51
|
-
* @param
|
|
52
|
-
* @returns {Promise<HTMLElement[]>}
|
|
44
|
+
* @param input - You can refer to this element by the label you applied to the `Select`.
|
|
53
45
|
*/
|
|
54
46
|
declare function getSelectedOptions(input: HTMLElement): Promise<HTMLElement[]>;
|
|
55
47
|
export declare const selectEvent: {
|
|
@@ -3,8 +3,8 @@ import { CustomTheme } from '../../theming';
|
|
|
3
3
|
type ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>;
|
|
4
4
|
/**
|
|
5
5
|
* Use this function to simulate the CSS that would be generated by styled-components
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
6
|
+
* @param styles - A `css` reference with interpolated styles
|
|
7
|
+
* @returns The final CSS
|
|
8
8
|
*/
|
|
9
9
|
export default function getInterpolatedStyles(styles: ThemedInterpolation): string;
|
|
10
10
|
export {};
|
package/dist/testing/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { queries, fireEvent, act, waitFor, createEvent, within, waitForElementToBeRemoved, render } from "@testing-library/react";
|
|
2
|
-
import { t as toArray } from "../toArray-
|
|
2
|
+
import { t as toArray } from "../toArray-BJJzFRD1.js";
|
|
3
3
|
import { isFunction } from "@loadsmart/utils-function";
|
|
4
|
-
import { a as alice } from "../miranda-compatibility.theme-
|
|
4
|
+
import { a as alice } from "../miranda-compatibility.theme-CIu9fa89.js";
|
|
5
5
|
import React__default from "react";
|
|
6
6
|
import { D as DragDropFileContext } from "../DragDropFile.context-oKnUu6d3.js";
|
|
7
7
|
function getContainerFromInput(input) {
|
|
@@ -34,7 +34,7 @@ async function pick$1(day, input) {
|
|
|
34
34
|
input.focus();
|
|
35
35
|
});
|
|
36
36
|
const dayElement = queries.getByLabelText(datePickerContainer, day);
|
|
37
|
-
if (dayElement
|
|
37
|
+
if (dayElement.getAttribute("aria-checked") == "false") {
|
|
38
38
|
fireEvent.click(dayElement);
|
|
39
39
|
}
|
|
40
40
|
await collapse$2(input);
|
|
@@ -179,7 +179,7 @@ async function select(option, input) {
|
|
|
179
179
|
await expand(input);
|
|
180
180
|
const menuContainer = getSelectMenu(input);
|
|
181
181
|
const optionElement = await within(menuContainer).findByLabelText(option);
|
|
182
|
-
if (optionElement
|
|
182
|
+
if (optionElement.getAttribute("aria-selected") == "false") {
|
|
183
183
|
fireEvent.mouseDown(optionElement);
|
|
184
184
|
act(() => {
|
|
185
185
|
optionElement.focus();
|
|
@@ -193,7 +193,7 @@ async function unselect(option, input) {
|
|
|
193
193
|
await expand(input);
|
|
194
194
|
const menuContainer = getSelectMenu(input);
|
|
195
195
|
const optionElement = await within(menuContainer).findByLabelText(option);
|
|
196
|
-
if (optionElement
|
|
196
|
+
if (optionElement.getAttribute("aria-selected") === "true") {
|
|
197
197
|
fireEvent.click(optionElement);
|
|
198
198
|
}
|
|
199
199
|
await collapse(input);
|
|
@@ -202,9 +202,7 @@ async function clear(input) {
|
|
|
202
202
|
await waitForPendingQuery(input);
|
|
203
203
|
const searchContainer = getSelectSearchContainer(input);
|
|
204
204
|
const clearButton = within(searchContainer).getByTestId("select-trigger-clear");
|
|
205
|
-
|
|
206
|
-
fireEvent.click(clearButton);
|
|
207
|
-
}
|
|
205
|
+
fireEvent.click(clearButton);
|
|
208
206
|
}
|
|
209
207
|
async function search(query, input) {
|
|
210
208
|
fireEvent.change(input, {
|
|
@@ -231,7 +229,7 @@ async function getSelectedOptions(input) {
|
|
|
231
229
|
selectedOptions = await within(menuContainer).findAllByRole("option", {
|
|
232
230
|
selected: true
|
|
233
231
|
});
|
|
234
|
-
} catch
|
|
232
|
+
} catch {
|
|
235
233
|
selectedOptions = [];
|
|
236
234
|
}
|
|
237
235
|
await collapse(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/testing/DatePickerEvent/DatePickerEvent.ts","../../src/testing/DatePickerEvent/DateRangePickerEvent.ts","../../src/testing/DragDropFileEvent/DragDropFileEvent.ts","../../src/testing/SelectEvent/SelectEvent.ts","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts","../../src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx"],"sourcesContent":["/* eslint-disable */\nimport { act, queries, fireEvent, waitFor, waitForElementToBeRemoved } from '@testing-library/react'\n// find the date picker container from its input field 🤷\nfunction getContainerFromInput(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is rendered, then the select is already expanded\n if (queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(input)\n\n await waitFor(() => {\n expect(queries.getByRole(datePickerContainer, 'menu')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is not rendered, then the select is already collapsed\n if (!queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(queries.getByText(datePickerContainer, 'Close'))\n\n await waitFor(() => {\n expect(queries.queryByRole(datePickerContainer, 'menu')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(day: string, input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n act(() => {\n input.focus()\n })\n\n const dayElement = queries.getByLabelText(datePickerContainer, day)\n\n if (dayElement && dayElement.getAttribute('aria-checked') == 'false') {\n fireEvent.click(dayElement)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n const clearButton = queries.getByLabelText(datePickerContainer, 'Clear selection')\n\n fireEvent.click(clearButton)\n\n await collapse(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n const selectedDays: HTMLElement[] = queries.queryAllByRole(datePickerContainer, 'checkbox', {\n checked: true,\n })\n\n await collapse(input)\n\n return selectedDays\n}\n\nconst datePickerEvent = {\n getContainer: getContainerFromInput,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default datePickerEvent\n","/* eslint-disable */\nimport { queries } from '@testing-library/react'\n\nimport DatePickerEvent from './DatePickerEvent'\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await DatePickerEvent.expand(input)\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n await DatePickerEvent.collapse(input)\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(range: [string | null, string | null], input: HTMLElement): Promise<void> {\n const dateRangePickerContainer = DatePickerEvent.getContainer(input)\n\n await expand(input)\n\n const [rangeStart, rangeEnd] = range\n\n if (rangeStart != null) {\n const dateRangeStartInput = queries.getByTestId(\n dateRangePickerContainer,\n 'input-date-range-start'\n )\n\n await DatePickerEvent.pick(rangeStart, dateRangeStartInput)\n }\n\n if (rangeEnd != null) {\n const dateRangeEndInput = queries.getByTestId(dateRangePickerContainer, 'input-date-range-end')\n\n await DatePickerEvent.pick(rangeEnd, dateRangeEndInput)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await DatePickerEvent.clear(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n return DatePickerEvent.getSelectedDates(input)\n}\n\nexport const dateRangePickerEvent = {\n getContainer: DatePickerEvent.getContainer,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default dateRangePickerEvent\n","import { createEvent, fireEvent } from '@testing-library/react'\n\nimport toArray from 'utils/toolset/toArray'\n\n/**\n * Get the input dropzone, which is the input parent (label).\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst getDropZoneFromInput = (input: HTMLInputElement): HTMLLabelElement =>\n input.parentNode as HTMLLabelElement\n\n/**\n * Simulates the onDragOver event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragOver = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragOverEvent = createEvent.dragOver(dropzone)\n\n fireEvent(dropzone, dragOverEvent)\n}\n\n/**\n * Simulates the onDragLeave event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragLeave = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragLeaveEvent = createEvent.dragLeave(dropzone)\n\n fireEvent(dropzone, dragLeaveEvent)\n}\n\n/**\n * Simulates the onDrop event on the drop zone. You can provide a list of files or a single file.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dropFiles = (input: HTMLInputElement, files: File | File[]) => {\n const dropzone = getDropZoneFromInput(input)\n\n const fileDropEvent = createEvent.drop(dropzone)\n\n Object.defineProperty(fileDropEvent, 'dataTransfer', { value: { files: toArray(files) } })\n\n fireEvent(dropzone, fileDropEvent)\n}\n\nexport const DragDropFileEvent = {\n dragOver,\n dragLeave,\n dropFiles,\n}\n\nexport default DragDropFileEvent\n","import { act, waitFor, within, waitForElementToBeRemoved, fireEvent } from '@testing-library/react'\n\n// based on https://github.com/romgain/react-select-event/blob/master/src/index.ts\n\n// find the select container from its input field 🤷\nfunction getSelectContainer(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Please, make sure to call expand before trying to get the menu container\n */\nfunction getSelectMenu(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.nextSibling as HTMLElement\n}\n\nfunction getSelectTriggerHandle(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.nextSibling!.nextSibling as HTMLElement\n}\n\nfunction getSelectSearchContainer(input: HTMLElement): HTMLElement {\n return input.parentNode as HTMLElement\n}\n\nfunction isSelectMenuExpanded(input: HTMLElement): boolean {\n const selectContainer = getSelectContainer(input)\n\n /**\n * Once the select is expanded, we have the following structure:\n * +-------------+\n * | Close button (visually hidden)\n * +-------------+\n * | DropdownTrigger\n * +-------------+\n * | Popover\n * +-------------+\n *\n * This, if the container has 3 children, we assume the menu is expanded\n */\n return selectContainer.children.length === 3\n}\n\n/**\n * This is needed because some datasources might be asynchronous.\n * To ensure that the data they retrieve will be available, we wait for the\n * querying phase to finish.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function waitForPendingQuery(input: HTMLElement) {\n const searchContainer = getSelectSearchContainer(input)\n\n if (!within(searchContainer).queryByTestId('select-trigger-loading')) {\n return\n }\n\n await waitForElementToBeRemoved(\n () => within(searchContainer).queryByTestId('select-trigger-loading'),\n { timeout: 2500 }\n )\n}\n\n/**\n * Expand the `Select` menu, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n if (isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n await waitFor(() => {\n expect(triggerHandle).toBeEnabled()\n })\n\n /**\n * Using act and a manually dispatched event so we can account for the\n * state changes that happen when the search input is clicked.\n * This is mainly related to the `handleEvent` from the `useClickOutside` hook.\n */\n act(() => {\n input.dispatchEvent(new MouseEvent('click', { bubbles: true }))\n })\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).getByRole('listbox')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `Select` menu, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n if (!isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n fireEvent.click(triggerHandle)\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).queryByRole('listbox')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Select the provided option(s), if they are present in the menu.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string | RegExp} option - Label for the option to be selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function select(option: string | RegExp, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // click the option if exists; Select currently closes when an item is clicked.\n if (optionElement && optionElement.getAttribute('aria-selected') == 'false') {\n /**\n * This is a replacement for the `userEvent.click`.\n * We are adopting this approach to remove the peer dep to @testing-library/user-event for\n * applications using this helper, so they are not tied to the same user-event as this library.\n * It follows the same sequence of event stated in the documentation available at:\n * https://testing-library.com/docs/guide-events/#interactions-vs-events\n */\n fireEvent.mouseDown(optionElement)\n\n act(() => {\n optionElement.focus()\n })\n\n fireEvent.mouseUp(optionElement)\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Unselect the provided option(s), if they are present in the menu AND are selected.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string} option - Label for the option to be unselected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function unselect(option: string, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // ensures that the option exists and IS selected\n if (optionElement && optionElement.getAttribute('aria-selected') === 'true') {\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n const searchContainer = getSelectSearchContainer(input)\n\n const clearButton = within(searchContainer).getByTestId('select-trigger-clear')\n\n if (clearButton) {\n fireEvent.click(clearButton)\n }\n}\n\n/**\n * Perform search based on the given `query`. It will fail if the option is not found.\n * @param {string} query - Search term.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function search(query: string, input: HTMLElement): Promise<void> {\n fireEvent.change(input, {\n target: { value: query },\n })\n\n await waitForPendingQuery(input)\n\n const menuContainer = getSelectMenu(input)\n\n await within(menuContainer).findAllByRole('option')\n}\n\n/**\n * Get options elements currently available in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const options = within(menuContainer).queryAllByRole('option')\n\n await collapse(input)\n\n return options\n}\n\n/**\n * Get options elements currently selected in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n let selectedOptions: HTMLElement[] = []\n\n try {\n selectedOptions = await within(menuContainer).findAllByRole('option', {\n selected: true,\n })\n } catch (err) {\n selectedOptions = []\n }\n\n await collapse(input)\n\n return selectedOptions\n}\n\nexport const selectEvent = {\n select,\n unselect,\n clear,\n search,\n expand,\n collapse,\n getOptions,\n getSelectedOptions,\n isMenuExpanded: isSelectMenuExpanded,\n}\n\nexport default selectEvent\n","import type { Interpolation, ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\n\nimport { Alice } from '../../theming/themes'\nimport type { CustomTheme } from '../../theming'\nimport toArray from 'utils/toolset/toArray'\n\ntype ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>\n\n/**\n * Use this function to simulate the CSS that would be generated by styled-components\n * @param {Interpolation<ThemeProps<CustomTheme>>} styles - A `css` reference with interpolated styles\n * @returns {string} The final CSS\n */\nexport default function getInterpolatedStyles(styles: ThemedInterpolation): string {\n return toArray(styles)\n .map((interpolation) => {\n while (isFunction(interpolation)) {\n interpolation = interpolation({ theme: Alice })\n }\n\n return interpolation\n })\n .join('')\n}\n","import React, { ReactNode } from 'react'\nimport { render } from '@testing-library/react'\nimport type { RenderResult } from '@testing-library/react'\n\nimport type { DragDropFileContextValue } from '../../components/DragDropFile/types'\nimport { DragDropFileContext } from '../../components/DragDropFile/DragDropFile.context'\n\nconst defaultContextValueMock: DragDropFileContextValue = {\n fileList: [],\n onFilesAdded: jest.fn(),\n onRetryUpload: jest.fn(),\n onRemoveFile: jest.fn(),\n}\n\nconst renderWithDragDropFileProvider = (\n ui: ReactNode,\n customContext?: Partial<DragDropFileContextValue>\n): RenderResult => {\n const contextValue = { ...defaultContextValueMock, ...customContext }\n\n const renderedUi = (children: ReactNode) => (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n\n return render(renderedUi(ui))\n}\n\nexport default renderWithDragDropFileProvider\n"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","fireEvent","click","waitFor","expect","getByRole","toBeInTheDocument","collapse","getByText","not","pick","day","act","focus","dayElement","getByLabelText","getAttribute","clear","clearButton","getSelectedDates","selectedDays","queryAllByRole","checked","datePickerEvent","getContainer","DatePickerEvent","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","dateRangePickerEvent","getDropZoneFromInput","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","defineProperty","value","toArray","DragDropFileEvent","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","selectContainer","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","waitForElementToBeRemoved","timeout","triggerHandle","toBeEnabled","dispatchEvent","MouseEvent","bubbles","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","err","selectEvent","isMenuExpanded","getInterpolatedStyles","styles","map","interpolation","isFunction","theme","Alice","join","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","renderWithDragDropFileProvider","ui","customContext","contextValue","renderedUi","React","render"],"mappings":";;;;;;AAGA,SAASA,sBAAsBC,OAAiC;AAEvDA,SAAAA,MAAMC,WAAYA,WAAYA,WAAYA;AACnD;AAOA,eAAeC,SAAOF,OAAmC;AACjDG,QAAAA,sBAAsBJ,sBAAsBC,KAAK;AAGvD,MAAII,QAAQC,YAAYF,qBAAqB,MAAM,GAAG;AACpD;AAAA,EAAA;AAGFG,YAAUC,MAAMP,KAAK;AAErB,QAAMQ,QAAQ,MAAM;AAClBC,WAAOL,QAAQM,UAAUP,qBAAqB,MAAM,CAAC,EAAEQ,kBAAkB;AAAA,EAAA,CAC1E;AACH;AAOA,eAAeC,WAASZ,OAAmC;AACnDG,QAAAA,sBAAsBJ,sBAAsBC,KAAK;AAGvD,MAAI,CAACI,QAAQC,YAAYF,qBAAqB,MAAM,GAAG;AACrD;AAAA,EA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,sBAAsBC,QAAqC;AACjF,SAAO5C,QAAQ4C,MAAM,EAClBC,IAAKC,CAAkB,kBAAA;AACfC,WAAAA,WAAWD,aAAa,GAAG;AAChCA,sBAAgBA,cAAc;AAAA,QAAEE,OAAOC;AAAAA,MAAAA,CAAO;AAAA,IAAA;AAGzCH,WAAAA;AAAAA,EAAAA,CACR,EACAI,KAAK,EAAE;AACZ;ACjBA,MAAMC,0BAAoD;AAAA,EACxDC,UAAU,CAAE;AAAA,EACZC,cAAcC,KAAKC,GAAG;AAAA,EACtBC,eAAeF,KAAKC,GAAG;AAAA,EACvBE,cAAcH,KAAKC,GAAG;AACxB;AAEMG,MAAAA,iCAAiCA,CACrCC,IACAC,kBACiB;AACjB,QAAMC,eAAe;AAAA,IAAE,GAAGV;AAAAA,IAAyB,GAAGS;AAAAA,EAAc;AAE9DE,QAAAA,aAAaA,CAACrD,aAClBsD,+BAAA,cAAC,oBAAoB,UAApB,EAA6B,OAAOF,aAAAA,GAAepD,QAAS;AAGxDuD,SAAAA,OAAOF,WAAWH,EAAE,CAAC;AAC9B;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/testing/DatePickerEvent/DatePickerEvent.ts","../../src/testing/DatePickerEvent/DateRangePickerEvent.ts","../../src/testing/DragDropFileEvent/DragDropFileEvent.ts","../../src/testing/SelectEvent/SelectEvent.ts","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts","../../src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx"],"sourcesContent":["import { act, queries, fireEvent, waitFor } from '@testing-library/react'\n// find the date picker container from its input field 🤷\nfunction getContainerFromInput(input: HTMLElement): HTMLElement {\n return input.parentNode!.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function expand(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is rendered, then the select is already expanded\n if (queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(input)\n\n await waitFor(() => {\n expect(queries.getByRole(datePickerContainer, 'menu')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is not rendered, then the select is already collapsed\n if (!queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(queries.getByText(datePickerContainer, 'Close'))\n\n await waitFor(() => {\n expect(queries.queryByRole(datePickerContainer, 'menu')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programmatically expand the `DatePicker` calendar before picking the date.\n * @param day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function pick(day: string, input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n act(() => {\n input.focus()\n })\n\n const dayElement = queries.getByLabelText(datePickerContainer, day)\n\n if (dayElement.getAttribute('aria-checked') == 'false') {\n fireEvent.click(dayElement)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function clear(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n const clearButton = queries.getByLabelText(datePickerContainer, 'Clear selection')\n\n fireEvent.click(clearButton)\n\n await collapse(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n const selectedDays: HTMLElement[] = queries.queryAllByRole(datePickerContainer, 'checkbox', {\n checked: true,\n })\n\n await collapse(input)\n\n return selectedDays\n}\n\nconst datePickerEvent = {\n getContainer: getContainerFromInput,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default datePickerEvent\n","import { queries } from '@testing-library/react'\n\nimport DatePickerEvent from './DatePickerEvent'\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await DatePickerEvent.expand(input)\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n await DatePickerEvent.collapse(input)\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programmatically expand the `DatePicker` calendar before picking the date.\n * @param day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function pick(range: [string | null, string | null], input: HTMLElement): Promise<void> {\n const dateRangePickerContainer = DatePickerEvent.getContainer(input)\n\n await expand(input)\n\n const [rangeStart, rangeEnd] = range\n\n if (rangeStart != null) {\n const dateRangeStartInput = queries.getByTestId(\n dateRangePickerContainer,\n 'input-date-range-start'\n )\n\n await DatePickerEvent.pick(rangeStart, dateRangeStartInput)\n }\n\n if (rangeEnd != null) {\n const dateRangeEndInput = queries.getByTestId(dateRangePickerContainer, 'input-date-range-end')\n\n await DatePickerEvent.pick(rangeEnd, dateRangeEndInput)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await DatePickerEvent.clear(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param input - You can refer to this element by the label you applied to the `DatePicker`\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n return DatePickerEvent.getSelectedDates(input)\n}\n\nexport const dateRangePickerEvent = {\n getContainer: DatePickerEvent.getContainer,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default dateRangePickerEvent\n","import { createEvent, fireEvent } from '@testing-library/react'\n\nimport toArray from 'utils/toolset/toArray'\n\n/**\n * Get the input dropzone, which is the input parent (label).\n * @param input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst getDropZoneFromInput = (input: HTMLInputElement): HTMLLabelElement =>\n input.parentNode as HTMLLabelElement\n\n/**\n * Simulates the onDragOver event on the drop zone.\n * @param input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragOver = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragOverEvent = createEvent.dragOver(dropzone)\n\n fireEvent(dropzone, dragOverEvent)\n}\n\n/**\n * Simulates the onDragLeave event on the drop zone.\n * @param input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragLeave = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragLeaveEvent = createEvent.dragLeave(dropzone)\n\n fireEvent(dropzone, dragLeaveEvent)\n}\n\n/**\n * Simulates the onDrop event on the drop zone. You can provide a list of files or a single file.\n * @param input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dropFiles = (input: HTMLInputElement, files: File | File[]) => {\n const dropzone = getDropZoneFromInput(input)\n\n const fileDropEvent = createEvent.drop(dropzone)\n\n Object.defineProperty(fileDropEvent, 'dataTransfer', { value: { files: toArray(files) } })\n\n fireEvent(dropzone, fileDropEvent)\n}\n\nexport const DragDropFileEvent = {\n dragOver,\n dragLeave,\n dropFiles,\n}\n\nexport default DragDropFileEvent\n","import { act, waitFor, within, waitForElementToBeRemoved, fireEvent } from '@testing-library/react'\n\n// based on https://github.com/romgain/react-select-event/blob/master/src/index.ts\n\n// find the select container from its input field 🤷\nfunction getSelectContainer(input: HTMLElement): HTMLElement {\n return input.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Please, make sure to call expand before trying to get the menu container\n */\nfunction getSelectMenu(input: HTMLElement): HTMLElement {\n return input.parentNode!.parentNode!.nextSibling as HTMLElement\n}\n\nfunction getSelectTriggerHandle(input: HTMLElement): HTMLElement {\n return input.parentNode!.nextSibling!.nextSibling as HTMLElement\n}\n\nfunction getSelectSearchContainer(input: HTMLElement): HTMLElement {\n return input.parentNode as HTMLElement\n}\n\nfunction isSelectMenuExpanded(input: HTMLElement): boolean {\n const selectContainer = getSelectContainer(input)\n\n /**\n * Once the select is expanded, we have the following structure:\n * +-------------+\n * | Close button (visually hidden)\n * +-------------+\n * | DropdownTrigger\n * +-------------+\n * | Popover\n * +-------------+\n *\n * This, if the container has 3 children, we assume the menu is expanded\n */\n return selectContainer.children.length === 3\n}\n\n/**\n * This is needed because some datasources might be asynchronous.\n * To ensure that the data they retrieve will be available, we wait for the\n * querying phase to finish.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function waitForPendingQuery(input: HTMLElement) {\n const searchContainer = getSelectSearchContainer(input)\n\n if (!within(searchContainer).queryByTestId('select-trigger-loading')) {\n return\n }\n\n await waitForElementToBeRemoved(\n () => within(searchContainer).queryByTestId('select-trigger-loading'),\n { timeout: 2500 }\n )\n}\n\n/**\n * Expand the `Select` menu, if it not already expanded.\n * input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n if (isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n await waitFor(() => {\n expect(triggerHandle).toBeEnabled()\n })\n\n /**\n * Using act and a manually dispatched event so we can account for the\n * state changes that happen when the search input is clicked.\n * This is mainly related to the `handleEvent` from the `useClickOutside` hook.\n */\n act(() => {\n input.dispatchEvent(new MouseEvent('click', { bubbles: true }))\n })\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).getByRole('listbox')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `Select` menu, if it not already collapsed.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n if (!isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n fireEvent.click(triggerHandle)\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).queryByRole('listbox')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Select the provided option(s), if they are present in the menu.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param option - Label for the option to be selected.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function select(option: string | RegExp, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // click the option if exists; Select currently closes when an item is clicked.\n if (optionElement.getAttribute('aria-selected') == 'false') {\n /**\n * This is a replacement for the `userEvent.click`.\n * We are adopting this approach to remove the peer dep to @testing-library/user-event for\n * applications using this helper, so they are not tied to the same user-event as this library.\n * It follows the same sequence of event stated in the documentation available at:\n * https://testing-library.com/docs/guide-events/#interactions-vs-events\n */\n fireEvent.mouseDown(optionElement)\n\n act(() => {\n optionElement.focus()\n })\n\n fireEvent.mouseUp(optionElement)\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Unselect the provided option(s), if they are present in the menu AND are selected.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param option - Label for the option to be unselected.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function unselect(option: string, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // ensures that the option exists and IS selected\n if (optionElement.getAttribute('aria-selected') === 'true') {\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n const searchContainer = getSelectSearchContainer(input)\n\n const clearButton = within(searchContainer).getByTestId('select-trigger-clear')\n\n fireEvent.click(clearButton)\n}\n\n/**\n * Perform search based on the given `query`. It will fail if the option is not found.\n * @param query - Search term.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function search(query: string, input: HTMLElement): Promise<void> {\n fireEvent.change(input, {\n target: { value: query },\n })\n\n await waitForPendingQuery(input)\n\n const menuContainer = getSelectMenu(input)\n\n await within(menuContainer).findAllByRole('option')\n}\n\n/**\n * Get options elements currently available in the `Select` menu.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function getOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const options = within(menuContainer).queryAllByRole('option')\n\n await collapse(input)\n\n return options\n}\n\n/**\n * Get options elements currently selected in the `Select` menu.\n * @param input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function getSelectedOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n let selectedOptions: HTMLElement[] = []\n\n try {\n selectedOptions = await within(menuContainer).findAllByRole('option', {\n selected: true,\n })\n } catch {\n selectedOptions = []\n }\n\n await collapse(input)\n\n return selectedOptions\n}\n\nexport const selectEvent = {\n select,\n unselect,\n clear,\n search,\n expand,\n collapse,\n getOptions,\n getSelectedOptions,\n isMenuExpanded: isSelectMenuExpanded,\n}\n\nexport default selectEvent\n","import type { Interpolation, ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\n\nimport { Alice } from '../../theming/themes'\nimport type { CustomTheme } from '../../theming'\nimport toArray from 'utils/toolset/toArray'\n\ntype ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>\n\n/**\n * Use this function to simulate the CSS that would be generated by styled-components\n * @param styles - A `css` reference with interpolated styles\n * @returns The final CSS\n */\nexport default function getInterpolatedStyles(styles: ThemedInterpolation): string {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- used only in tests\n return toArray(styles)\n .map((interpolation) => {\n while (isFunction(interpolation)) {\n interpolation = interpolation({ theme: Alice })\n }\n\n return interpolation\n })\n .join('')\n}\n","import type { ReactNode } from 'react'\nimport React from 'react'\nimport { render } from '@testing-library/react'\nimport type { RenderResult } from '@testing-library/react'\n\nimport type { DragDropFileContextValue } from '../../components/DragDropFile/types'\nimport { DragDropFileContext } from '../../components/DragDropFile/DragDropFile.context'\n\nconst defaultContextValueMock: DragDropFileContextValue = {\n fileList: [],\n onFilesAdded: jest.fn(),\n onRetryUpload: jest.fn(),\n onRemoveFile: jest.fn(),\n}\n\nconst renderWithDragDropFileProvider = (\n ui: ReactNode,\n customContext?: Partial<DragDropFileContextValue>\n): RenderResult => {\n const contextValue = { ...defaultContextValueMock, ...customContext }\n\n const renderedUi = (children: ReactNode) => (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n\n return render(renderedUi(ui))\n}\n\nexport default renderWithDragDropFileProvider\n"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","fireEvent","click","waitFor","expect","getByRole","toBeInTheDocument","collapse","getByText","not","pick","day","act","focus","dayElement","getByLabelText","getAttribute","clear","clearButton","getSelectedDates","selectedDays","queryAllByRole","checked","datePickerEvent","getContainer","DatePickerEvent","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","dateRangePickerEvent","getDropZoneFromInput","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","Object","defineProperty","value","toArray","DragDropFileEvent","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","selectContainer","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","waitForElementToBeRemoved","timeout","triggerHandle","toBeEnabled","dispatchEvent","MouseEvent","bubbles","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","selectEvent","isMenuExpanded","getInterpolatedStyles","styles","map","interpolation","isFunction","theme","Alice","join","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","renderWithDragDropFileProvider","ui","customContext","contextValue","renderedUi","React","render"],"mappings":";;;;;;AAEA,SAASA,sBAAsBC,OAAiC;AAC9D,SAAOA,MAAMC,WAAYA,WAAYA,WAAYA;AACnD;AAMA,eAAeC,SAAOF,OAAmC;AACvD,QAAMG,sBAAsBJ,sBAAsBC,KAAK;AAGvD,MAAII,QAAQC,YAAYF,qBAAqB,MAAM,GAAG;AACpD;AAAA,EACF;AAEAG,YAAUC,MAAMP,KAAK;AAErB,QAAMQ,QAAQ,MAAM;AAClBC,WAAOL,QAAQM,UAAUP,qBAAqB,MAAM,CAAC,EAAEQ,kBAAAA;AAAAA,EACzD,CAAC;AACH;AAMA,eAAeC,WAASZ,OAAmC;AACzD,QAAMG,sBAAsBJ,sBAAsBC,KAAK;AAGvD,MAAI,CAACI,QAAQC,YAAYF,qBAAqB,MAAM,GAAG;AACrD;AAAA,EACF;AAEAG,YAAUC,MAAMH,QAAQS,UAAUV,qBAAqB,OAAO,CAAC;AAE/D,QAAMK,QAAQ,MAAM;AAClBC,WAAOL,QAAQC,YAAYF,qBAAqB,MAAM,CAAC,EAAEW,IAAIH,kBAAAA;AAAAA,EAC/D,CAAC;AACH;AAQA,eAAeI,OAAKC,KAAahB,OAAmC;AAClE,QAAMG,sBAAsBJ,sBAAsBC,KAAK;AAEvD,QAAME,SAAOF,KAAK;AAElBiB,MAAI,MAAM;AACRjB,UAAMkB,MAAAA;AAAAA,EACR,CAAC;AAED,QAAMC,aAAaf,QAAQgB,eAAejB,qBAAqBa,GAAG;AAElE,MAAIG,WAAWE,aAAa,cAAc,KAAK,SAAS;AACtDf,cAAUC,MAAMY,UAAU;AAAA,EAC5B;AAEA,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AApB,EAA6B,OAAOF,aAAAA,GAAenD,QAAS;AAG/D,SAAOsD,OAAOF,WAAWH,EAAE,CAAC;AAC9B;"}
|
|
@@ -18,8 +18,8 @@ interface DataGenerator {
|
|
|
18
18
|
amount: number;
|
|
19
19
|
allowRepeat?: boolean;
|
|
20
20
|
}) => T | Array<T>;
|
|
21
|
-
pickone<T>(arr: T[])
|
|
22
|
-
pickset<T>(arr: T[], count?: number)
|
|
21
|
+
pickone: <T>(arr: T[]) => T;
|
|
22
|
+
pickset: <T>(arr: T[], count?: number) => T[];
|
|
23
23
|
profession: () => string;
|
|
24
24
|
sentence: (opts?: Chance.Options) => string;
|
|
25
25
|
state: (opts?: Chance.Options) => string;
|
package/dist/tests/renderer.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RenderOptions, fireEvent, within, waitFor, waitForElementToBeRemoved, act, screen, queries } from '@testing-library/react';
|
|
2
2
|
import { default as userEvent } from '@testing-library/user-event';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
3
4
|
declare class Renderer {
|
|
4
|
-
result:
|
|
5
|
-
constructor(children:
|
|
5
|
+
result: ReactNode;
|
|
6
|
+
constructor(children: ReactNode);
|
|
6
7
|
render(options?: Omit<RenderOptions, 'queries'>): import('@testing-library/react').RenderResult<typeof queries, HTMLElement, HTMLElement>;
|
|
7
8
|
}
|
|
8
|
-
export default function customRenderer(children:
|
|
9
|
+
export default function customRenderer(children: ReactNode): Renderer;
|
|
9
10
|
export { act, fireEvent as fire, queries, screen, userEvent as user, waitFor, waitForElementToBeRemoved, within, };
|
package/dist/theming/index.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ export type ThemedProps = ThemeProps<CustomTheme>;
|
|
|
7
7
|
type TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken);
|
|
8
8
|
/**
|
|
9
9
|
* Return a design token value for the current theme.
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @returns
|
|
10
|
+
* @param token - Token whose value should be returned.
|
|
11
|
+
* @param props - Component props.
|
|
12
|
+
* @returns Token value or `undefined` if the token was not found for the current theme.
|
|
13
13
|
*/
|
|
14
14
|
export declare function getToken<TProps extends ThemedProps>(token: TokenLike<TProps>): (props: TProps) => ThemeTokenValue;
|
|
15
15
|
export declare function getToken<TProps extends ThemedProps>(token: TokenLike<TProps>, props: TProps): ThemeTokenValue;
|
package/dist/theming/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isFunction } from "@loadsmart/utils-function";
|
|
2
|
-
import { a as alice, l as loadsmart, m as mirandaCompatibility } from "../miranda-compatibility.theme-
|
|
2
|
+
import { a as alice, l as loadsmart, m as mirandaCompatibility } from "../miranda-compatibility.theme-CIu9fa89.js";
|
|
3
3
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
4
|
__proto__: null,
|
|
5
5
|
Alice: alice,
|
|
@@ -12,7 +12,7 @@ function getTokenFromTheme(token, props) {
|
|
|
12
12
|
}
|
|
13
13
|
function getToken(token, props) {
|
|
14
14
|
if (props === void 0) {
|
|
15
|
-
return (
|
|
15
|
+
return (themeProps) => getTokenFromTheme(token, themeProps);
|
|
16
16
|
}
|
|
17
17
|
return getTokenFromTheme(token, props);
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/theming/index.ts"],"sourcesContent":["import { isFunction } from '@loadsmart/utils-function'\n\nimport type { ThemeProps } from 'styled-components'\nimport type ThemeAlice from './themes/alice.theme'\n\nexport type ThemeToken = keyof typeof ThemeAlice\nexport type ThemeTokenValue = string | number\n\nexport type CustomTheme = Record<ThemeToken, ThemeTokenValue>\nexport type ThemedProps = ThemeProps<CustomTheme>\n\ntype TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken)\n\nfunction getTokenFromTheme<P extends ThemedProps>(token: TokenLike<P>, props: P): ThemeTokenValue {\n const tokenName = isFunction(token) ? token(props) : token\n return props.theme[tokenName]\n}\n\n/**\n * Return a design token value for the current theme.\n * @param
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/theming/index.ts"],"sourcesContent":["import { isFunction } from '@loadsmart/utils-function'\n\nimport type { ThemeProps } from 'styled-components'\nimport type ThemeAlice from './themes/alice.theme'\n\nexport type ThemeToken = keyof typeof ThemeAlice\nexport type ThemeTokenValue = string | number\n\nexport type CustomTheme = Record<ThemeToken, ThemeTokenValue>\nexport type ThemedProps = ThemeProps<CustomTheme>\n\ntype TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken)\n\nfunction getTokenFromTheme<P extends ThemedProps>(token: TokenLike<P>, props: P): ThemeTokenValue {\n const tokenName = isFunction(token) ? token(props) : token\n return props.theme[tokenName]\n}\n\n/**\n * Return a design token value for the current theme.\n * @param token - Token whose value should be returned.\n * @param props - Component props.\n * @returns Token value or `undefined` if the token was not found for the current theme.\n */\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>\n): (props: TProps) => ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>,\n props: TProps\n): ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(token: any, props?: any): any {\n if (props === undefined) {\n return (themeProps: TProps) => getTokenFromTheme(token, themeProps)\n }\n\n return getTokenFromTheme(token, props)\n}\n\nexport * as Themes from './themes'\n"],"names":["getTokenFromTheme","token","props","tokenName","isFunction","theme","getToken","undefined","themeProps"],"mappings":";;;;;;;;AAaA,SAASA,kBAAyCC,OAAqBC,OAA2B;AAChG,QAAMC,YAAYC,WAAWH,KAAK,IAAIA,MAAMC,KAAK,IAAID;AACrD,SAAOC,MAAMG,MAAMF,SAAS;AAC9B;AAiBO,SAASG,SAAqCL,OAAYC,OAAkB;AACjF,MAAIA,UAAUK,QAAW;AACvB,WAAO,CAACC,eAAuBR,kBAAkBC,OAAOO,UAAU;AAAA,EACpE;AAEA,SAAOR,kBAAkBC,OAAOC,KAAK;AACvC;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type VariableValue = string | number;
|
|
2
|
-
|
|
2
|
+
interface VariableMap {
|
|
3
3
|
[key: string]: VariableValue;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
export declare function generateColorGetter(colors: VariableMap): (name: string, opacity?: number) => VariableValue;
|
|
6
6
|
export declare function generateSpacingGetter(spacings: VariableMap): (name: string) => VariableValue;
|
|
7
7
|
export declare function generateShadowGetter(shadows: VariableMap): (name: string) => VariableValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toArray-BJJzFRD1.js","sources":["../src/utils/toolset/toArray.ts"],"sourcesContent":["/**\n * Produces array for non-array value.\n * @param value - Value to be converted/returned.\n * @return Returns `value` itself if it is an array or\n * an array containing the provided `value`.\n */\nconst toArray = <T>(value: T | T[] | readonly T[] | undefined | null): T[] => {\n if (value == null) {\n return []\n }\n\n if (Array.isArray(value)) {\n return value\n }\n\n return [value as T]\n}\n\nexport default toArray\n"],"names":["toArray","value","Array","isArray"],"mappings":"AAMA,MAAMA,UAAU,CAAIC,UAA0D;AAC5E,MAAIA,SAAS,MAAM;AACjB,WAAO,CAAA;AAAA,EACT;AAEA,MAAIC,MAAMC,QAAQF,KAAK,GAAG;AACxB,WAAOA;AAAAA,EACT;AAEA,SAAO,CAACA,KAAU;AACpB;"}
|