@loadsmart/loadsmart-ui 8.0.1 → 8.0.3

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 (193) hide show
  1. package/dist/common/SelectionWrapper.d.ts +1 -1
  2. package/dist/components/Banner/Banner.d.ts +3 -3
  3. package/dist/components/Button/Button.d.ts +3 -2
  4. package/dist/components/Calendar/Calendar.helpers.d.ts +2 -1
  5. package/dist/components/Calendar/Pickers/DayPicker.d.ts +2 -1
  6. package/dist/components/Calendar/Pickers/PickerButton.d.ts +2 -3
  7. package/dist/components/Card/CardTitle.d.ts +2 -1
  8. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  9. package/dist/components/DatePicker/DatePicker.d.ts +4 -4
  10. package/dist/components/DatePicker/DateRangePicker.d.ts +1 -1
  11. package/dist/components/DatePicker/useDatePicker.d.ts +7 -586
  12. package/dist/components/DatePicker/useDateRangePicker.d.ts +5 -889
  13. package/dist/components/Dialog/Dialog.d.ts +1 -3
  14. package/dist/components/DragDropFile/DragDropFile.d.ts +4 -3
  15. package/dist/components/DragDropFile/styles.d.ts +9 -8
  16. package/dist/components/Dropdown/Dropdown.context.d.ts +2 -1
  17. package/dist/components/Dropdown/Dropdown.types.d.ts +1 -1
  18. package/dist/components/Dropdown/DropdownMenu.d.ts +2 -1
  19. package/dist/components/Dropdown/DropdownTrigger.d.ts +1 -1
  20. package/dist/components/EmptyState/EmptyState.d.ts +2 -2
  21. package/dist/components/Icon/Icon.d.ts +3 -2
  22. package/dist/components/Label/Label.d.ts +1 -1
  23. package/dist/components/Layout/Stack.d.ts +2 -1
  24. package/dist/components/Loaders/LoadingBar.d.ts +2 -1
  25. package/dist/components/Loaders/LoadingDots.d.ts +1 -1
  26. package/dist/components/Modal/Modal.d.ts +1 -4
  27. package/dist/components/Radio/Radio.d.ts +1 -1
  28. package/dist/components/Select/Select.context.d.ts +3 -2
  29. package/dist/components/Select/Select.d.ts +1 -1
  30. package/dist/components/Select/SelectTrigger.d.ts +1 -1
  31. package/dist/components/SideNavigation/Logo/Logo.d.ts +2 -1
  32. package/dist/components/SideNavigation/Menu/Menu.d.ts +4 -2
  33. package/dist/components/SideNavigation/Menu/MenuLink.d.ts +2 -1
  34. package/dist/components/SideNavigation/SideNavigation.d.ts +1 -2
  35. package/dist/components/Steps/Steps.d.ts +1 -1
  36. package/dist/components/Steps/StepsStep.d.ts +2 -1
  37. package/dist/components/Switch/Switch.d.ts +5 -2
  38. package/dist/components/Table/Selection.d.ts +1 -1
  39. package/dist/components/TablePagination/TablePagination.styles.d.ts +2 -4
  40. package/dist/components/TablePagination/TablePaginationActions.d.ts +2 -7
  41. package/dist/components/Tabs/Tabs.types.d.ts +1 -1
  42. package/dist/components/Tabs/TabsContext.d.ts +2 -1
  43. package/dist/components/Text/Text.d.ts +10 -8
  44. package/dist/components/TextField/TextField.d.ts +4 -3
  45. package/dist/components/Textarea/Textarea.d.ts +1 -1
  46. package/dist/components/ToggleGroup/Toggle.d.ts +2 -1
  47. package/dist/components/ToggleGroup/ToggleGroup.types.d.ts +1 -1
  48. package/dist/components/ToggleGroup/ToggleGroupContext.d.ts +2 -2
  49. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  50. package/dist/components/TopNavigation/Logo/Logo.d.ts +2 -1
  51. package/dist/components/TopNavigation/Menu/MenuItemDropdown.d.ts +4 -4
  52. package/dist/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.d.ts +2 -1
  53. package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +2 -1
  54. package/dist/index.js +135 -128
  55. package/dist/index.js.map +1 -1
  56. package/dist/prop-Fs2axl9W.js.map +1 -1
  57. package/dist/styles/typography.d.ts +2 -1
  58. package/dist/testing/getInterpolatedStyles/getInterpolatedStyles.d.ts +4 -2
  59. package/dist/testing/index.js.map +1 -1
  60. package/dist/tests/renderer.d.ts +2 -2
  61. package/dist/theming/index.d.ts +3 -2
  62. package/dist/theming/index.js.map +1 -1
  63. package/dist/utils/types/ColorScheme.d.ts +1 -2
  64. package/package.json +27 -26
  65. package/dist/components/Accordion/Accordion.stories.d.ts +0 -9
  66. package/dist/components/Accordion/Accordion.test.d.ts +0 -1
  67. package/dist/components/Banner/Banner.stories.d.ts +0 -107
  68. package/dist/components/Banner/Banner.test.d.ts +0 -1
  69. package/dist/components/Breadcrumbs/Breadbrumbs.test.d.ts +0 -1
  70. package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +0 -5
  71. package/dist/components/Button/Button.stories.d.ts +0 -33
  72. package/dist/components/Button/Button.test.d.ts +0 -1
  73. package/dist/components/Calendar/Calendar.stories.d.ts +0 -22
  74. package/dist/components/Calendar/Calendar.test.d.ts +0 -1
  75. package/dist/components/Calendar/Date.helper.test.d.ts +0 -1
  76. package/dist/components/Calendar/DateFormat.helper.test.d.ts +0 -1
  77. package/dist/components/Calendar/Month.helper.test.d.ts +0 -1
  78. package/dist/components/Calendar/Pickers/DayPicker.test.d.ts +0 -1
  79. package/dist/components/Calendar/Pickers/MonthPicker.test.d.ts +0 -1
  80. package/dist/components/Calendar/Pickers/YearPicker.test.d.ts +0 -1
  81. package/dist/components/Card/Card.stories.d.ts +0 -8
  82. package/dist/components/Card/Card.test.d.ts +0 -1
  83. package/dist/components/Checkbox/Checkbox.stories.d.ts +0 -9
  84. package/dist/components/Checkbox/Checkbox.test.d.ts +0 -1
  85. package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -23
  86. package/dist/components/DatePicker/DatePicker.test.d.ts +0 -1
  87. package/dist/components/DatePicker/DateRangePicker.stories.d.ts +0 -22
  88. package/dist/components/DatePicker/DateRangePicker.test.d.ts +0 -1
  89. package/dist/components/Dialog/Dialog.stories.d.ts +0 -68
  90. package/dist/components/Dialog/Dialog.test.d.ts +0 -1
  91. package/dist/components/DragDropFile/DragDropFile.stories.d.ts +0 -34
  92. package/dist/components/DragDropFile/components/DropZone.test.d.ts +0 -1
  93. package/dist/components/DragDropFile/components/FileList.test.d.ts +0 -1
  94. package/dist/components/Drawer/Drawer.stories.d.ts +0 -6
  95. package/dist/components/Drawer/Drawer.test.d.ts +0 -1
  96. package/dist/components/Dropdown/Dropdown.stories.d.ts +0 -12
  97. package/dist/components/Dropdown/Dropdown.test.d.ts +0 -1
  98. package/dist/components/Dropdown/useDropdown.test.d.ts +0 -1
  99. package/dist/components/EmptyState/EmptyState.stories.d.ts +0 -33
  100. package/dist/components/EmptyState/EmptyState.test.d.ts +0 -1
  101. package/dist/components/ErrorMessage/ErrorMessage.stories.d.ts +0 -14
  102. package/dist/components/ErrorMessage/ErrorMessage.test.d.ts +0 -1
  103. package/dist/components/HighlightMatch/HighlightMatch.stories.d.ts +0 -5
  104. package/dist/components/HighlightMatch/HighlightMatch.test.d.ts +0 -1
  105. package/dist/components/IconFactory/IconFactory.stories.d.ts +0 -6
  106. package/dist/components/IconFactory/IconFactory.test.d.ts +0 -1
  107. package/dist/components/Label/Label.stories.d.ts +0 -15
  108. package/dist/components/Label/Label.test.d.ts +0 -1
  109. package/dist/components/Layout/Layout.stories.d.ts +0 -147
  110. package/dist/components/Link/Link.stories.d.ts +0 -6
  111. package/dist/components/Link/Link.test.d.ts +0 -1
  112. package/dist/components/Loaders/LoadingBar.stories.d.ts +0 -5
  113. package/dist/components/Loaders/LoadingBar.test.d.ts +0 -1
  114. package/dist/components/Loaders/LoadingDots.stories.d.ts +0 -6
  115. package/dist/components/Loaders/LoadingDots.test.d.ts +0 -1
  116. package/dist/components/Loaders/Spinner.stories.d.ts +0 -5
  117. package/dist/components/Loaders/Spinner.test.d.ts +0 -1
  118. package/dist/components/Modal/Modal.stories.d.ts +0 -31
  119. package/dist/components/Modal/Modal.test.d.ts +0 -1
  120. package/dist/components/Pagination/Pagination.stories.d.ts +0 -5
  121. package/dist/components/Pagination/Pagination.test.d.ts +0 -1
  122. package/dist/components/Pagination/usePagination.test.d.ts +0 -1
  123. package/dist/components/Popover/Popover.stories.d.ts +0 -5
  124. package/dist/components/Popover/Popover.test.d.ts +0 -1
  125. package/dist/components/ProgressBar/ProgressBar.stories.d.ts +0 -13
  126. package/dist/components/ProgressBar/ProgressBar.test.d.ts +0 -1
  127. package/dist/components/Radio/Radio.stories.d.ts +0 -9
  128. package/dist/components/Radio/Radio.test.d.ts +0 -1
  129. package/dist/components/Section/Section.test.d.ts +0 -1
  130. package/dist/components/Section/Sections.stories.d.ts +0 -6
  131. package/dist/components/Select/Select.stories.d.ts +0 -19
  132. package/dist/components/Select/Select.test.d.ts +0 -1
  133. package/dist/components/Select/SelectEmpty.test.d.ts +0 -1
  134. package/dist/components/Select/SelectOption.test.d.ts +0 -1
  135. package/dist/components/Select/useSelect.helpers.test.d.ts +0 -1
  136. package/dist/components/Select/useSelect.test.d.ts +0 -1
  137. package/dist/components/SideNavigation/Logo/Logo.test.d.ts +0 -1
  138. package/dist/components/SideNavigation/Menu/Menu.test.d.ts +0 -1
  139. package/dist/components/SideNavigation/Separator/Separator.test.d.ts +0 -1
  140. package/dist/components/SideNavigation/SideNavigation.stories.d.ts +0 -6
  141. package/dist/components/SideNavigation/SideNavigation.test.d.ts +0 -1
  142. package/dist/components/Steps/Steps.stories.d.ts +0 -5
  143. package/dist/components/Steps/Steps.test.d.ts +0 -1
  144. package/dist/components/Steps/useStep.test.d.ts +0 -1
  145. package/dist/components/Switch/Switch.stories.d.ts +0 -5
  146. package/dist/components/Switch/Switch.test.d.ts +0 -1
  147. package/dist/components/Table/Table.stories.d.ts +0 -62
  148. package/dist/components/Table/Table.test.d.ts +0 -1
  149. package/dist/components/Table/useSortBy.test.d.ts +0 -1
  150. package/dist/components/TablePagination/TablePagination.stories.d.ts +0 -5
  151. package/dist/components/TablePagination/TablePagination.test.d.ts +0 -1
  152. package/dist/components/Tabs/Tabs.stories.d.ts +0 -24
  153. package/dist/components/Tabs/Tabs.test.d.ts +0 -1
  154. package/dist/components/Tag/Tag.stories.d.ts +0 -63
  155. package/dist/components/Tag/Tag.test.d.ts +0 -1
  156. package/dist/components/Text/Text.stories.d.ts +0 -7
  157. package/dist/components/Text/Text.test.d.ts +0 -1
  158. package/dist/components/TextField/TextField.stories.d.ts +0 -12
  159. package/dist/components/TextField/TextField.test.d.ts +0 -1
  160. package/dist/components/Textarea/Textarea.stories.d.ts +0 -12
  161. package/dist/components/Textarea/Textarea.test.d.ts +0 -1
  162. package/dist/components/Toast/Toast.stories.d.ts +0 -13
  163. package/dist/components/Toast/Toast.test.d.ts +0 -1
  164. package/dist/components/ToggleGroup/Toggle.test.d.ts +0 -1
  165. package/dist/components/ToggleGroup/ToggleGroup.stories.d.ts +0 -6
  166. package/dist/components/ToggleGroup/ToggleGroup.test.d.ts +0 -1
  167. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -14
  168. package/dist/components/Tooltip/Tooltip.test.d.ts +0 -1
  169. package/dist/components/TopNavigation/Logo/Logo.test.d.ts +0 -1
  170. package/dist/components/TopNavigation/Menu/Menu.test.d.ts +0 -1
  171. package/dist/components/TopNavigation/TopNavigation.stories.d.ts +0 -6
  172. package/dist/components/VisuallyHidden/VisuallyHidden.stories.d.ts +0 -12
  173. package/dist/components/VisuallyHidden/VisuallyHidden.test.d.ts +0 -1
  174. package/dist/hooks/useClickOutside/useClickOutside.test.d.ts +0 -1
  175. package/dist/hooks/useDidMount/useDidMount.test.d.ts +0 -1
  176. package/dist/hooks/useFingerprint/useFingerprint.test.d.ts +0 -1
  177. package/dist/hooks/useFocusTrap/useFocusTrap.stories.d.ts +0 -7
  178. package/dist/hooks/useFocusTrap/useFocusTrap.test.d.ts +0 -1
  179. package/dist/hooks/useFocusWithin/useFocusWithin.test.d.ts +0 -1
  180. package/dist/hooks/useHeightExpansionToggler/useHeightExpansionToggler.test.d.ts +0 -1
  181. package/dist/hooks/useSelectable/SelectableStrategy.test.d.ts +0 -1
  182. package/dist/hooks/useSelectable/useSelectable.test.d.ts +0 -1
  183. package/dist/styles/font.test.d.ts +0 -1
  184. package/dist/styles/typography.test.d.ts +0 -1
  185. package/dist/testing/SelectEvent/SelectEvent.test.d.ts +0 -1
  186. package/dist/tools/conditional.test.d.ts +0 -1
  187. package/dist/tools/prop.test.d.ts +0 -1
  188. package/dist/utils/toolset/formatBytes.test.d.ts +0 -1
  189. package/dist/utils/toolset/getID.test.d.ts +0 -1
  190. package/dist/utils/toolset/getOrdinalSuffix.test.d.ts +0 -1
  191. package/dist/utils/toolset/highlightMatch.test.d.ts +0 -1
  192. package/dist/utils/toolset/interleave.test.d.ts +0 -1
  193. package/dist/utils/toolset/styledCompounds.d.ts +0 -12
@@ -1 +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,SAAS;AAElC,QAAMc,MAAMb,KAAKc,OAAiB,CAACC,KAAKZ,QAAQ;AAC9C,QAAIa,QAAQjB,UAAUI,GAAG;AAEzB,QAAIO,WAAWM,KAAK,GAAG;AACrBA,cAAQA,MAAMrB,KAAK;AAAA,IACrB;AAEA,QAAIqB,OAAO;AACT,YAAMC,WAAWd;AAEjB,YAAMe,SAAUC,SAASF,UAAUtB,KAA+B,KAAKQ;AACvE,aAAO,CAAC,GAAGY,KAAKG,MAAM;AAAA,IACxB;AAEA,WAAOH;AAAAA,EACT,GAAG,CAAA,CAAE;AAEL,SAAOF,IAAIO,KAAK,GAAG;AACrB;AAkBA,SAASC,eAAkB3B,YAA4B;AACrD,SAAO,SAAUC,OAAkB;AACjC,QAAI2B,UAAoB,CAAA;AAExB,aAASC,IAAI,GAAGA,IAAI7B,WAAW8B,QAAQD,KAAK;AAC1C,YAAMxB,YAAYL,WAAW6B,CAAC;AAE9B,UAAIb,WAAWX,SAAS,GAAG;AACzBuB,gBAAQG,KAAK1B,UAAUJ,KAAK,CAAC;AAAA,MAC/B,WAAW+B,SAAS3B,SAAS,GAAG;AAC9BuB,kBAAUA,QAAQK,OAAOf,sBAAyBb,WAAWJ,KAAK,CAAC;AAAA,MACrE,WAAWI,WAAW;AACpBuB,gBAAQG,KAAKG,OAAO7B,SAAS,CAAC;AAAA,MAChC;AAAA,IACF;AAEA,WAAOuB,QAAQF,KAAK,GAAG;AAAA,EACzB;AACF;ACnHA,SAASS,WAAWC,MAAsB;AACxC,QAAM,CAACd,OAAOe,YAAY,IAAID;AAE9B,MAAId,SAAS,QAAQA,UAAU,SAASgB,OAAOC,MAAMjB,KAAK,GAAG;AAC3D,WAAOe,gBAAgBf;AAAAA,EACzB;AAEA,MAAI,OAAOA,UAAU,YAAYA,MAAMQ,WAAW,GAAG;AACnD,WAAOO,gBAAgBf;AAAAA,EACzB;AAEA,SAAOA;AACT;AAcA,SAASkB,KACPC,MACAJ,cACAK,eAAeP,SACf;AACA,SAAO,CAAClC,UAAmByC,aAAazC,MAAMwC,IAAI,GAAGJ,YAAY;AACnE;"}
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(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,UAAM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AAW+B,SAAS3B,SAAS,GAAG;AAC9BuB,kBAAUA,QAAQK,OAAOf,sBAAsBb,WAAWJ,KAAK,CAAC;AAAA,MAClE,WAAWI,WAAW;AACpBuB,gBAAQG,KAAKG,OAAO7B,SAAS,CAAC;AAAA,MAChC;AAAA,IACF;AAEA,WAAOuB,QAAQF,KAAK,GAAG;AAAA,EACzB;AACF;ACnHA,SAASS,WAAWC,MAAsB;AACxC,QAAM,CAACd,OAAOe,YAAY,IAAID;AAE9B,MAAId,SAAS,QAAQA,UAAU,SAASgB,OAAOC,MAAMjB,KAAK,GAAG;AAC3D,WAAOe,gBAAgBf;AAAAA,EACzB;AAEA,MAAI,OAAOA,UAAU,YAAYA,MAAMQ,WAAW,GAAG;AACnD,WAAOO,gBAAgBf;AAAAA,EACzB;AAEA,SAAOA;AACT;AAcA,SAASkB,KACPC,MACAJ,cACAK,eAAeP,SACf;AACA,SAAO,CAAClC,UAAmByC,aAAazC,MAAMwC,IAAI,GAAGJ,YAAY;AACnE;"}
@@ -1,4 +1,5 @@
1
1
  import { ThemeToken } from '../theming';
2
+ import { FlattenInterpolation, ThemeProps } from 'styled-components';
2
3
  export interface TypographyOptions {
3
4
  italic?: boolean;
4
5
  color?: ThemeToken;
@@ -19,5 +20,5 @@ export declare const typographyProperties: TypographyProperties;
19
20
  * @param variant Name of the variant
20
21
  * @param options Add boldness, italics and color
21
22
  */
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));
23
+ declare function typography<P>(variant?: TypographyVariants | ((props: P) => string), options?: TypographyOptions): FlattenInterpolation<ThemeProps<any>> | ((props: P) => FlattenInterpolation<ThemeProps<any>> | ((props: unknown) => FlattenInterpolation<ThemeProps<any>> | /*elided*/ any));
23
24
  export default typography;
@@ -1,6 +1,8 @@
1
- import { Interpolation, ThemeProps } from 'styled-components';
1
+ import { Interpolation } from 'styled-components';
2
2
  import { CustomTheme } from '../../theming';
3
- type ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>;
3
+ type ThemedInterpolation = Interpolation<{
4
+ theme: CustomTheme;
5
+ }>;
4
6
  /**
5
7
  * Use this function to simulate the CSS that would be generated by styled-components
6
8
  * @param styles - A `css` reference with interpolated styles
@@ -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":["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,WAAY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OW,aAAa,EAAEU,cAAc,UAAU;AAAA,MACpEK,UAAU;AAAA,IAAA,CACX;AAAA,EACH,QAAQ;AACND,sBAAkB,CAAA;AAAA,EACpB;AAEA,QAAM/E,SAASZ,KAAK;AAEpB,SAAO2F;AACT;AAEO,MAAME,cAAc;AAAA,EACzBlB;AAAAA,EACAO;AAAAA,EACA5D;AAAAA,EACA6D;AAAAA,EACAjF;AAAAA,EACAU;AAAAA,EACA4E;AAAAA,EACAE;AAAAA,EACAI,gBAAgBlC;AAClB;AC1OA,SAAwBmC,sBAAsBC,QAAqC;AAEjF,SAAO3C,QAAQ2C,MAAM,EAClBC,IAAKC,CAAAA,kBAAkB;AACtB,WAAOC,WAAWD,aAAa,GAAG;AAChCA,sBAAgBA,cAAc;AAAA,QAAEE,OAAOC;AAAAA,MAAAA,CAAO;AAAA,IAChD;AAEA,WAAOH;AAAAA,EACT,CAAC,EACAI,KAAK,EAAE;AACZ;ACjBA,MAAMC,0BAAoD;AAAA,EACxDC,UAAU,CAAA;AAAA,EACVC,cAAcC,KAAKC,GAAAA;AAAAA,EACnBC,eAAeF,KAAKC,GAAAA;AAAAA,EACpBE,cAAcH,KAAKC,GAAAA;AACrB;AAEA,MAAMG,iCAAiCA,CACrCC,IACAC,kBACiB;AACjB,QAAMC,eAAe;AAAA,IAAE,GAAGV;AAAAA,IAAyB,GAAGS;AAAAA,EAAAA;AAEtD,QAAME,aAAaA,CAACpD,aAClBqD,+BAAA,cAAC,oBAAoB,UAApB,EAA6B,OAAOF,aAAAA,GAAenD,QAAS;AAG/D,SAAOsD,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 } 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<{ theme: 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,E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BAAoD;AAAA,EACxDC,UAAU,CAAA;AAAA,EACVC,cAAcC,KAAKC,GAAAA;AAAAA,EACnBC,eAAeF,KAAKC,GAAAA;AAAAA,EACpBE,cAAcH,KAAKC,GAAAA;AACrB;AAEA,MAAMG,iCAAiCA,CACrCC,IACAC,kBACiB;AACjB,QAAMC,eAAe;AAAA,IAAE,GAAGV;AAAAA,IAAyB,GAAGS;AAAAA,EAAAA;AAEtD,QAAME,aAAaA,CAACpD,aAClBqD,+BAAA,cAAC,oBAAoB,UAApB,EAA6B,OAAOF,aAAAA,GAAenD,QAAS;AAG/D,SAAOsD,OAAOF,WAAWH,EAAE,CAAC;AAC9B;"}
@@ -1,10 +1,10 @@
1
- import { RenderOptions, fireEvent, within, waitFor, waitForElementToBeRemoved, act, screen, queries } from '@testing-library/react';
1
+ import { RenderOptions, fireEvent, within, waitFor, waitForElementToBeRemoved, act, screen, queries, RenderResult } from '@testing-library/react';
2
2
  import { default as userEvent } from '@testing-library/user-event';
3
3
  import { ReactNode } from 'react';
4
4
  declare class Renderer {
5
5
  result: ReactNode;
6
6
  constructor(children: ReactNode);
7
- render(options?: Omit<RenderOptions, 'queries'>): import('@testing-library/react').RenderResult<typeof queries, HTMLElement, HTMLElement>;
7
+ render(options?: Omit<RenderOptions, 'queries'>): RenderResult<typeof queries, HTMLElement, HTMLElement>;
8
8
  }
9
9
  export default function customRenderer(children: ReactNode): Renderer;
10
10
  export { act, fireEvent as fire, queries, screen, userEvent as user, waitFor, waitForElementToBeRemoved, within, };
@@ -1,9 +1,10 @@
1
- import { ThemeProps } from 'styled-components';
2
1
  import { default as ThemeAlice } from './themes/alice.theme';
3
2
  export type ThemeToken = keyof typeof ThemeAlice;
4
3
  export type ThemeTokenValue = string | number;
5
4
  export type CustomTheme = Record<ThemeToken, ThemeTokenValue>;
6
- export type ThemedProps = ThemeProps<CustomTheme>;
5
+ export interface ThemedProps {
6
+ theme: CustomTheme;
7
+ }
7
8
  type TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken);
8
9
  /**
9
10
  * Return a design token value for the current theme.
@@ -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 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
+ {"version":3,"file":"index.js","sources":["../../src/theming/index.ts"],"sourcesContent":["import { isFunction } from '@loadsmart/utils-function'\n\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 interface ThemedProps {\n theme: CustomTheme\n}\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":";;;;;;;;AAcA,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,2 +1 @@
1
- type ColorScheme = 'dark' | 'light';
2
- export default ColorScheme;
1
+ export type ColorScheme = 'dark' | 'light';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loadsmart/loadsmart-ui",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Miranda UI, a React UI library",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "postpack": "pinst --enable",
28
28
  "format": "prettier . --write",
29
29
  "check:format:ci": "prettier . --check",
30
- "check:type": "tsc",
30
+ "check:type": "tsc -b",
31
31
  "check:type:ci": "yarn check:type"
32
32
  },
33
33
  "storybook-deployer": {
@@ -37,53 +37,54 @@
37
37
  "addFileAttribute": "true"
38
38
  },
39
39
  "devDependencies": {
40
- "@commitlint/cli": "^20.4.3",
41
- "@commitlint/config-conventional": "^20.4.3",
42
- "@loadsmart/miranda-tokens": "^4.25.2",
43
- "@storybook/addon-a11y": "^8.6.12",
44
- "@storybook/addon-docs": "^8.6.12",
45
- "@storybook/addon-essentials": "^8.6.12",
46
- "@storybook/addon-links": "^8.6.12",
47
- "@storybook/react": "^8.6.12",
48
- "@storybook/react-vite": "^8.6.12",
49
- "@storybook/theming": "^8.6.12",
50
- "@swc/core": "^1.15.18",
40
+ "@commitlint/cli": "^20.5.0",
41
+ "@commitlint/config-conventional": "^20.5.0",
42
+ "@loadsmart/miranda-tokens": "^4.25.7",
43
+ "@rolldown/plugin-babel": "^0.2.2",
44
+ "@storybook/addon-a11y": "^8.6.18",
45
+ "@storybook/addon-docs": "^8.6.18",
46
+ "@storybook/addon-essentials": "^8.6.18",
47
+ "@storybook/addon-links": "^8.6.18",
48
+ "@storybook/react": "^8.6.18",
49
+ "@storybook/react-vite": "^8.6.18",
50
+ "@storybook/theming": "^8.6.18",
51
+ "@swc/core": "^1.15.21",
51
52
  "@swc/jest": "^0.2.39",
52
- "@tailwindcss/vite": "^4.2.1",
53
+ "@tailwindcss/vite": "^4.2.2",
53
54
  "@testing-library/dom": "^10.4.1",
54
55
  "@testing-library/jest-dom": "^6.9.1",
55
56
  "@testing-library/react": "^16.3.2",
56
- "@testing-library/react-hooks": "^8.0.1",
57
57
  "@testing-library/user-event": "^13.5.0",
58
58
  "@types/chance": "^1.1.7",
59
- "@types/jest": "^29.5.14",
60
- "@types/node": "^22.19.15",
59
+ "@types/jest": "^30.0.0",
60
+ "@types/node": "^24.12.0",
61
61
  "@types/react": "^18.3.28",
62
62
  "@types/react-dom": "^18.3.7",
63
63
  "@types/styled-components": "^5.1.36",
64
- "@vitejs/plugin-react": "^5.1.4",
64
+ "@vitejs/plugin-react": "^5.2.0",
65
65
  "babel-plugin-styled-components": "^2.1.4",
66
66
  "chance": "^1.1.13",
67
67
  "commitizen": "^4.3.1",
68
68
  "cz-conventional-changelog": "^3.3.0",
69
69
  "eslint": "^9.39.4",
70
70
  "eslint-config-prettier": "^10.1.8",
71
+ "eslint-plugin-jest": "^29.15.1",
71
72
  "eslint-plugin-jest-dom": "^5.5.0",
72
73
  "eslint-plugin-jsx-a11y": "^6.10.2",
73
74
  "eslint-plugin-prettier": "^5.5.5",
74
75
  "eslint-plugin-promise": "^7.2.1",
75
76
  "eslint-plugin-react": "^7.37.5",
76
77
  "eslint-plugin-react-hooks": "^7.0.1",
77
- "eslint-plugin-testing-library": "^7.16.0",
78
+ "eslint-plugin-testing-library": "^7.16.2",
78
79
  "eslint-plugin-unicorn": "^63.0.0",
79
80
  "gh-pages": "^6.3.0",
80
81
  "husky": "^9.1.7",
81
- "jest": "^29.7.0",
82
- "jest-environment-jsdom": "^29.7.0",
82
+ "jest": "^30.3.0",
83
+ "jest-environment-jsdom": "^30.3.0",
83
84
  "jest-junit": "^16.0.0",
84
85
  "jest-transformer-svg": "^2.1.0",
85
- "lint-staged": "^16.3.2",
86
- "nanoid": "^5.1.6",
86
+ "lint-staged": "^16.4.0",
87
+ "nanoid": "^5.1.7",
87
88
  "pinst": "^3.0.0",
88
89
  "prettier": "^3.8.1",
89
90
  "react": "^18.3.1",
@@ -93,10 +94,10 @@
93
94
  "semantic-release": "^25.0.3",
94
95
  "storybook": "^8.6.18",
95
96
  "styled-components": "^5.3.11",
96
- "tailwindcss": "^4.2.1",
97
+ "tailwindcss": "^4.2.2",
97
98
  "ts-toolbelt": "^9.6.0",
98
- "typescript": "^5.9.3",
99
- "typescript-eslint": "^8.57.0",
99
+ "typescript": "^6.0.2",
100
+ "typescript-eslint": "^8.57.2",
100
101
  "vite": "^7.3.1",
101
102
  "vite-plugin-dts": "^4.5.4",
102
103
  "vite-plugin-svgr": "^4.5.0"
@@ -1,9 +0,0 @@
1
- import { default as React } from 'react';
2
- import { AccordionProps } from './Accordion';
3
- import { Meta } from '@storybook/react';
4
- declare const _default: Meta;
5
- export default _default;
6
- export declare function Playground(args: AccordionProps): React.JSX.Element;
7
- export declare function CustomIndicators(): React.JSX.Element;
8
- export declare function ControlledOpened(args: AccordionProps): React.JSX.Element;
9
- export declare function ControlledBasedOnExpandedProp(args: AccordionProps): React.JSX.Element;
@@ -1 +0,0 @@
1
- export {};
@@ -1,107 +0,0 @@
1
- import { default as React } from 'react';
2
- import { Meta } from '@storybook/react';
3
- import { BannerProps, BannerActionProps } from './Banner';
4
- declare const _default: Meta;
5
- export default _default;
6
- export declare function Playground(args: BannerProps): React.JSX.Element;
7
- export declare namespace Playground {
8
- var args: {
9
- scale: string;
10
- variant: string;
11
- title: string;
12
- };
13
- }
14
- export declare function Warning(args: BannerProps): React.JSX.Element;
15
- export declare namespace Warning {
16
- var args: {
17
- scale: string;
18
- variant: string;
19
- title: string;
20
- };
21
- }
22
- export declare function Danger(args: BannerProps): React.JSX.Element;
23
- export declare namespace Danger {
24
- var args: {
25
- scale: string;
26
- variant: string;
27
- title: string;
28
- };
29
- }
30
- export declare function Neutral(args: BannerProps): React.JSX.Element;
31
- export declare namespace Neutral {
32
- var args: {
33
- scale: string;
34
- variant: string;
35
- title: string;
36
- };
37
- }
38
- export declare function CustomIcon(args: BannerProps): React.JSX.Element;
39
- export declare namespace CustomIcon {
40
- var args: {
41
- scale: string;
42
- variant: string;
43
- title: string;
44
- icon: React.JSX.Element;
45
- };
46
- }
47
- export declare function Large(args: BannerProps): React.JSX.Element;
48
- export declare namespace Large {
49
- var args: {
50
- scale: string;
51
- variant: string;
52
- title: string;
53
- description: string;
54
- };
55
- }
56
- export declare function Action(args: BannerActionProps): React.JSX.Element;
57
- export declare namespace Action {
58
- var args: {
59
- scale: string;
60
- variant: string;
61
- title: string;
62
- action: string;
63
- };
64
- }
65
- export declare function ActionWithSecondaryAction(args: BannerActionProps): React.JSX.Element;
66
- export declare namespace ActionWithSecondaryAction {
67
- var args: {
68
- scale: string;
69
- variant: string;
70
- title: string;
71
- action: string;
72
- secondaryAction: string;
73
- };
74
- }
75
- export declare function ActionLarge(args: BannerActionProps): React.JSX.Element;
76
- export declare namespace ActionLarge {
77
- var args: {
78
- scale: string;
79
- variant: string;
80
- title: string;
81
- description: string;
82
- action: string;
83
- };
84
- }
85
- export declare function ActionLargeWithSecondaryAction(args: BannerActionProps): React.JSX.Element;
86
- export declare namespace ActionLargeWithSecondaryAction {
87
- var args: {
88
- scale: string;
89
- variant: string;
90
- title: string;
91
- description: string;
92
- action: string;
93
- secondaryAction: string;
94
- };
95
- }
96
- export declare function ActionLargeDismissibleWithSecondaryAction(args: BannerActionProps): React.JSX.Element;
97
- export declare namespace ActionLargeDismissibleWithSecondaryAction {
98
- var args: {
99
- scale: string;
100
- variant: string;
101
- title: string;
102
- description: string;
103
- action: string;
104
- secondaryAction: string;
105
- dismissible: boolean;
106
- };
107
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { BreadcrumbsProps } from './Breadcrumbs';
2
- import { Meta } from '@storybook/react';
3
- declare const _default: Meta;
4
- export default _default;
5
- export declare const Playground: import('@storybook/core/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, BreadcrumbsProps>;
@@ -1,33 +0,0 @@
1
- import { default as React } from 'react';
2
- import { Meta } from '@storybook/react';
3
- import { BackButtonProps } from '../../common/BackButton';
4
- import { ButtonProps } from './Button';
5
- import { CloseButtonProps } from '../../common/CloseButton';
6
- declare const _default: Meta;
7
- export default _default;
8
- export declare function Playground(args: ButtonProps): React.JSX.Element;
9
- export declare namespace Playground {
10
- var args: {
11
- scale: string;
12
- variant: string;
13
- leading: React.JSX.Element;
14
- trailing: React.JSX.Element;
15
- };
16
- }
17
- export declare function Base(args: ButtonProps): React.JSX.Element;
18
- export declare function Selector(args: ButtonProps): React.JSX.Element;
19
- export declare namespace Selector {
20
- var args: {
21
- scale: string;
22
- variant: string;
23
- };
24
- }
25
- export declare function Icon(args: ButtonProps): React.JSX.Element;
26
- export declare namespace Icon {
27
- var args: {
28
- scale: string;
29
- };
30
- }
31
- export declare function Back(args: BackButtonProps): React.JSX.Element;
32
- export declare function Close(args: CloseButtonProps): React.JSX.Element;
33
- export declare function Loading(args: ButtonProps): React.JSX.Element;
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import { default as React } from 'react';
2
- import { Meta } from '@storybook/react';
3
- import { CalendarDate } from './Date.helper';
4
- import { CalendarProps } from './Calendar.types';
5
- declare const _default: Meta;
6
- export default _default;
7
- export declare const Playground: import('@storybook/core/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, CalendarProps>;
8
- export declare function Selection(): React.JSX.Element;
9
- declare function isWeekend(date: CalendarDate): boolean;
10
- export declare function CalendarConstraints(args: CalendarProps): React.JSX.Element;
11
- export declare namespace CalendarConstraints {
12
- var args: {
13
- constraints: ((string | null)[] | typeof isWeekend)[];
14
- };
15
- var parameters: {
16
- docs: {
17
- description: {
18
- story: string;
19
- };
20
- };
21
- };
22
- }
@@ -1 +0,0 @@
1
- export declare const formatter: import('./DateFormat.helper').DateFormat;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { StoryFn, Meta } from '@storybook/react';
2
- import { CardProps } from './Card';
3
- declare const _default: Meta;
4
- export default _default;
5
- export declare const Playground: StoryFn<CardProps>;
6
- export declare const Default: StoryFn<CardProps>;
7
- export declare const TitleOnly: StoryFn<CardProps>;
8
- export declare const Flagged: StoryFn<CardProps>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { default as React } from 'react';
2
- import { CheckboxProps } from './Checkbox';
3
- import { Meta } from '@storybook/react';
4
- declare const _default: Meta;
5
- export default _default;
6
- export declare function Playground(args: CheckboxProps): React.JSX.Element;
7
- export declare namespace Playground {
8
- var args: {};
9
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { default as React } from 'react';
2
- import { StoryFn, Meta } from '@storybook/react';
3
- import { DatePickerProps } from './DatePicker.types';
4
- declare const _default: Meta;
5
- export default _default;
6
- export declare const Playground: StoryFn<DatePickerProps>;
7
- export declare const WithValue: StoryFn<DatePickerProps>;
8
- export declare function DatePickerConstraints(args: DatePickerProps): React.JSX.Element;
9
- export declare namespace DatePickerConstraints {
10
- var args: {
11
- id: string;
12
- name: string;
13
- constraints: (string | null)[][];
14
- value: string;
15
- };
16
- var parameters: {
17
- docs: {
18
- description: {
19
- story: string;
20
- };
21
- };
22
- };
23
- }
@@ -1 +0,0 @@
1
- export {};