@yamada-ui/react 2.1.8-dev-20260408054356 → 2.1.8-dev-20260408063728

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 (258) hide show
  1. package/dist/cjs/components/motion/transition.cjs +2 -2
  2. package/dist/cjs/components/motion/transition.cjs.map +1 -1
  3. package/dist/cjs/core/components/create-component.cjs.map +1 -1
  4. package/dist/cjs/core/components/props.cjs +1 -0
  5. package/dist/cjs/core/components/props.cjs.map +1 -1
  6. package/dist/esm/components/motion/transition.js +2 -2
  7. package/dist/esm/components/motion/transition.js.map +1 -1
  8. package/dist/esm/core/components/create-component.js.map +1 -1
  9. package/dist/esm/core/components/props.js +1 -0
  10. package/dist/esm/core/components/props.js.map +1 -1
  11. package/dist/types/components/accordion/accordion.d.ts +2 -4
  12. package/dist/types/components/accordion/accordion.style.d.ts +1 -1
  13. package/dist/types/components/accordion/use-accordion.d.ts +11 -11
  14. package/dist/types/components/airy/airy.d.ts +2 -3
  15. package/dist/types/components/alert/alert.d.ts +2 -5
  16. package/dist/types/components/alert/alert.style.d.ts +1 -1
  17. package/dist/types/components/alpha-slider/alpha-slider.d.ts +2 -3
  18. package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +2 -2
  19. package/dist/types/components/autocomplete/autocomplete.d.ts +2 -4
  20. package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
  21. package/dist/types/components/autocomplete/use-autocomplete.d.ts +5 -7
  22. package/dist/types/components/avatar/avatar.d.ts +5 -5
  23. package/dist/types/components/avatar/use-avatar-group.d.ts +2 -2
  24. package/dist/types/components/badge/badge.d.ts +2 -2
  25. package/dist/types/components/bleed/bleed.d.ts +2 -2
  26. package/dist/types/components/blockquote/blockquote.d.ts +2 -2
  27. package/dist/types/components/breadcrumb/breadcrumb.d.ts +2 -2
  28. package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
  29. package/dist/types/components/breadcrumb/use-breadcrumb.d.ts +2 -2
  30. package/dist/types/components/button/button-group.d.ts +0 -1
  31. package/dist/types/components/button/button.d.ts +2 -3
  32. package/dist/types/components/button/icon-button.d.ts +2 -2
  33. package/dist/types/components/calendar/calendar.d.ts +2 -3
  34. package/dist/types/components/calendar/calendar.style.d.ts +2 -2
  35. package/dist/types/components/calendar/use-calendar.d.ts +8 -9
  36. package/dist/types/components/card/card.d.ts +2 -2
  37. package/dist/types/components/carousel/carousel.d.ts +2 -3
  38. package/dist/types/components/carousel/carousel.style.d.ts +2 -2
  39. package/dist/types/components/carousel/use-carousel.d.ts +3 -3
  40. package/dist/types/components/center/center.d.ts +2 -2
  41. package/dist/types/components/chart/area-chart.d.ts +2 -2
  42. package/dist/types/components/chart/bar-chart.d.ts +2 -2
  43. package/dist/types/components/chart/chart.d.ts +5 -5
  44. package/dist/types/components/chart/composed-chart.d.ts +2 -2
  45. package/dist/types/components/chart/donut-chart.d.ts +2 -2
  46. package/dist/types/components/chart/line-chart.d.ts +2 -2
  47. package/dist/types/components/chart/radar-chart.d.ts +2 -2
  48. package/dist/types/components/chart/use-chart.d.ts +2 -2
  49. package/dist/types/components/checkbox/checkbox-group.d.ts +0 -2
  50. package/dist/types/components/checkbox/checkbox.d.ts +4 -5
  51. package/dist/types/components/checkbox/use-checkbox-group.d.ts +2 -3
  52. package/dist/types/components/checkbox/use-checkbox.d.ts +0 -1
  53. package/dist/types/components/checkbox-card/checkbox-card-group.d.ts +0 -3
  54. package/dist/types/components/checkbox-card/checkbox-card.d.ts +4 -6
  55. package/dist/types/components/circle-progress/circle-progress.d.ts +2 -3
  56. package/dist/types/components/close-button/close-button.d.ts +2 -3
  57. package/dist/types/components/code/code.d.ts +2 -2
  58. package/dist/types/components/collapse/collapse.d.ts +2 -3
  59. package/dist/types/components/color-picker/color-picker.d.ts +2 -6
  60. package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
  61. package/dist/types/components/color-picker/use-color-picker.d.ts +2 -5
  62. package/dist/types/components/color-selector/color-selector.d.ts +2 -6
  63. package/dist/types/components/color-selector/use-color-selector.d.ts +3 -5
  64. package/dist/types/components/color-swatch/color-swatch.d.ts +2 -2
  65. package/dist/types/components/container/container.d.ts +2 -2
  66. package/dist/types/components/data-list/data-list.d.ts +2 -2
  67. package/dist/types/components/data-list/data-list.style.d.ts +1 -1
  68. package/dist/types/components/date-picker/date-picker.d.ts +2 -5
  69. package/dist/types/components/date-picker/date-picker.style.d.ts +1 -1
  70. package/dist/types/components/date-picker/use-date-picker.d.ts +4 -7
  71. package/dist/types/components/drawer/drawer.d.ts +2 -5
  72. package/dist/types/components/drawer/use-drawer.d.ts +0 -2
  73. package/dist/types/components/dropzone/dropzone.d.ts +5 -8
  74. package/dist/types/components/dropzone/dropzone.style.d.ts +1 -1
  75. package/dist/types/components/dropzone/use-dropzone.d.ts +0 -1
  76. package/dist/types/components/editable/editable.d.ts +4 -5
  77. package/dist/types/components/editable/use-editable.d.ts +2 -3
  78. package/dist/types/components/em/em.d.ts +2 -2
  79. package/dist/types/components/empty-state/empty-state.d.ts +2 -2
  80. package/dist/types/components/fade/fade.d.ts +2 -3
  81. package/dist/types/components/fade-scale/fade-scale.d.ts +0 -1
  82. package/dist/types/components/field/field.d.ts +3 -3
  83. package/dist/types/components/field/use-field-props.d.ts +8 -8
  84. package/dist/types/components/fieldset/fieldset.d.ts +3 -4
  85. package/dist/types/components/file-button/file-button.d.ts +2 -4
  86. package/dist/types/components/file-button/use-file-button.d.ts +18 -20
  87. package/dist/types/components/file-input/file-input.d.ts +2 -4
  88. package/dist/types/components/file-input/use-file-input.d.ts +17 -18
  89. package/dist/types/components/flex/flex.d.ts +2 -2
  90. package/dist/types/components/flip/flip.d.ts +4 -5
  91. package/dist/types/components/flip/flip.style.d.ts +1 -1
  92. package/dist/types/components/float/float.d.ts +2 -2
  93. package/dist/types/components/form/form.d.ts +3 -4
  94. package/dist/types/components/format/format-byte.d.ts +4 -4
  95. package/dist/types/components/format/format-date-time.d.ts +4 -4
  96. package/dist/types/components/format/format-number.d.ts +2 -2
  97. package/dist/types/components/format/use-format-byte.d.ts +0 -1
  98. package/dist/types/components/format/use-format-date-time.d.ts +0 -1
  99. package/dist/types/components/format/use-format-number.d.ts +0 -1
  100. package/dist/types/components/grid/grid-item.d.ts +2 -2
  101. package/dist/types/components/grid/grid.d.ts +2 -2
  102. package/dist/types/components/group/group.d.ts +2 -3
  103. package/dist/types/components/group/use-group.d.ts +2 -2
  104. package/dist/types/components/heading/heading.d.ts +2 -2
  105. package/dist/types/components/highlight/highlight.d.ts +0 -2
  106. package/dist/types/components/hue-slider/hue-slider.d.ts +3 -4
  107. package/dist/types/components/icon/icon.d.ts +5 -5
  108. package/dist/types/components/image/image.d.ts +2 -2
  109. package/dist/types/components/indicator/indicator.d.ts +4 -5
  110. package/dist/types/components/infinite-scroll-area/infinite-scroll-area.d.ts +2 -2
  111. package/dist/types/components/input/input-addon.d.ts +2 -2
  112. package/dist/types/components/input/input-element.d.ts +2 -2
  113. package/dist/types/components/input/input-group.d.ts +0 -2
  114. package/dist/types/components/input/input.d.ts +2 -3
  115. package/dist/types/components/kbd/kbd.d.ts +2 -2
  116. package/dist/types/components/link/link.d.ts +2 -2
  117. package/dist/types/components/link-box/link-box.d.ts +2 -2
  118. package/dist/types/components/list/list.d.ts +2 -2
  119. package/dist/types/components/list/list.style.d.ts +2 -2
  120. package/dist/types/components/loading/loading-provider.d.ts +2 -2
  121. package/dist/types/components/loading/loading.d.ts +3 -4
  122. package/dist/types/components/loading/use-loading-component.d.ts +0 -1
  123. package/dist/types/components/mark/mark.d.ts +2 -2
  124. package/dist/types/components/menu/menu.d.ts +2 -3
  125. package/dist/types/components/menu/menu.style.d.ts +2 -2
  126. package/dist/types/components/menu/use-menu.d.ts +11 -11
  127. package/dist/types/components/modal/modal.d.ts +2 -6
  128. package/dist/types/components/native-accordion/native-accordion.d.ts +2 -2
  129. package/dist/types/components/native-accordion/native-accordion.style.d.ts +2 -2
  130. package/dist/types/components/native-accordion/use-native-accordion.d.ts +2 -2
  131. package/dist/types/components/native-popover/native-popover.d.ts +2 -2
  132. package/dist/types/components/native-select/native-select.d.ts +2 -4
  133. package/dist/types/components/native-select/use-native-select.d.ts +0 -1
  134. package/dist/types/components/native-table/native-table.d.ts +4 -4
  135. package/dist/types/components/notice/notice.style.d.ts +1 -1
  136. package/dist/types/components/notice/use-notice.d.ts +0 -3
  137. package/dist/types/components/number-input/number-input.d.ts +2 -3
  138. package/dist/types/components/number-input/number-input.style.d.ts +1 -1
  139. package/dist/types/components/number-input/use-number-input.d.ts +0 -1
  140. package/dist/types/components/pagination/pagination.d.ts +2 -3
  141. package/dist/types/components/pagination/pagination.style.d.ts +1 -1
  142. package/dist/types/components/pagination/use-pagination.d.ts +2 -2
  143. package/dist/types/components/password-input/password-input.d.ts +2 -3
  144. package/dist/types/components/password-input/strength-meter.d.ts +2 -2
  145. package/dist/types/components/password-input/use-password-input.d.ts +2 -3
  146. package/dist/types/components/picture/picture.d.ts +0 -1
  147. package/dist/types/components/pin-input/pin-input.d.ts +2 -4
  148. package/dist/types/components/pin-input/use-pin-input.d.ts +7 -8
  149. package/dist/types/components/popover/popover.d.ts +2 -3
  150. package/dist/types/components/progress/progress.d.ts +4 -4
  151. package/dist/types/components/progress/use-progress.d.ts +706 -706
  152. package/dist/types/components/qr-code/qr-code.d.ts +2 -2
  153. package/dist/types/components/radio/radio-group.d.ts +0 -2
  154. package/dist/types/components/radio/radio.d.ts +4 -5
  155. package/dist/types/components/radio/use-radio-group.d.ts +2 -3
  156. package/dist/types/components/radio/use-radio.d.ts +0 -1
  157. package/dist/types/components/radio-card/radio-card-group.d.ts +0 -3
  158. package/dist/types/components/radio-card/radio-card.d.ts +4 -6
  159. package/dist/types/components/rating/rating.style.d.ts +2 -2
  160. package/dist/types/components/rating/use-rating.d.ts +11 -12
  161. package/dist/types/components/reorder/reorder.d.ts +2 -3
  162. package/dist/types/components/reorder/reorder.style.d.ts +1 -1
  163. package/dist/types/components/reorder/use-reorder.d.ts +4 -4
  164. package/dist/types/components/resizable/resizable.d.ts +2 -2
  165. package/dist/types/components/resizable/resizable.style.d.ts +2 -2
  166. package/dist/types/components/resizable/use-resizable.d.ts +2 -2
  167. package/dist/types/components/ripple/ripple.d.ts +2 -3
  168. package/dist/types/components/ripple/use-ripple.d.ts +2 -2
  169. package/dist/types/components/rotate/rotate.d.ts +2 -3
  170. package/dist/types/components/saturation-slider/saturation-slider.d.ts +2 -2
  171. package/dist/types/components/saturation-slider/use-saturation-slider.d.ts +2 -3
  172. package/dist/types/components/scroll-area/scroll-area.d.ts +2 -2
  173. package/dist/types/components/segmented-control/segmented-control.d.ts +2 -3
  174. package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
  175. package/dist/types/components/segmented-control/use-segmented-control.d.ts +9 -10
  176. package/dist/types/components/select/select.d.ts +2 -4
  177. package/dist/types/components/select/select.style.d.ts +1 -1
  178. package/dist/types/components/select/use-select.d.ts +4 -6
  179. package/dist/types/components/separator/separator.d.ts +2 -2
  180. package/dist/types/components/simple-grid/simple-grid.d.ts +2 -3
  181. package/dist/types/components/skeleton/skeleton.d.ts +2 -2
  182. package/dist/types/components/slide/slide.d.ts +2 -3
  183. package/dist/types/components/slide-fade/slide-fade.d.ts +2 -3
  184. package/dist/types/components/slider/slider.d.ts +2 -2
  185. package/dist/types/components/slider/use-slider.d.ts +2 -3
  186. package/dist/types/components/snacks/snacks.d.ts +0 -2
  187. package/dist/types/components/snacks/use-snacks.d.ts +0 -1
  188. package/dist/types/components/stack/h-stack.d.ts +2 -2
  189. package/dist/types/components/stack/stack.d.ts +2 -2
  190. package/dist/types/components/stack/v-stack.d.ts +2 -2
  191. package/dist/types/components/stack/z-stack.d.ts +2 -2
  192. package/dist/types/components/stat/stat.d.ts +2 -2
  193. package/dist/types/components/stat/stat.style.d.ts +2 -2
  194. package/dist/types/components/status/status.d.ts +2 -2
  195. package/dist/types/components/steps/steps.d.ts +2 -2
  196. package/dist/types/components/steps/steps.style.d.ts +1 -1
  197. package/dist/types/components/steps/use-steps.d.ts +10 -10
  198. package/dist/types/components/switch/switch.d.ts +2 -2
  199. package/dist/types/components/switch/use-switch.d.ts +0 -1
  200. package/dist/types/components/table/table.d.ts +2 -4
  201. package/dist/types/components/tabs/tabs.d.ts +2 -2
  202. package/dist/types/components/tabs/tabs.style.d.ts +1 -1
  203. package/dist/types/components/tabs/use-tabs.d.ts +16 -16
  204. package/dist/types/components/tag/tag.d.ts +2 -2
  205. package/dist/types/components/tag/tag.style.d.ts +1 -1
  206. package/dist/types/components/text/text.d.ts +2 -2
  207. package/dist/types/components/textarea/textarea.d.ts +2 -4
  208. package/dist/types/components/textarea/use-autosize.d.ts +2 -2
  209. package/dist/types/components/timeline/timeline.d.ts +5 -5
  210. package/dist/types/components/timeline/timeline.style.d.ts +2 -2
  211. package/dist/types/components/tip/tip.d.ts +0 -2
  212. package/dist/types/components/toggle/toggle-group.d.ts +1 -1
  213. package/dist/types/components/toggle/toggle.d.ts +5 -7
  214. package/dist/types/components/toggle/use-toggle-group.d.ts +2 -2
  215. package/dist/types/components/toggle/use-toggle.d.ts +2 -3
  216. package/dist/types/components/tooltip/tooltip.d.ts +2 -4
  217. package/dist/types/components/visually-hidden/visually-hidden.d.ts +2 -2
  218. package/dist/types/components/wrap/wrap.d.ts +2 -3
  219. package/dist/types/core/components/create-component.d.ts +11 -9
  220. package/dist/types/core/components/index.types.d.ts +1 -0
  221. package/dist/types/core/components/props.d.ts +6 -10
  222. package/dist/types/core/components/use-component-style.d.ts +2 -0
  223. package/dist/types/core/components/utils.d.ts +1 -0
  224. package/dist/types/core/constant.d.ts +1 -0
  225. package/dist/types/core/css/calc.d.ts +1 -0
  226. package/dist/types/core/css/config.d.ts +1 -0
  227. package/dist/types/core/css/css.d.ts +1 -0
  228. package/dist/types/core/css/index.types.d.ts +1 -0
  229. package/dist/types/core/css/styles.d.ts +1 -0
  230. package/dist/types/core/css/token.d.ts +1 -0
  231. package/dist/types/core/css/use-css.d.ts +1 -0
  232. package/dist/types/core/css/utils.d.ts +2 -0
  233. package/dist/types/core/generated-theme-tokens.types.d.ts +1 -0
  234. package/dist/types/core/index.d.ts +2 -0
  235. package/dist/types/core/system/color-mode-provider.d.ts +2 -2
  236. package/dist/types/core/system/config.d.ts +1 -0
  237. package/dist/types/core/system/create-system.d.ts +1 -0
  238. package/dist/types/core/system/factory.d.ts +1 -0
  239. package/dist/types/core/system/index.types.d.ts +1 -0
  240. package/dist/types/core/system/storage-script.d.ts +3 -3
  241. package/dist/types/core/system/styled.d.ts +3 -2
  242. package/dist/types/core/system/system-provider.d.ts +2 -2
  243. package/dist/types/core/system/var.d.ts +2 -0
  244. package/dist/types/hooks/use-async-callback/index.d.ts +0 -1
  245. package/dist/types/hooks/use-breakpoint/use-breakpoint-state.d.ts +2 -2
  246. package/dist/types/hooks/use-clickable/index.d.ts +9 -9
  247. package/dist/types/hooks/use-clipboard/index.d.ts +2 -2
  248. package/dist/types/hooks/use-combobox/index.d.ts +12 -13
  249. package/dist/types/hooks/use-counter/index.d.ts +2 -2
  250. package/dist/types/hooks/use-descendants/index.d.ts +2 -2
  251. package/dist/types/hooks/use-field-sizing/index.d.ts +2 -2
  252. package/dist/types/hooks/use-hover/index.d.ts +2 -2
  253. package/dist/types/hooks/use-popper/index.d.ts +2 -2
  254. package/dist/types/index.d.ts +0 -103
  255. package/dist/types/providers/i18n-provider/i18n-provider.d.ts +3 -3
  256. package/dist/types/providers/ui-provider/ui-provider.d.ts +2 -3
  257. package/dist/types/utils/children.d.ts +2 -2
  258. package/package.json +1 -1
@@ -14,7 +14,7 @@ const createTransition = {
14
14
  1
15
15
  ]
16
16
  },
17
- ...duration ? { duration: (0, require_utils_index.utils_exports.isNumber)(duration) ? duration : duration.enter } : {},
17
+ ...!(0, require_utils_index.utils_exports.isUndefined)(duration) ? { duration: (0, require_utils_index.utils_exports.isNumber)(duration) ? duration : duration.enter } : {},
18
18
  delay: (0, require_utils_index.utils_exports.isNumber)(delay) ? delay : delay?.enter
19
19
  };
20
20
  };
@@ -31,7 +31,7 @@ const createTransition = {
31
31
  1
32
32
  ]
33
33
  },
34
- ...duration ? { duration: (0, require_utils_index.utils_exports.isNumber)(duration) ? duration : duration.exit } : {},
34
+ ...!(0, require_utils_index.utils_exports.isUndefined)(duration) ? { duration: (0, require_utils_index.utils_exports.isNumber)(duration) ? duration : duration.exit } : {},
35
35
  delay: (0, require_utils_index.utils_exports.isNumber)(delay) ? delay : delay?.exit
36
36
  };
37
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transition.cjs","names":[],"sources":["../../../../src/components/motion/transition.ts"],"sourcesContent":["import type { Transition } from \"motion/react\"\nimport type { MotionTransitionProps } from \"./index.types\"\nimport { isNumber } from \"../../utils\"\n\nexport const createTransition = {\n enter: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0, 0, 0.58, 1],\n }),\n ...(duration\n ? { duration: isNumber(duration) ? duration : duration.enter }\n : {}),\n delay: isNumber(delay) ? delay : delay?.enter,\n }\n }\n },\n exit: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0.42, 0, 1, 1],\n }),\n ...(duration\n ? { duration: isNumber(duration) ? duration : duration.exit }\n : {}),\n delay: isNumber(delay) ? delay : delay?.exit,\n }\n }\n },\n}\n"],"mappings":";;;AAIA,MAAa,mBAAmB;CAC9B,OAAO,SAAU,YAAyB;AACxC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAG;MAAG;MAAM;MAAE;KACtB;IACD,GAAI,WACA,EAAE,0DAAmB,SAAS,GAAG,WAAW,SAAS,OAAO,GAC5D,EAAE;IACN,uDAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGL,MAAM,SAAU,YAAyB;AACvC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAM;MAAG;MAAG;MAAE;KACtB;IACD,GAAI,WACA,EAAE,0DAAmB,SAAS,GAAG,WAAW,SAAS,MAAM,GAC3D,EAAE;IACN,uDAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGN"}
1
+ {"version":3,"file":"transition.cjs","names":[],"sources":["../../../../src/components/motion/transition.ts"],"sourcesContent":["import type { Transition } from \"motion/react\"\nimport type { MotionTransitionProps } from \"./index.types\"\nimport { isNumber, isUndefined } from \"../../utils\"\n\nexport const createTransition = {\n enter: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0, 0, 0.58, 1],\n }),\n ...(!isUndefined(duration)\n ? { duration: isNumber(duration) ? duration : duration.enter }\n : {}),\n delay: isNumber(delay) ? delay : delay?.enter,\n }\n }\n },\n exit: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0.42, 0, 1, 1],\n }),\n ...(!isUndefined(duration)\n ? { duration: isNumber(duration) ? duration : duration.exit }\n : {}),\n delay: isNumber(delay) ? delay : delay?.exit,\n }\n }\n },\n}\n"],"mappings":";;;AAIA,MAAa,mBAAmB;CAC9B,OAAO,SAAU,YAAyB;AACxC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAG;MAAG;MAAM;MAAE;KACtB;IACD,GAAI,oDAAa,SAAS,GACtB,EAAE,0DAAmB,SAAS,GAAG,WAAW,SAAS,OAAO,GAC5D,EAAE;IACN,uDAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGL,MAAM,SAAU,YAAyB;AACvC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAM;MAAG;MAAG;MAAE;KACtB;IACD,GAAI,oDAAa,SAAS,GACtB,EAAE,0DAAmB,SAAS,GAAG,WAAW,SAAS,MAAM,GAC3D,EAAE;IACN,uDAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGN"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-component.cjs","names":["Fragment","styled","getDisplayName","createContext","useSystem","getClassName","name","useComponentStyle","withContext","mergeProps","chainProps","getSlotClassName","useComponentSlotStyle","style","mergeSlotCSS"],"sources":["../../../../src/core/components/create-component.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, FunctionComponent } from \"react\"\nimport type { AnyString, Dict, Merge } from \"../../utils\"\nimport type { CSSObject, CSSSlotObject } from \"../css\"\nimport type {\n ComponentSlotStyle,\n ComponentStyle,\n StyledOptions,\n System,\n WithoutThemeProps,\n} from \"../system\"\nimport type {\n As,\n DOMElement,\n HTMLStyledProps,\n Component as OriginalComponent,\n} from \"./index.types\"\nimport { Fragment } from \"react\"\nimport {\n createContext,\n cx,\n isArray,\n isFunction,\n isObject,\n isString,\n runIfFn,\n toArray,\n toCamelCase,\n toPascalCase,\n} from \"../../utils\"\nimport { styled, useSystem } from \"../system\"\nimport { chainProps, mergeProps } from \"./props\"\nimport {\n getSlotClassName,\n mergeSlotCSS,\n useComponentSlotStyle,\n useComponentStyle,\n} from \"./use-component-style\"\nimport { getClassName, getDisplayName } from \"./utils\"\n\ntype AsWithFragment = \"fragment\" | As\ntype ClassName = ((system: System) => string) | string\n\ntype Component<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n> = Y extends \"fragment\"\n ? FunctionComponent<M>\n : OriginalComponent<Exclude<Y, \"fragment\">, M>\n\nexport type ComponentSlotName<\n Y extends ComponentSlotStyle | ComponentStyle = ComponentSlotStyle,\n> = AnyString | Extract<keyof NonNullable<Y[\"base\"]>, string>\n\nexport type ComponentSlot<Y extends string> =\n | [Y, Y]\n | Y\n | { name: string; slot: [Y, Y] | Y }\n\nexport type InitialProps<Y extends Dict = Dict> =\n | ((props: Y) => any)\n | Partial<Y>\nexport type SuperProps<Y extends Dict = Dict> = ((props: Y) => any) | Y\n\nexport type SuperWithoutThemeProps<\n Y extends Dict = Dict,\n M extends Dict = Dict,\n D extends keyof Y = keyof Y,\n> = ((props: WithoutThemeProps<Y, M, D>) => any) | WithoutThemeProps<Y, M, D>\n\nexport interface UseComponentPropsOptions<\n Y extends number | string | symbol = string,\n> {\n className?: ClassName\n withContext?: boolean\n transferProps?: Y[]\n}\n\nexport interface ComponentOptions extends Omit<StyledOptions, \"transferProps\"> {\n className?: ClassName\n shouldStyleProps?: boolean\n}\n\ninterface classNameOptions<Y extends string = string> {\n className?: ClassName\n slot?: ComponentSlot<Y>\n}\n\nexport interface ComponentWithContextOptions<\n Y extends number | string | symbol = string,\n>\n extends ComponentOptions, UseComponentPropsOptions<Y> {}\n\nfunction createProxyComponent<\n Y extends AsWithFragment = \"div\",\n M extends Dict = Dict,\n>(el: FC<M> | Y, { shouldStyleProps, ...options }: ComponentOptions = {}) {\n options.shouldForwardProp ??= isFunction(el)\n shouldStyleProps ??= !isFunction(el)\n\n if (el === \"fragment\") el = Fragment\n\n if (shouldStyleProps || isString(el)) {\n const ProxyComponent = styled(el as As, options)\n\n ProxyComponent.displayName = \"ProxyComponent\"\n\n return ProxyComponent\n } else {\n el.displayName ??= \"ProxyComponent\"\n\n return el as FC<M>\n }\n}\n\nfunction withDisplayName<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n>(Component: FC<M>, displayName: string) {\n Object.defineProperty(Component, \"name\", { value: displayName })\n Object.defineProperty(Component, \"displayName\", { value: displayName })\n\n return Component as Component<Y, M>\n}\n\nfunction getSlotKey<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"unknown\"\n\n if (isArray(slot) || !isObject(slot)) {\n return toCamelCase(toArray(slot).join(\"-\"))\n } else {\n return toCamelCase(slot.name)\n }\n}\n\nfunction getSlotName<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"\"\n\n if (isArray(slot)) {\n return slot.map((value) => toPascalCase(value as string)).join(\"\")\n } else if (isObject(slot)) {\n return toPascalCase(slot.name)\n } else {\n return toPascalCase(slot as string)\n }\n}\n\nexport function createComponent<\n Y extends object = {},\n M extends ComponentStyle = Dict,\n D extends Dict = Dict,\n>(name: string, style?: M) {\n const defaultClassName = style?.className\n const defaultDisplayName = getDisplayName(name)\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${defaultDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${defaultDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(name?: string, className?: ClassName) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getClassName(name, defaultClassName)(system)\n\n return className\n }\n\n function useComponentProps<H extends Y = Y, R extends keyof H = keyof H>(\n props: H,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= defaultClassName\n className ??= getClassName(name)(system)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext ? mergeProps(contextProps, props)() : props\n const [, rest] = useComponentStyle(mergedProps, {\n name,\n className,\n style,\n transferProps,\n })\n\n return rest\n }\n\n function component<D extends AsWithFragment = \"div\", H extends Dict = Y>(\n el: D | FC<H>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperProps<H>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps<any>(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withContext<\n D extends AsWithFragment = \"div\",\n H extends Y = Y,\n R extends keyof H = keyof H,\n >(\n el: D | FC<WithoutThemeProps<H, M, R>>,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<R> = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperWithoutThemeProps<H, M, R>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useComponentProps(computedProps, {\n className,\n withContext,\n transferProps,\n })\n const rest = chainProps<any>(...toArray(superProps))()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n useComponentContext,\n usePropsContext,\n withContext,\n useComponentProps,\n }\n}\n\nexport function createSlotComponent<\n Y extends object = {},\n M extends ComponentSlotStyle = Dict,\n D extends Dict = Dict,\n>(rootName: string, style?: M) {\n const rootClassName = style?.className\n const rootDisplayName = getDisplayName(rootName)\n const classNameMap = new Map<string, classNameOptions>()\n const [StyleContext, useStyleContext] = createContext<\n CSSSlotObject<ComponentSlotName<M>>\n >({\n name: `${rootDisplayName}StyleContext`,\n })\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${rootDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${rootDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(\n slot?: ComponentSlot<ComponentSlotName<M>>,\n className?: ClassName,\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return className\n }\n\n function useClassNames() {\n const system = useSystem()\n const entries = classNameMap.entries().map(([key, { className, slot }]) => {\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return [key, className]\n })\n\n return Object.fromEntries(\n entries.filter(([_, className]) => className),\n ) as { [key: string]: string }\n }\n\n function useRootComponentProps<\n Y extends Dict = Dict,\n R extends keyof Y = keyof Y,\n >(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ): [\n CSSSlotObject,\n Merge<WithoutThemeProps<Y, M, R>, { css?: CSSObject | CSSObject[] }>,\n ] {\n className = useClassName(slot, className)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext ? mergeProps(contextProps, props)() : props\n const [css, rest] = useComponentSlotStyle(mergedProps, {\n name: rootName,\n className,\n style,\n slot,\n transferProps,\n })\n\n return [css, rest]\n }\n\n function useSlotComponentProps<Y extends Dict = Dict>(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { className }: Omit<UseComponentPropsOptions, \"transferProps\"> = {},\n ) {\n className = useClassName(slot, className)\n\n const style = useStyleContext()\n\n return {\n ...props,\n className: cx(className, props.className),\n css: mergeSlotCSS(slot, style, props.css),\n }\n }\n\n function component<H extends AsWithFragment = \"div\", R extends Dict = Dict>(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n className = useClassName(slot, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withProvider<\n H extends AsWithFragment = \"div\",\n R extends Y = Y,\n T extends keyof R = keyof R,\n >(\n el: FC<WithoutThemeProps<R, M, T>> | H,\n slot: ComponentSlot<ComponentSlotName<M>> = \"root\" as ComponentSlot<\n ComponentSlotName<M>\n >,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<T> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperWithoutThemeProps<R, M, T>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const [context, mergedProps] = useRootComponentProps(\n computedProps,\n slot,\n {\n className,\n withContext,\n transferProps,\n },\n )\n const rest = chainProps<any>(...superProps)()(mergedProps)\n\n return (\n <StyleContext value={context}>\n <ProxyComponent {...rest} />\n </StyleContext>\n )\n }, displayName)\n }\n }\n\n function withContext<\n H extends AsWithFragment = \"div\",\n R extends Dict = H extends DOMElement ? HTMLStyledProps<H> : Dict,\n >(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n name,\n className,\n withContext,\n ...options\n }: Omit<ComponentWithContextOptions, \"transferProps\"> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useSlotComponentProps(computedProps, slot, {\n className,\n withContext,\n })\n const rest = chainProps(...superProps)()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n StyleContext,\n useClassNames,\n useComponentContext,\n usePropsContext,\n useStyleContext,\n withContext,\n withProvider,\n useRootComponentProps,\n useSlotComponentProps,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8FA,SAAS,qBAGP,IAAe,EAAE,kBAAkB,GAAG,YAA8B,EAAE,EAAE;AACxE,SAAQ,wEAAiC,GAAG;AAC5C,sBAAqB,mDAAY,GAAG;AAEpC,KAAI,OAAO,WAAY,MAAKA;AAE5B,KAAI,oEAA6B,GAAG,EAAE;EACpC,MAAM,iBAAiBC,uBAAO,IAAU,QAAQ;AAEhD,iBAAe,cAAc;AAE7B,SAAO;QACF;AACL,KAAG,gBAAgB;AAEnB,SAAO;;;AAIX,SAAS,gBAGP,WAAkB,aAAqB;AACvC,QAAO,eAAe,WAAW,QAAQ,EAAE,OAAO,aAAa,CAAC;AAChE,QAAO,eAAe,WAAW,eAAe,EAAE,OAAO,aAAa,CAAC;AAEvE,QAAO;;AAGT,SAAS,WAA6B,MAAyB;AAC7D,KAAI,CAAC,KAAM,QAAO;AAElB,oDAAY,KAAK,IAAI,iDAAU,KAAK,CAClC,0GAA2B,KAAK,CAAC,KAAK,IAAI,CAAC;KAE3C,2DAAmB,KAAK,KAAK;;AAIjC,SAAS,YAA8B,MAAyB;AAC9D,KAAI,CAAC,KAAM,QAAO;AAElB,oDAAY,KAAK,CACf,QAAO,KAAK,KAAK,8DAAuB,MAAgB,CAAC,CAAC,KAAK,GAAG;0DAChD,KAAK,CACvB,4DAAoB,KAAK,KAAK;KAE9B,4DAAoB,KAAe;;AAIvC,SAAgB,gBAId,MAAc,OAA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"file":"create-component.cjs","names":["Fragment","styled","getDisplayName","createContext","useSystem","getClassName","name","useComponentStyle","withContext","mergeProps","chainProps","getSlotClassName","useComponentSlotStyle","style","mergeSlotCSS"],"sources":["../../../../src/core/components/create-component.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, FunctionComponent } from \"react\"\nimport type { AnyString, Dict, Merge } from \"../../utils\"\nimport type { CSSObject, CSSSlotObject } from \"../css\"\nimport type {\n ComponentSlotStyle,\n ComponentStyle,\n StyledOptions,\n System,\n WithoutThemeProps,\n} from \"../system\"\nimport type {\n As,\n DOMElement,\n HTMLStyledProps,\n Component as OriginalComponent,\n} from \"./index.types\"\nimport { Fragment } from \"react\"\nimport {\n createContext,\n cx,\n isArray,\n isFunction,\n isObject,\n isString,\n runIfFn,\n toArray,\n toCamelCase,\n toPascalCase,\n} from \"../../utils\"\nimport { styled, useSystem } from \"../system\"\nimport { chainProps, mergeProps } from \"./props\"\nimport {\n getSlotClassName,\n mergeSlotCSS,\n useComponentSlotStyle,\n useComponentStyle,\n} from \"./use-component-style\"\nimport { getClassName, getDisplayName } from \"./utils\"\n\ntype AsWithFragment = \"fragment\" | As\ntype ClassName = ((system: System) => string) | string\n\ntype Component<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n> = Y extends \"fragment\"\n ? FunctionComponent<M>\n : OriginalComponent<Exclude<Y, \"fragment\">, M>\n\nexport type ComponentSlotName<\n Y extends ComponentSlotStyle | ComponentStyle = ComponentSlotStyle,\n> = AnyString | Extract<keyof NonNullable<Y[\"base\"]>, string>\n\nexport type ComponentSlot<Y extends string> =\n | [Y, Y]\n | Y\n | { name: string; slot: [Y, Y] | Y }\n\nexport type InitialProps<Y extends Dict = Dict> =\n | ((props: Y) => any)\n | Partial<Y>\nexport type SuperProps<Y extends Dict = Dict> = ((props: Y) => any) | Y\n\nexport type SuperWithoutThemeProps<\n Y extends Dict = Dict,\n M extends Dict = Dict,\n D extends keyof Y = keyof Y,\n> = ((props: WithoutThemeProps<Y, M, D>) => any) | WithoutThemeProps<Y, M, D>\n\nexport interface UseComponentPropsOptions<\n Y extends number | string | symbol = string,\n> {\n className?: ClassName\n withContext?: boolean\n transferProps?: Y[]\n}\n\nexport interface ComponentOptions extends Omit<StyledOptions, \"transferProps\"> {\n className?: ClassName\n shouldStyleProps?: boolean\n}\n\ninterface classNameOptions<Y extends string = string> {\n className?: ClassName\n slot?: ComponentSlot<Y>\n}\n\nexport interface ComponentWithContextOptions<\n Y extends number | string | symbol = string,\n>\n extends ComponentOptions, UseComponentPropsOptions<Y> {}\n\nfunction createProxyComponent<\n Y extends AsWithFragment = \"div\",\n M extends Dict = Dict,\n>(el: FC<M> | Y, { shouldStyleProps, ...options }: ComponentOptions = {}) {\n options.shouldForwardProp ??= isFunction(el)\n shouldStyleProps ??= !isFunction(el)\n\n if (el === \"fragment\") el = Fragment\n\n if (shouldStyleProps || isString(el)) {\n const ProxyComponent = styled(el as As, options)\n\n ProxyComponent.displayName = \"ProxyComponent\"\n\n return ProxyComponent\n } else {\n el.displayName ??= \"ProxyComponent\"\n\n return el as FC<M>\n }\n}\n\nfunction withDisplayName<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n>(Component: FC<M>, displayName: string) {\n Object.defineProperty(Component, \"name\", { value: displayName })\n Object.defineProperty(Component, \"displayName\", { value: displayName })\n\n return Component as Component<Y, M>\n}\n\nfunction getSlotKey<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"unknown\"\n\n if (isArray(slot) || !isObject(slot)) {\n return toCamelCase(toArray(slot).join(\"-\"))\n } else {\n return toCamelCase(slot.name)\n }\n}\n\nfunction getSlotName<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"\"\n\n if (isArray(slot)) {\n return slot.map((value) => toPascalCase(value as string)).join(\"\")\n } else if (isObject(slot)) {\n return toPascalCase(slot.name)\n } else {\n return toPascalCase(slot as string)\n }\n}\n\nexport function createComponent<\n Y extends object = {},\n M extends ComponentStyle = Dict,\n D extends Dict = Dict,\n>(name: string, style?: M) {\n const defaultClassName = style?.className\n const defaultDisplayName = getDisplayName(name)\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${defaultDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${defaultDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(name?: string, className?: ClassName) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getClassName(name, defaultClassName)(system)\n\n return className\n }\n\n function useComponentProps<H extends Y = Y, R extends keyof H = keyof H>(\n props: H,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= defaultClassName\n className ??= getClassName(name)(system)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext\n ? (mergeProps(contextProps, props)() as H)\n : props\n const [, rest] = useComponentStyle(mergedProps, {\n name,\n className,\n style,\n transferProps,\n })\n\n return rest\n }\n\n function component<D extends AsWithFragment = \"div\", H extends Dict = Y>(\n el: D | FC<H>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperProps<H>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps<any>(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withContext<\n D extends AsWithFragment = \"div\",\n H extends Y = Y,\n R extends keyof H = keyof H,\n >(\n el: D | FC<WithoutThemeProps<H, M, R>>,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<R> = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperWithoutThemeProps<H, M, R>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useComponentProps(computedProps, {\n className,\n withContext,\n transferProps,\n })\n const rest = chainProps<any>(...toArray(superProps))()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n useComponentContext,\n usePropsContext,\n withContext,\n useComponentProps,\n }\n}\n\nexport function createSlotComponent<\n Y extends object = {},\n M extends ComponentSlotStyle = Dict,\n D extends Dict = Dict,\n>(rootName: string, style?: M) {\n const rootClassName = style?.className\n const rootDisplayName = getDisplayName(rootName)\n const classNameMap = new Map<string, classNameOptions>()\n const [StyleContext, useStyleContext] = createContext<\n CSSSlotObject<ComponentSlotName<M>>\n >({\n name: `${rootDisplayName}StyleContext`,\n })\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${rootDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${rootDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(\n slot?: ComponentSlot<ComponentSlotName<M>>,\n className?: ClassName,\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return className\n }\n\n function useClassNames() {\n const system = useSystem()\n const entries = classNameMap.entries().map(([key, { className, slot }]) => {\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return [key, className]\n })\n\n return Object.fromEntries(\n entries.filter(([_, className]) => className),\n ) as { [key: string]: string }\n }\n\n function useRootComponentProps<\n Y extends Dict = {},\n R extends keyof Y = keyof Y,\n >(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ): [\n CSSSlotObject,\n Merge<WithoutThemeProps<Y, M, R>, { css?: CSSObject | CSSObject[] }>,\n ] {\n className = useClassName(slot, className)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext\n ? (mergeProps(contextProps, props)() as Y)\n : props\n const [css, rest] = useComponentSlotStyle(mergedProps, {\n name: rootName,\n className,\n style,\n slot,\n transferProps,\n })\n\n return [css, rest]\n }\n\n function useSlotComponentProps<Y extends Dict = {}>(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { className }: Omit<UseComponentPropsOptions, \"transferProps\"> = {},\n ) {\n className = useClassName(slot, className)\n\n const style = useStyleContext()\n\n return {\n ...props,\n className: cx(className, props.className),\n css: mergeSlotCSS(slot, style, props.css),\n }\n }\n\n function component<H extends AsWithFragment = \"div\", R extends Dict = Dict>(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n className = useClassName(slot, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withProvider<\n H extends AsWithFragment = \"div\",\n R extends Y = Y,\n T extends keyof R = keyof R,\n >(\n el: FC<WithoutThemeProps<R, M, T>> | H,\n slot: ComponentSlot<ComponentSlotName<M>> = \"root\" as ComponentSlot<\n ComponentSlotName<M>\n >,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<T> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperWithoutThemeProps<R, M, T>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const [context, mergedProps] = useRootComponentProps(\n computedProps,\n slot,\n {\n className,\n withContext,\n transferProps,\n },\n )\n const rest = chainProps<any>(...superProps)()(mergedProps)\n\n return (\n <StyleContext value={context}>\n <ProxyComponent {...rest} />\n </StyleContext>\n )\n }, displayName)\n }\n }\n\n function withContext<\n H extends AsWithFragment = \"div\",\n R extends Dict = H extends DOMElement ? HTMLStyledProps<H> : Dict,\n >(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n name,\n className,\n withContext,\n ...options\n }: Omit<ComponentWithContextOptions, \"transferProps\"> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useSlotComponentProps(computedProps, slot, {\n className,\n withContext,\n })\n const rest = chainProps(...superProps)()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n StyleContext,\n useClassNames,\n useComponentContext,\n usePropsContext,\n useStyleContext,\n withContext,\n withProvider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G,YACH;AACA,UAAO,iBAAuB,UAAU;IAItC,MAAM,CAAC,SAAS,eAAe,wEAHE,aAAa,GAC1C,aAAa,MAAM,GACnBO,yBAAW,gBAAgB,EAAE,EAAE,MAAM,EAAE,EAGzC,MACA;KACE;KACA;KACA;KACD,CACF;AAGD,WACE,2CAAC;KAAa,OAAO;eACnB,2CAAC,kBAAe,GAJPC,yBAAgB,GAAG,WAAW,EAAE,CAAC,YAAY,GAI1B;MACf;MAEhB,YAAY;;;CAInB,SAAS,YAIP,IACA,MACA,EACE,MACA,WACA,4BACA,GAAG,YACmD,EAAE,EAC1D;EACA,MAAM,iBAAiB,qBAAqB,IAAI,QAAQ;EACxD,MAAM,UAAU,WAAW,KAAK;EAEhC,MAAM,cAAcR,6BAAe,MAAM,GAAG,kBAD3B,YAAY,KAAK,GACuC;AAEzE,eAAa,IAAI,SAAS;GAAE;GAAW;GAAM,CAAC;AAE9C,SAAO,SACL,cACA,GAAG,YACH;AACA,UAAO,iBAAuB,UAAU;IAItC,MAAM,cAAc,wEAHa,aAAa,GAC1C,aAAa,MAAM,GACnBO,yBAAW,gBAAgB,EAAE,EAAE,MAAM,EAAE,EACc,MAAM;KAC7D;KACA;KACD,CAAC;AAGF,WAAO,2CAAC,kBAAe,GAFVC,yBAAW,GAAG,WAAW,EAAE,CAAC,YAAY,GAElB;MAClC,YAAY;;;AAInB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -24,6 +24,7 @@ function mergeProps(...args) {
24
24
  return function({ mergeClassName = true, mergeCSS = true, mergeEvent = true, mergeRef = true, mergeStyle = true } = {}) {
25
25
  let result = {};
26
26
  for (const props of args) {
27
+ if ((0, require_utils_index.utils_exports.isUndefined)(props)) continue;
27
28
  for (const key in result) {
28
29
  if (mergeRef && key === "ref") {
29
30
  result[key] = require_ref.mergeRefs(result[key], props[key]);
@@ -1 +1 @@
1
- {"version":3,"file":"props.cjs","names":["conditionProperties","styleProperties","result: Dict","mergeRefs"],"sources":["../../../../src/core/components/props.ts"],"sourcesContent":["import type { Dict, Merge } from \"../../utils\"\nimport { useMemo } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport {\n cx,\n handlerAll,\n isArray,\n isEmptyObject,\n isFunction,\n isObject,\n isUndefined,\n merge,\n mergeRefs,\n omitObject,\n splitObject,\n} from \"../../utils\"\nimport { conditionProperties, styleProperties } from \"../css\"\n\ntype MergeAll<Y extends Dict[]> = Y extends [infer M]\n ? M\n : Y extends [infer D, ...infer H]\n ? H extends any[]\n ? Merge<D, MergeAll<H>>\n : D\n : never\n\nfunction isEvent(key: string) {\n return /^on[A-Z]/.test(key)\n}\n\nexport const cssProps = new Set<string>([\n ...conditionProperties,\n ...styleProperties,\n])\n\nexport type ShouldForwardProp = (prop: string) => boolean\n\nexport function createShouldForwardProp(\n forwardProps: string[] = [],\n): ShouldForwardProp {\n return function (prop: string): boolean {\n if (forwardProps.includes(prop)) return true\n\n if (prop.startsWith(\"--\")) return false\n\n return !cssProps.has(prop)\n }\n}\n\ninterface MergePropsOptions {\n mergeClassName?: boolean\n mergeCSS?: boolean\n mergeEvent?: boolean\n mergeRef?: boolean\n mergeStyle?: boolean\n}\n\nexport function mergeProps<Y extends Dict[]>(...args: Y) {\n return function ({\n mergeClassName = true,\n mergeCSS = true,\n mergeEvent = true,\n mergeRef = true,\n mergeStyle = true,\n }: MergePropsOptions = {}): MergeAll<Y> {\n let result: Dict = {}\n\n for (const props of args) {\n for (const key in result) {\n if (mergeRef && key === \"ref\") {\n result[key] = mergeRefs(result[key], props[key])\n\n continue\n }\n\n if (\n mergeEvent &&\n isEvent(key) &&\n isFunction(result[key]) &&\n isFunction(props[key])\n ) {\n result[key] = handlerAll(result[key], props[key])\n\n continue\n }\n\n if (mergeClassName && (key === \"className\" || key === \"class\")) {\n result[key] = cx(result[key], props[key])\n\n continue\n }\n\n if (mergeStyle && key === \"style\") {\n result[key] = merge(result[key] ?? {}, props[key] ?? {})\n\n continue\n }\n\n if (mergeCSS && key === \"css\") {\n if (isArray(result[key])) {\n result[key].push(props[key])\n } else {\n result[key] ??= []\n\n result[key] = [result[key], props[key]]\n }\n\n continue\n }\n\n result[key] = !isUndefined(props[key]) ? props[key] : result[key]\n }\n\n for (const key in props) {\n if (isUndefined(result[key])) result[key] = props[key]\n }\n }\n\n return result as any\n }\n}\n\ntype CallbackProps<Y extends Dict = Dict> = (props: Y) => Y\n\ntype PropsOrCallback<Y extends Dict = Dict> = CallbackProps<Y> | Y\n\nexport function chainProps<Y extends Dict = Dict>(\n ...props: PropsOrCallback<Y>[]\n) {\n return function (options: MergePropsOptions = {}) {\n if (!props.length) return (a: Y) => a\n\n if (props.length === 1)\n return function (b: Y) {\n const a = props[0] ?? {}\n const c = isFunction(a) ? a(b) : mergeProps(a, b)(options)\n\n return c\n } as CallbackProps<Y>\n\n return props.reduce(function (a, b) {\n return function (c: Y = {} as Y) {\n const d = isFunction(a) ? a(c) : mergeProps(a, c)(options)\n const f = isFunction(b) ? b(d) : mergeProps(b, d)(options)\n\n return f\n }\n }) as CallbackProps<Y>\n }\n}\n\nexport function isEqualProps<\n Y extends Dict,\n M extends Dict,\n D extends keyof M | keyof Y,\n>(a: Y, b: M, omitKeys: D[] = []) {\n return isEqual(\n omitObject(a, omitKeys as (keyof Y)[]),\n omitObject(b, omitKeys as (keyof M)[]),\n )\n}\n\nexport function useSplitProps<Y extends Dict, M extends keyof Y>(\n props: Y,\n keys: M[] | readonly M[],\n) {\n return useMemo(() => splitObject<Y, M>(props, keys), [props, keys])\n}\n\nexport function extractProps(props: Dict, keys: readonly string[] | string[]) {\n let result: Dict = {}\n\n Object.entries(props).forEach(([key, value]) => {\n if (!cssProps.has(key)) return\n\n if (keys.includes(key)) {\n result = merge(result, { [key]: value })\n } else if (isObject(value)) {\n value = extractProps(value, keys)\n\n if (isEmptyObject(value)) return\n\n result = merge(result, { [key]: value })\n }\n })\n\n return result\n}\n\nexport function useExtractProps(\n props: Dict,\n ke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gB,gBACd,OACA,MACA;AACA,iCAAqB,aAAa,OAAO,KAAK,EAAE,CAAC,OAAO,KAAK,CAAC"}
1
+ {"version":3,"file":"props.cjs","names":["conditionProperties","styleProperties","result: Dict","mergeRefs"],"sources":["../../../../src/core/components/props.ts"],"sourcesContent":["import type { Dict, Merge } from \"../../utils\"\nimport { useMemo } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport {\n cx,\n handlerAll,\n isArray,\n isEmptyObject,\n isFunction,\n isObject,\n isUndefined,\n merge,\n mergeRefs,\n omitObject,\n splitObject,\n} from \"../../utils\"\nimport { conditionProperties, styleProperties } from \"../css\"\n\ntype Optionalize<Y> = [Extract<Y, undefined>] extends [never]\n ? Y\n : Partial<Exclude<Y, undefined>>\n\ntype MergeAll<Y extends (Dict | undefined)[]> = Y extends [infer M]\n ? Optionalize<M>\n : Y extends [infer D, ...infer H]\n ? H extends (Dict | undefined)[]\n ? Merge<Optionalize<D>, MergeAll<H>>\n : Optionalize<D>\n : never\n\nfunction isEvent(key: string) {\n return /^on[A-Z]/.test(key)\n}\n\nexport const cssProps = new Set<string>([\n ...conditionProperties,\n ...styleProperties,\n])\n\nexport type ShouldForwardProp = (prop: string) => boolean\n\nexport function createShouldForwardProp(\n forwardProps: string[] = [],\n): ShouldForwardProp {\n return function (prop: string): boolean {\n if (forwardProps.includes(prop)) return true\n\n if (prop.startsWith(\"--\")) return false\n\n return !cssProps.has(prop)\n }\n}\n\ninterface MergePropsOptions {\n mergeClassName?: boolean\n mergeCSS?: boolean\n mergeEvent?: boolean\n mergeRef?: boolean\n mergeStyle?: boolean\n}\n\nexport function mergeProps<Y extends Dict>(\n ...args: Y[]\n): (options?: MergePropsOptions) => Y\nexport function mergeProps<Y extends (Dict | undefined)[]>(\n ...args: Y\n): (options?: MergePropsOptions) => MergeAll<Y>\nexport function mergeProps(...args: (Dict | undefined)[]) {\n return function ({\n mergeClassName = true,\n mergeCSS = true,\n mergeEvent = true,\n mergeRef = true,\n mergeStyle = true,\n }: MergePropsOptions = {}) {\n let result: Dict = {}\n\n for (const props of args) {\n if (isUndefined(props)) continue\n\n for (const key in result) {\n if (mergeRef && key === \"ref\") {\n result[key] = mergeRefs(result[key], props[key])\n\n continue\n }\n\n if (\n mergeEvent &&\n isEvent(key) &&\n isFunction(result[key]) &&\n isFunction(props[key])\n ) {\n result[key] = handlerAll(result[key], props[key])\n\n continue\n }\n\n if (mergeClassName && (key === \"className\" || key === \"class\")) {\n result[key] = cx(result[key], props[key])\n\n continue\n }\n\n if (mergeStyle && key === \"style\") {\n result[key] = merge(result[key] ?? {}, props[key] ?? {})\n\n continue\n }\n\n if (mergeCSS && key === \"css\") {\n if (isArray(result[key])) {\n result[key].push(props[key])\n } else {\n result[key] ??= []\n\n result[key] = [result[key], props[key]]\n }\n\n continue\n }\n\n result[key] = !isUndefined(props[key]) ? props[key] : result[key]\n }\n\n for (const key in props) {\n if (isUndefined(result[key])) result[key] = props[key]\n }\n }\n\n return result as any\n }\n}\n\ntype CallbackProps<Y extends Dict = Dict> = (props: Y) => Y\n\ntype PropsOrCallback<Y extends Dict = Dict> = CallbackProps<Y> | Y\n\nexport function chainProps<Y extends Dict = Dict>(\n ...props: PropsOrCallback<Y>[]\n) {\n return function (options: MergePropsOptions = {}) {\n if (!props.length) return (a: Y) => a\n\n if (props.length === 1)\n return function (b: Y) {\n const a = props[0] ?? {}\n const c = isFunction(a) ? a(b) : mergeProps(a, b)(options)\n\n return c\n } as CallbackProps<Y>\n\n return props.reduce(function (a, b) {\n return function (c: Y = {} as Y) {\n const d = isFunction(a) ? a(c) : mergeProps(a, c)(options)\n const f = isFunction(b) ? b(d) : mergeProps(b, d)(options)\n\n return f\n }\n }) as CallbackProps<Y>\n }\n}\n\nexport function isEqualProps<\n Y extends Dict,\n M extends Dict,\n D extends keyof M | keyof Y,\n>(a: Y, b: M, omitKeys: D[] = []) {\n return isEqual(\n omitObject(a, omitKeys as (keyof Y)[]),\n omitObject(b, omitKeys as (keyof M)[]),\n )\n}\n\nexport function useSplitProps<Y extends Dict, M extends keyof Y>(\n props: Y,\n keys: M[] | readonly M[],\n) {\n return useMemo(() => splitObject<Y, M>(props, keys), [props, keys])\n}\n\nexport function extractProps(props: Dict, keys: readonly string[] | string[]) {\n let result: Dict = {}\n\n Object.entries(props).forEach(([key, value]) => {\n if (!cssProps.has(key)) return\n\n if (keys.includes(key)) {\n result = merge(result, { [key]: value })\n } else if (isObject(value)) {\n value = extractProps(value, keys)\n\n if (isEmptyObject(value)) return\n\n result = merge(result, { [key]: value })\n }\n })\n\n return result\n}\n\nexport function useExtractProps(\n props: Dict,\n keys: readonly string[] | string[],\n) {\n return useMemo(() => extractProps(props, keys), [props, keys])\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAS,QAAQ,KAAa;AAC5B,QAAO,WAAW,KAAK,IAAI;;AAG7B,MAAa,WAAW,IAAI,IAAY,CACtC,GAAGA,wCACH,GAAGC,+BACJ,CAAC;AAIF,SAAgB,wBACd,eAAyB,EAAE,EACR;AACnB,QAAO,SAAU,MAAuB;AACtC,MAAI,aAAa,SAAS,KAAK,CAAE,QAAO;AAExC,MAAI,KAAK,WAAW,KAAK,CAAE,QAAO;AAElC,SAAO,CAAC,SAAS,IAAI,KAAK;;;AAkB9B,SAAgB,WAAW,GAAG,MAA4B;AACxD,QAAO,SAAU,EACf,iBAAiB,MACjB,WAAW,MACX,aAAa,MACb,WAAW,MACX,aAAa,SACQ,EAAE,EAAE;EACzB,IAAIC,SAAe,EAAE;AAErB,OAAK,MAAM,SAAS,MAAM;AACxB,0DAAgB,MAAM,CAAE;AAExB,QAAK,MAAM,OAAO,QAAQ;AACxB,QAAI,YAAY,QAAQ,OAAO;AAC7B,YAAO,OAAOC,sBAAU,OAAO,MAAM,MAAM,KAAK;AAEhD;;AAGF,QACE,cACA,QAAQ,IAAI,sDACD,OAAO,KAAK,sDACZ,MAAM,KAAK,EACtB;AACA,YAAO,yDAAkB,OAAO,MAAM,MAAM,KAAK;AAEjD;;AAG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AO,KAAK,CAAC;;AAGrE,SAAgB,aAAa,OAAa,MAAoC;CAC5E,IAAID,SAAe,EAAE;AAErB,QAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,KAAK,WAAW;AAC9C,MAAI,CAAC,SAAS,IAAI,IAAI,CAAE;AAExB,MAAI,KAAK,SAAS,IAAI,CACpB,uDAAe,QAAQ,GAAG,MAAM,OAAO,CAAC;2DACtB,MAAM,EAAE;AAC1B,WAAQ,aAAa,OAAO,KAAK;AAEjC,4DAAkB,MAAM,CAAE;AAE1B,yDAAe,QAAQ,GAAG,MAAM,OAAO,CAAC;;GAE1C;AAEF,QAAO;;AAGT,SAAgB,gBACd,OACA,MACA;AACA,iCAAqB,aAAa,OAAO,KAAK,EAAE,CAAC,OAAO,KAAK,CAAC"}
@@ -14,7 +14,7 @@ const createTransition = {
14
14
  1
15
15
  ]
16
16
  },
17
- ...duration ? { duration: (0, utils_exports.isNumber)(duration) ? duration : duration.enter } : {},
17
+ ...!(0, utils_exports.isUndefined)(duration) ? { duration: (0, utils_exports.isNumber)(duration) ? duration : duration.enter } : {},
18
18
  delay: (0, utils_exports.isNumber)(delay) ? delay : delay?.enter
19
19
  };
20
20
  };
@@ -31,7 +31,7 @@ const createTransition = {
31
31
  1
32
32
  ]
33
33
  },
34
- ...duration ? { duration: (0, utils_exports.isNumber)(duration) ? duration : duration.exit } : {},
34
+ ...!(0, utils_exports.isUndefined)(duration) ? { duration: (0, utils_exports.isNumber)(duration) ? duration : duration.exit } : {},
35
35
  delay: (0, utils_exports.isNumber)(delay) ? delay : delay?.exit
36
36
  };
37
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"transition.js","names":[],"sources":["../../../../src/components/motion/transition.ts"],"sourcesContent":["import type { Transition } from \"motion/react\"\nimport type { MotionTransitionProps } from \"./index.types\"\nimport { isNumber } from \"../../utils\"\n\nexport const createTransition = {\n enter: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0, 0, 0.58, 1],\n }),\n ...(duration\n ? { duration: isNumber(duration) ? duration : duration.enter }\n : {}),\n delay: isNumber(delay) ? delay : delay?.enter,\n }\n }\n },\n exit: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0.42, 0, 1, 1],\n }),\n ...(duration\n ? { duration: isNumber(duration) ? duration : duration.exit }\n : {}),\n delay: isNumber(delay) ? delay : delay?.exit,\n }\n }\n },\n}\n"],"mappings":";;;AAIA,MAAa,mBAAmB;CAC9B,OAAO,SAAU,YAAyB;AACxC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAG;MAAG;MAAM;MAAE;KACtB;IACD,GAAI,WACA,EAAE,sCAAmB,SAAS,GAAG,WAAW,SAAS,OAAO,GAC5D,EAAE;IACN,mCAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGL,MAAM,SAAU,YAAyB;AACvC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAM;MAAG;MAAG;MAAE;KACtB;IACD,GAAI,WACA,EAAE,sCAAmB,SAAS,GAAG,WAAW,SAAS,MAAM,GAC3D,EAAE;IACN,mCAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGN"}
1
+ {"version":3,"file":"transition.js","names":[],"sources":["../../../../src/components/motion/transition.ts"],"sourcesContent":["import type { Transition } from \"motion/react\"\nimport type { MotionTransitionProps } from \"./index.types\"\nimport { isNumber, isUndefined } from \"../../utils\"\n\nexport const createTransition = {\n enter: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0, 0, 0.58, 1],\n }),\n ...(!isUndefined(duration)\n ? { duration: isNumber(duration) ? duration : duration.enter }\n : {}),\n delay: isNumber(delay) ? delay : delay?.enter,\n }\n }\n },\n exit: function (transition?: Transition) {\n return function (\n delay?: MotionTransitionProps[\"delay\"],\n duration?: MotionTransitionProps[\"duration\"],\n ): Transition {\n return {\n ...(transition ?? {\n duration: 0.2,\n ease: [0.42, 0, 1, 1],\n }),\n ...(!isUndefined(duration)\n ? { duration: isNumber(duration) ? duration : duration.exit }\n : {}),\n delay: isNumber(delay) ? delay : delay?.exit,\n }\n }\n },\n}\n"],"mappings":";;;AAIA,MAAa,mBAAmB;CAC9B,OAAO,SAAU,YAAyB;AACxC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAG;MAAG;MAAM;MAAE;KACtB;IACD,GAAI,gCAAa,SAAS,GACtB,EAAE,sCAAmB,SAAS,GAAG,WAAW,SAAS,OAAO,GAC5D,EAAE;IACN,mCAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGL,MAAM,SAAU,YAAyB;AACvC,SAAO,SACL,OACA,UACY;AACZ,UAAO;IACL,GAAI,cAAc;KAChB,UAAU;KACV,MAAM;MAAC;MAAM;MAAG;MAAG;MAAE;KACtB;IACD,GAAI,gCAAa,SAAS,GACtB,EAAE,sCAAmB,SAAS,GAAG,WAAW,SAAS,MAAM,GAC3D,EAAE;IACN,mCAAgB,MAAM,GAAG,QAAQ,OAAO;IACzC;;;CAGN"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-component.js","names":["createContext","name","withContext","style"],"sources":["../../../../src/core/components/create-component.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, FunctionComponent } from \"react\"\nimport type { AnyString, Dict, Merge } from \"../../utils\"\nimport type { CSSObject, CSSSlotObject } from \"../css\"\nimport type {\n ComponentSlotStyle,\n ComponentStyle,\n StyledOptions,\n System,\n WithoutThemeProps,\n} from \"../system\"\nimport type {\n As,\n DOMElement,\n HTMLStyledProps,\n Component as OriginalComponent,\n} from \"./index.types\"\nimport { Fragment } from \"react\"\nimport {\n createContext,\n cx,\n isArray,\n isFunction,\n isObject,\n isString,\n runIfFn,\n toArray,\n toCamelCase,\n toPascalCase,\n} from \"../../utils\"\nimport { styled, useSystem } from \"../system\"\nimport { chainProps, mergeProps } from \"./props\"\nimport {\n getSlotClassName,\n mergeSlotCSS,\n useComponentSlotStyle,\n useComponentStyle,\n} from \"./use-component-style\"\nimport { getClassName, getDisplayName } from \"./utils\"\n\ntype AsWithFragment = \"fragment\" | As\ntype ClassName = ((system: System) => string) | string\n\ntype Component<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n> = Y extends \"fragment\"\n ? FunctionComponent<M>\n : OriginalComponent<Exclude<Y, \"fragment\">, M>\n\nexport type ComponentSlotName<\n Y extends ComponentSlotStyle | ComponentStyle = ComponentSlotStyle,\n> = AnyString | Extract<keyof NonNullable<Y[\"base\"]>, string>\n\nexport type ComponentSlot<Y extends string> =\n | [Y, Y]\n | Y\n | { name: string; slot: [Y, Y] | Y }\n\nexport type InitialProps<Y extends Dict = Dict> =\n | ((props: Y) => any)\n | Partial<Y>\nexport type SuperProps<Y extends Dict = Dict> = ((props: Y) => any) | Y\n\nexport type SuperWithoutThemeProps<\n Y extends Dict = Dict,\n M extends Dict = Dict,\n D extends keyof Y = keyof Y,\n> = ((props: WithoutThemeProps<Y, M, D>) => any) | WithoutThemeProps<Y, M, D>\n\nexport interface UseComponentPropsOptions<\n Y extends number | string | symbol = string,\n> {\n className?: ClassName\n withContext?: boolean\n transferProps?: Y[]\n}\n\nexport interface ComponentOptions extends Omit<StyledOptions, \"transferProps\"> {\n className?: ClassName\n shouldStyleProps?: boolean\n}\n\ninterface classNameOptions<Y extends string = string> {\n className?: ClassName\n slot?: ComponentSlot<Y>\n}\n\nexport interface ComponentWithContextOptions<\n Y extends number | string | symbol = string,\n>\n extends ComponentOptions, UseComponentPropsOptions<Y> {}\n\nfunction createProxyComponent<\n Y extends AsWithFragment = \"div\",\n M extends Dict = Dict,\n>(el: FC<M> | Y, { shouldStyleProps, ...options }: ComponentOptions = {}) {\n options.shouldForwardProp ??= isFunction(el)\n shouldStyleProps ??= !isFunction(el)\n\n if (el === \"fragment\") el = Fragment\n\n if (shouldStyleProps || isString(el)) {\n const ProxyComponent = styled(el as As, options)\n\n ProxyComponent.displayName = \"ProxyComponent\"\n\n return ProxyComponent\n } else {\n el.displayName ??= \"ProxyComponent\"\n\n return el as FC<M>\n }\n}\n\nfunction withDisplayName<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n>(Component: FC<M>, displayName: string) {\n Object.defineProperty(Component, \"name\", { value: displayName })\n Object.defineProperty(Component, \"displayName\", { value: displayName })\n\n return Component as Component<Y, M>\n}\n\nfunction getSlotKey<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"unknown\"\n\n if (isArray(slot) || !isObject(slot)) {\n return toCamelCase(toArray(slot).join(\"-\"))\n } else {\n return toCamelCase(slot.name)\n }\n}\n\nfunction getSlotName<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"\"\n\n if (isArray(slot)) {\n return slot.map((value) => toPascalCase(value as string)).join(\"\")\n } else if (isObject(slot)) {\n return toPascalCase(slot.name)\n } else {\n return toPascalCase(slot as string)\n }\n}\n\nexport function createComponent<\n Y extends object = {},\n M extends ComponentStyle = Dict,\n D extends Dict = Dict,\n>(name: string, style?: M) {\n const defaultClassName = style?.className\n const defaultDisplayName = getDisplayName(name)\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${defaultDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${defaultDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(name?: string, className?: ClassName) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getClassName(name, defaultClassName)(system)\n\n return className\n }\n\n function useComponentProps<H extends Y = Y, R extends keyof H = keyof H>(\n props: H,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= defaultClassName\n className ??= getClassName(name)(system)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext ? mergeProps(contextProps, props)() : props\n const [, rest] = useComponentStyle(mergedProps, {\n name,\n className,\n style,\n transferProps,\n })\n\n return rest\n }\n\n function component<D extends AsWithFragment = \"div\", H extends Dict = Y>(\n el: D | FC<H>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperProps<H>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps<any>(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withContext<\n D extends AsWithFragment = \"div\",\n H extends Y = Y,\n R extends keyof H = keyof H,\n >(\n el: D | FC<WithoutThemeProps<H, M, R>>,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<R> = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperWithoutThemeProps<H, M, R>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useComponentProps(computedProps, {\n className,\n withContext,\n transferProps,\n })\n const rest = chainProps<any>(...toArray(superProps))()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n useComponentContext,\n usePropsContext,\n withContext,\n useComponentProps,\n }\n}\n\nexport function createSlotComponent<\n Y extends object = {},\n M extends ComponentSlotStyle = Dict,\n D extends Dict = Dict,\n>(rootName: string, style?: M) {\n const rootClassName = style?.className\n const rootDisplayName = getDisplayName(rootName)\n const classNameMap = new Map<string, classNameOptions>()\n const [StyleContext, useStyleContext] = createContext<\n CSSSlotObject<ComponentSlotName<M>>\n >({\n name: `${rootDisplayName}StyleContext`,\n })\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${rootDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${rootDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(\n slot?: ComponentSlot<ComponentSlotName<M>>,\n className?: ClassName,\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return className\n }\n\n function useClassNames() {\n const system = useSystem()\n const entries = classNameMap.entries().map(([key, { className, slot }]) => {\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return [key, className]\n })\n\n return Object.fromEntries(\n entries.filter(([_, className]) => className),\n ) as { [key: string]: string }\n }\n\n function useRootComponentProps<\n Y extends Dict = Dict,\n R extends keyof Y = keyof Y,\n >(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ): [\n CSSSlotObject,\n Merge<WithoutThemeProps<Y, M, R>, { css?: CSSObject | CSSObject[] }>,\n ] {\n className = useClassName(slot, className)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext ? mergeProps(contextProps, props)() : props\n const [css, rest] = useComponentSlotStyle(mergedProps, {\n name: rootName,\n className,\n style,\n slot,\n transferProps,\n })\n\n return [css, rest]\n }\n\n function useSlotComponentProps<Y extends Dict = Dict>(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { className }: Omit<UseComponentPropsOptions, \"transferProps\"> = {},\n ) {\n className = useClassName(slot, className)\n\n const style = useStyleContext()\n\n return {\n ...props,\n className: cx(className, props.className),\n css: mergeSlotCSS(slot, style, props.css),\n }\n }\n\n function component<H extends AsWithFragment = \"div\", R extends Dict = Dict>(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n className = useClassName(slot, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withProvider<\n H extends AsWithFragment = \"div\",\n R extends Y = Y,\n T extends keyof R = keyof R,\n >(\n el: FC<WithoutThemeProps<R, M, T>> | H,\n slot: ComponentSlot<ComponentSlotName<M>> = \"root\" as ComponentSlot<\n ComponentSlotName<M>\n >,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<T> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperWithoutThemeProps<R, M, T>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const [context, mergedProps] = useRootComponentProps(\n computedProps,\n slot,\n {\n className,\n withContext,\n transferProps,\n },\n )\n const rest = chainProps<any>(...superProps)()(mergedProps)\n\n return (\n <StyleContext value={context}>\n <ProxyComponent {...rest} />\n </StyleContext>\n )\n }, displayName)\n }\n }\n\n function withContext<\n H extends AsWithFragment = \"div\",\n R extends Dict = H extends DOMElement ? HTMLStyledProps<H> : Dict,\n >(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n name,\n className,\n withContext,\n ...options\n }: Omit<ComponentWithContextOptions, \"transferProps\"> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useSlotComponentProps(computedProps, slot, {\n className,\n withContext,\n })\n const rest = chainProps(...superProps)()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n StyleContext,\n useClassNames,\n useComponentContext,\n usePropsContext,\n useStyleContext,\n withContext,\n withProvider,\n useRootComponentProps,\n useSlotComponentProps,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA8FA,SAAS,qBAGP,IAAe,EAAE,kBAAkB,GAAG,YAA8B,EAAE,EAAE;AACxE,SAAQ,oDAAiC,GAAG;AAC5C,sBAAqB,+BAAY,GAAG;AAEpC,KAAI,OAAO,WAAY,MAAK;AAE5B,KAAI,gDAA6B,GAAG,EAAE;EACpC,MAAM,iBAAiB,OAAO,IAAU,QAAQ;AAEhD,iBAAe,cAAc;AAE7B,SAAO;Q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B,qBAAqB,IAAI,QAAQ;EACxD,MAAM,UAAU,WAAW,KAAK;EAEhC,MAAM,cAAc,eAAe,MAAM,GAAG,kBAD3B,YAAY,KAAK,GACuC;AAEzE,eAAa,IAAI,SAAS;GAAE;GAAW;GAAM,CAAC;AAE9C,SAAO,SACL,cACA,GAAG,YACH;AACA,UAAO,iBAAuB,UAAU;IAItC,MAAM,cAAc,oDAHa,aAAa,GAC1C,aAAa,MAAM,GACnB,WAAW,gBAAgB,EAAE,EAAE,MAAM,EAAE,EACc,MAAM;KAC7D;KACA;KACD,CAAC;AAGF,WAAO,oBAAC,kBAAe,GAFV,WAAW,GAAG,WAAW,EAAE,CAAC,YAAY,GAElB;MAClC,YAAY;;;AAInB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"create-component.js","names":["createContext","name","withContext","style"],"sources":["../../../../src/core/components/create-component.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, FunctionComponent } from \"react\"\nimport type { AnyString, Dict, Merge } from \"../../utils\"\nimport type { CSSObject, CSSSlotObject } from \"../css\"\nimport type {\n ComponentSlotStyle,\n ComponentStyle,\n StyledOptions,\n System,\n WithoutThemeProps,\n} from \"../system\"\nimport type {\n As,\n DOMElement,\n HTMLStyledProps,\n Component as OriginalComponent,\n} from \"./index.types\"\nimport { Fragment } from \"react\"\nimport {\n createContext,\n cx,\n isArray,\n isFunction,\n isObject,\n isString,\n runIfFn,\n toArray,\n toCamelCase,\n toPascalCase,\n} from \"../../utils\"\nimport { styled, useSystem } from \"../system\"\nimport { chainProps, mergeProps } from \"./props\"\nimport {\n getSlotClassName,\n mergeSlotCSS,\n useComponentSlotStyle,\n useComponentStyle,\n} from \"./use-component-style\"\nimport { getClassName, getDisplayName } from \"./utils\"\n\ntype AsWithFragment = \"fragment\" | As\ntype ClassName = ((system: System) => string) | string\n\ntype Component<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n> = Y extends \"fragment\"\n ? FunctionComponent<M>\n : OriginalComponent<Exclude<Y, \"fragment\">, M>\n\nexport type ComponentSlotName<\n Y extends ComponentSlotStyle | ComponentStyle = ComponentSlotStyle,\n> = AnyString | Extract<keyof NonNullable<Y[\"base\"]>, string>\n\nexport type ComponentSlot<Y extends string> =\n | [Y, Y]\n | Y\n | { name: string; slot: [Y, Y] | Y }\n\nexport type InitialProps<Y extends Dict = Dict> =\n | ((props: Y) => any)\n | Partial<Y>\nexport type SuperProps<Y extends Dict = Dict> = ((props: Y) => any) | Y\n\nexport type SuperWithoutThemeProps<\n Y extends Dict = Dict,\n M extends Dict = Dict,\n D extends keyof Y = keyof Y,\n> = ((props: WithoutThemeProps<Y, M, D>) => any) | WithoutThemeProps<Y, M, D>\n\nexport interface UseComponentPropsOptions<\n Y extends number | string | symbol = string,\n> {\n className?: ClassName\n withContext?: boolean\n transferProps?: Y[]\n}\n\nexport interface ComponentOptions extends Omit<StyledOptions, \"transferProps\"> {\n className?: ClassName\n shouldStyleProps?: boolean\n}\n\ninterface classNameOptions<Y extends string = string> {\n className?: ClassName\n slot?: ComponentSlot<Y>\n}\n\nexport interface ComponentWithContextOptions<\n Y extends number | string | symbol = string,\n>\n extends ComponentOptions, UseComponentPropsOptions<Y> {}\n\nfunction createProxyComponent<\n Y extends AsWithFragment = \"div\",\n M extends Dict = Dict,\n>(el: FC<M> | Y, { shouldStyleProps, ...options }: ComponentOptions = {}) {\n options.shouldForwardProp ??= isFunction(el)\n shouldStyleProps ??= !isFunction(el)\n\n if (el === \"fragment\") el = Fragment\n\n if (shouldStyleProps || isString(el)) {\n const ProxyComponent = styled(el as As, options)\n\n ProxyComponent.displayName = \"ProxyComponent\"\n\n return ProxyComponent\n } else {\n el.displayName ??= \"ProxyComponent\"\n\n return el as FC<M>\n }\n}\n\nfunction withDisplayName<\n Y extends AsWithFragment = AsWithFragment,\n M extends object = {},\n>(Component: FC<M>, displayName: string) {\n Object.defineProperty(Component, \"name\", { value: displayName })\n Object.defineProperty(Component, \"displayName\", { value: displayName })\n\n return Component as Component<Y, M>\n}\n\nfunction getSlotKey<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"unknown\"\n\n if (isArray(slot) || !isObject(slot)) {\n return toCamelCase(toArray(slot).join(\"-\"))\n } else {\n return toCamelCase(slot.name)\n }\n}\n\nfunction getSlotName<Y extends string>(slot?: ComponentSlot<Y>) {\n if (!slot) return \"\"\n\n if (isArray(slot)) {\n return slot.map((value) => toPascalCase(value as string)).join(\"\")\n } else if (isObject(slot)) {\n return toPascalCase(slot.name)\n } else {\n return toPascalCase(slot as string)\n }\n}\n\nexport function createComponent<\n Y extends object = {},\n M extends ComponentStyle = Dict,\n D extends Dict = Dict,\n>(name: string, style?: M) {\n const defaultClassName = style?.className\n const defaultDisplayName = getDisplayName(name)\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${defaultDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${defaultDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(name?: string, className?: ClassName) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getClassName(name, defaultClassName)(system)\n\n return className\n }\n\n function useComponentProps<H extends Y = Y, R extends keyof H = keyof H>(\n props: H,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= defaultClassName\n className ??= getClassName(name)(system)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext\n ? (mergeProps(contextProps, props)() as H)\n : props\n const [, rest] = useComponentStyle(mergedProps, {\n name,\n className,\n style,\n transferProps,\n })\n\n return rest\n }\n\n function component<D extends AsWithFragment = \"div\", H extends Dict = Y>(\n el: D | FC<H>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperProps<H>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps<any>(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withContext<\n D extends AsWithFragment = \"div\",\n H extends Y = Y,\n R extends keyof H = keyof H,\n >(\n el: D | FC<WithoutThemeProps<H, M, R>>,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<R> = {},\n ) {\n const displayName = getDisplayName(name, defaultDisplayName)\n const ProxyComponent = createProxyComponent(el, options)\n\n return function (\n initialProps?: InitialProps<H>,\n ...superProps: SuperWithoutThemeProps<H, M, R>[]\n ) {\n return withDisplayName<D, H>((props) => {\n className = useClassName(name, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useComponentProps(computedProps, {\n className,\n withContext,\n transferProps,\n })\n const rest = chainProps<any>(...toArray(superProps))()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n useComponentContext,\n usePropsContext,\n withContext,\n useComponentProps,\n }\n}\n\nexport function createSlotComponent<\n Y extends object = {},\n M extends ComponentSlotStyle = Dict,\n D extends Dict = Dict,\n>(rootName: string, style?: M) {\n const rootClassName = style?.className\n const rootDisplayName = getDisplayName(rootName)\n const classNameMap = new Map<string, classNameOptions>()\n const [StyleContext, useStyleContext] = createContext<\n CSSSlotObject<ComponentSlotName<M>>\n >({\n name: `${rootDisplayName}StyleContext`,\n })\n const [ComponentContext, useComponentContext] = createContext<D>({\n name: `${rootDisplayName}Context`,\n })\n const [PropsContext, usePropsContext] = createContext<Partial<Y>>({\n name: `${rootDisplayName}PropsContext`,\n strict: false,\n })\n\n function useClassName(\n slot?: ComponentSlot<ComponentSlotName<M>>,\n className?: ClassName,\n ) {\n const system = useSystem()\n\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return className\n }\n\n function useClassNames() {\n const system = useSystem()\n const entries = classNameMap.entries().map(([key, { className, slot }]) => {\n className = runIfFn(className, system)\n className ??= getSlotClassName(\n rootClassName ?? getClassName(rootName)(system),\n slot,\n )\n\n return [key, className]\n })\n\n return Object.fromEntries(\n entries.filter(([_, className]) => className),\n ) as { [key: string]: string }\n }\n\n function useRootComponentProps<\n Y extends Dict = {},\n R extends keyof Y = keyof Y,\n >(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n className,\n withContext = true,\n transferProps,\n }: UseComponentPropsOptions<R> = {},\n ): [\n CSSSlotObject,\n Merge<WithoutThemeProps<Y, M, R>, { css?: CSSObject | CSSObject[] }>,\n ] {\n className = useClassName(slot, className)\n\n const contextProps = usePropsContext() ?? {}\n const mergedProps = withContext\n ? (mergeProps(contextProps, props)() as Y)\n : props\n const [css, rest] = useComponentSlotStyle(mergedProps, {\n name: rootName,\n className,\n style,\n slot,\n transferProps,\n })\n\n return [css, rest]\n }\n\n function useSlotComponentProps<Y extends Dict = {}>(\n props: Y,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { className }: Omit<UseComponentPropsOptions, \"transferProps\"> = {},\n ) {\n className = useClassName(slot, className)\n\n const style = useStyleContext()\n\n return {\n ...props,\n className: cx(className, props.className),\n css: mergeSlotCSS(slot, style, props.css),\n }\n }\n\n function component<H extends AsWithFragment = \"div\", R extends Dict = Dict>(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n { name, className, ...options }: ComponentOptions = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n className = useClassName(slot, className)\n\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = chainProps(...superProps)()(computedProps)\n\n return (\n <ProxyComponent\n {...mergedProps}\n className={cx(className, mergedProps.className)}\n />\n )\n }, displayName)\n }\n }\n\n function withProvider<\n H extends AsWithFragment = \"div\",\n R extends Y = Y,\n T extends keyof R = keyof R,\n >(\n el: FC<WithoutThemeProps<R, M, T>> | H,\n slot: ComponentSlot<ComponentSlotName<M>> = \"root\" as ComponentSlot<\n ComponentSlotName<M>\n >,\n {\n name,\n className,\n withContext,\n transferProps,\n ...options\n }: ComponentWithContextOptions<T> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperWithoutThemeProps<R, M, T>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const [context, mergedProps] = useRootComponentProps(\n computedProps,\n slot,\n {\n className,\n withContext,\n transferProps,\n },\n )\n const rest = chainProps<any>(...superProps)()(mergedProps)\n\n return (\n <StyleContext value={context}>\n <ProxyComponent {...rest} />\n </StyleContext>\n )\n }, displayName)\n }\n }\n\n function withContext<\n H extends AsWithFragment = \"div\",\n R extends Dict = H extends DOMElement ? HTMLStyledProps<H> : Dict,\n >(\n el: FC<R> | H,\n slot?: ComponentSlot<ComponentSlotName<M>>,\n {\n name,\n className,\n withContext,\n ...options\n }: Omit<ComponentWithContextOptions, \"transferProps\"> = {},\n ) {\n const ProxyComponent = createProxyComponent(el, options)\n const slotKey = getSlotKey(slot)\n const slotName = getSlotName(slot)\n const displayName = getDisplayName(name, `${rootDisplayName}${slotName}`)\n\n classNameMap.set(slotKey, { className, slot })\n\n return function (\n initialProps?: InitialProps<R>,\n ...superProps: SuperProps<R>[]\n ) {\n return withDisplayName<H, R>((props) => {\n const computedProps = isFunction(initialProps)\n ? initialProps(props)\n : mergeProps(initialProps ?? {}, props)()\n const mergedProps = useSlotComponentProps(computedProps, slot, {\n className,\n withContext,\n })\n const rest = chainProps(...superProps)()(mergedProps)\n\n return <ProxyComponent {...rest} />\n }, displayName)\n }\n }\n\n return {\n component,\n ComponentContext,\n PropsContext,\n StyleContext,\n useClassNames,\n useComponentContext,\n usePropsContext,\n useStyleContext,\n withContext,\n withProvider,\n useRootComponentProps,\n useSlotComponentProps,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA8FA,SAAS,qBAGP,IAAe,EAAE,kBAAkB,GAAG,YAA8B,EAAE,EAAE;AACxE,SAAQ,oDAAiC,GAAG;AAC5C,sBAAqB,+BAAY,GAAG;AAEpC,KAAI,OAAO,WAAY,MAAK;AAE5B,KAAI,gDAA6B,GAAG,EAAE;EACpC,MAAM,iBAAiB,OAAO,IAAU,QAAQ;AAEhD,iBAAe,cAAc;AAE7B,SAAO;QACF;AACL,KAAG,gBAAgB;AAEnB,SAAO;;;AAIX,SAAS,gBAGP,WAAkB,aAAqB;AACvC,QAAO,eAAe,WAAW,QAAQ,EAAE,OAAO,aAAa,CAAC;AAChE,QAAO,eAAe,WAAW,eAAe,EAAE,OAAO,aAAa,CAAC;AAEvE,QAAO;;AAGT,SAAS,WAA6B,MAAyB;AAC7D,KAAI,CAAC,KAAM,QAAO;AAElB,gCAAY,KAAK,IAAI,6BAAU,KAAK,CAClC,kEAA2B,KAAK,CAAC,KAAK,IAAI,CAAC;KAE3C,uCAAmB,KAAK,KAAK;;AAIjC,SAAS,YAA8B,MAAyB;AAC9D,KAAI,CAAC,KAAM,QAAO;AAElB,gCAAY,KAAK,CACf,QAAO,KAAK,KA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EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -22,6 +22,7 @@ function mergeProps(...args) {
22
22
  return function({ mergeClassName = true, mergeCSS = true, mergeEvent = true, mergeRef = true, mergeStyle = true } = {}) {
23
23
  let result = {};
24
24
  for (const props of args) {
25
+ if ((0, utils_exports.isUndefined)(props)) continue;
25
26
  for (const key in result) {
26
27
  if (mergeRef && key === "ref") {
27
28
  result[key] = mergeRefs(result[key], props[key]);
@@ -1 +1 @@
1
- {"version":3,"file":"props.js","names":["result: Dict"],"sources":["../../../../src/core/components/props.ts"],"sourcesContent":["import type { Dict, Merge } from \"../../utils\"\nimport { useMemo } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport {\n cx,\n handlerAll,\n isArray,\n isEmptyObject,\n isFunction,\n isObject,\n isUndefined,\n merge,\n mergeRefs,\n omitObject,\n splitObject,\n} from \"../../utils\"\nimport { conditionProperties, styleProperties } from \"../css\"\n\ntype MergeAll<Y extends Dict[]> = Y extends [infer M]\n ? M\n : Y extends [infer D, ...infer H]\n ? H extends any[]\n ? Merge<D, MergeAll<H>>\n : D\n : never\n\nfunction isEvent(key: string) {\n return /^on[A-Z]/.test(key)\n}\n\nexport const cssProps = new Set<string>([\n ...conditionProperties,\n ...styleProperties,\n])\n\nexport type ShouldForwardProp = (prop: string) => boolean\n\nexport function createShouldForwardProp(\n forwardProps: string[] = [],\n): ShouldForwardProp {\n return function (prop: string): boolean {\n if (forwardProps.includes(prop)) return true\n\n if (prop.startsWith(\"--\")) return false\n\n return !cssProps.has(prop)\n }\n}\n\ninterface MergePropsOptions {\n mergeClassName?: boolean\n mergeCSS?: boolean\n mergeEvent?: boolean\n mergeRef?: boolean\n mergeStyle?: boolean\n}\n\nexport function mergeProps<Y extends Dict[]>(...args: Y) {\n return function ({\n mergeClassName = true,\n mergeCSS = true,\n mergeEvent = true,\n mergeRef = true,\n mergeStyle = true,\n }: MergePropsOptions = {}): MergeAll<Y> {\n let result: Dict = {}\n\n for (const props of args) {\n for (const key in result) {\n if (mergeRef && key === \"ref\") {\n result[key] = mergeRefs(result[key], props[key])\n\n continue\n }\n\n if (\n mergeEvent &&\n isEvent(key) &&\n isFunction(result[key]) &&\n isFunction(props[key])\n ) {\n result[key] = handlerAll(result[key], props[key])\n\n continue\n }\n\n if (mergeClassName && (key === \"className\" || key === \"class\")) {\n result[key] = cx(result[key], props[key])\n\n continue\n }\n\n if (mergeStyle && key === \"style\") {\n result[key] = merge(result[key] ?? {}, props[key] ?? {})\n\n continue\n }\n\n if (mergeCSS && key === \"css\") {\n if (isArray(result[key])) {\n result[key].push(props[key])\n } else {\n result[key] ??= []\n\n result[key] = [result[key], props[key]]\n }\n\n continue\n }\n\n result[key] = !isUndefined(props[key]) ? props[key] : result[key]\n }\n\n for (const key in props) {\n if (isUndefined(result[key])) result[key] = props[key]\n }\n }\n\n return result as any\n }\n}\n\ntype CallbackProps<Y extends Dict = Dict> = (props: Y) => Y\n\ntype PropsOrCallback<Y extends Dict = Dict> = CallbackProps<Y> | Y\n\nexport function chainProps<Y extends Dict = Dict>(\n ...props: PropsOrCallback<Y>[]\n) {\n return function (options: MergePropsOptions = {}) {\n if (!props.length) return (a: Y) => a\n\n if (props.length === 1)\n return function (b: Y) {\n const a = props[0] ?? {}\n const c = isFunction(a) ? a(b) : mergeProps(a, b)(options)\n\n return c\n } as CallbackProps<Y>\n\n return props.reduce(function (a, b) {\n return function (c: Y = {} as Y) {\n const d = isFunction(a) ? a(c) : mergeProps(a, c)(options)\n const f = isFunction(b) ? b(d) : mergeProps(b, d)(options)\n\n return f\n }\n }) as CallbackProps<Y>\n }\n}\n\nexport function isEqualProps<\n Y extends Dict,\n M extends Dict,\n D extends keyof M | keyof Y,\n>(a: Y, b: M, omitKeys: D[] = []) {\n return isEqual(\n omitObject(a, omitKeys as (keyof Y)[]),\n omitObject(b, omitKeys as (keyof M)[]),\n )\n}\n\nexport function useSplitProps<Y extends Dict, M extends keyof Y>(\n props: Y,\n keys: M[] | readonly M[],\n) {\n return useMemo(() => splitObject<Y, M>(props, keys), [props, keys])\n}\n\nexport function extractProps(props: Dict, keys: readonly string[] | string[]) {\n let result: Dict = {}\n\n Object.entries(props).forEach(([key, value]) => {\n if (!cssProps.has(key)) return\n\n if (keys.includes(key)) {\n result = merge(result, { [key]: value })\n } else if (isObject(value)) {\n value = extractProps(value, keys)\n\n if (isEmptyObject(value)) return\n\n result = merge(result, { [key]: value })\n }\n })\n\n return result\n}\n\nexport function useExtractProps(\n props: Dict,\n keys: readonly string[] | string[],\n) {\n return useMemo(() => extractProps(props, keys), [props, keys])\n}\n"],"mappings":";;;;;;;;;AA0BA,SAAS,QAAQ,KAAa;AAC5B,QAAO,WAAW,KAAK,IAAI;;AAG7B,MAAa,WAAW,IAAI,IAAY,CACtC,GAAG,qBACH,GAAG,gBACJ,CAAC;AAIF,SAAgB,wBACd,eAAyB,EAAE,EACR;AACnB,QAAO,SAAU,MAAuB;AACtC,MAAI,aAAa,SAAS,KAAK,CAAE,QAAO;AAExC,MAAI,KAAK,WAAW,KAAK,CAAE,QAAO;AAElC,SAAO,CAAC,SAAS,IAAI,KAAK;;;AAY9B,SAAgB,WAA6B,GAAG,MAAS;AACvD,QAAO,SAAU,EACf,iBAAiB,MACjB,WAAW,MACX,aAAa,MACb,WAAW,MACX,aAAa,SACQ,EAAE,EAAe;EACtC,IAAIA,SAAe,EAAE;AAErB,OAAK,MAAM,SAAS,MAAM;AACxB,QAAK,MAAM,OAAO,QAAQ;AACxB,QAAI,YAAY,QAAQ,OAAO;AAC7B,YAAO,OAAO,UAAU,OAAO,MAAM,MAAM,KAAK;AAEhD;;AAGF,QACE,cACA,QAAQ,IAAI,kCACD,OAAO,KAAK,kCACZ,MAAM,KAAK,EACtB;AACA,YAAO,qCAAkB,OAAO,MAAM,MAAM,KAAK;AAEjD;;AAGF,QAAI,mBAAmB,QAAQ,eAAe,QAAQ,UAAU;AAC9D,YAAO,6BAAU,OAAO,MAAM,MAAM,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,EAAE;AAErB,QAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,KAAK,WAAW;AAC9C,MAAI,CAAC,SAAS,IAAI,IAAI,CAAE;AAExB,MAAI,KAAK,SAAS,IAAI,CACpB,mCAAe,QAAQ,GAAG,MAAM,OAAO,CAAC;uCACtB,MAAM,EAAE;AAC1B,WAAQ,aAAa,OAAO,KAAK;AAEjC,wCAAkB,MAAM,CAAE;AAE1B,qCAAe,QAAQ,GAAG,MAAM,OAAO,CAAC;;GAE1C;AAEF,QAAO;;AAGT,SAAgB,gBACd,OACA,MACA;AACA,QAAO,cAAc,aAAa,OAAO,KAAK,EAAE,CAAC,OAAO,KAAK,CAAC"}
1
+ {"version":3,"file":"props.js","names":["result: Dict"],"sources":["../../../../src/core/components/props.ts"],"sourcesContent":["import type { Dict, Merge } from \"../../utils\"\nimport { useMemo } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport {\n cx,\n handlerAll,\n isArray,\n isEmptyObject,\n isFunction,\n isObject,\n isUndefined,\n merge,\n mergeRefs,\n omitObject,\n splitObject,\n} from \"../../utils\"\nimport { conditionProperties, styleProperties } from \"../css\"\n\ntype Optionalize<Y> = [Extract<Y, undefined>] extends [never]\n ? Y\n : Partial<Exclude<Y, undefined>>\n\ntype MergeAll<Y extends (Dict | undefined)[]> = Y extends [infer M]\n ? Optionalize<M>\n : Y extends [infer D, ...infer H]\n ? H extends (Dict | undefined)[]\n ? Merge<Optionalize<D>, MergeAll<H>>\n : Optionalize<D>\n : never\n\nfunction isEvent(key: string) {\n return /^on[A-Z]/.test(key)\n}\n\nexport const cssProps = new Set<string>([\n ...conditionProperties,\n ...styleProperties,\n])\n\nexport type ShouldForwardProp = (prop: string) => boolean\n\nexport function createShouldForwardProp(\n forwardProps: string[] = [],\n): ShouldForwardProp {\n return function (prop: string): boolean {\n if (forwardProps.includes(prop)) return true\n\n if (prop.startsWith(\"--\")) return false\n\n return !cssProps.has(prop)\n }\n}\n\ninterface MergePropsOptions {\n mergeClassName?: boolean\n mergeCSS?: boolean\n mergeEvent?: boolean\n mergeRef?: boolean\n mergeStyle?: boolean\n}\n\nexport function mergeProps<Y extends Dict>(\n ...args: Y[]\n): (options?: MergePropsOptions) => Y\nexport function mergeProps<Y extends (Dict | undefined)[]>(\n ...args: Y\n): (options?: MergePropsOptions) => MergeAll<Y>\nexport function mergeProps(...args: (Dict | undefined)[]) {\n return function ({\n mergeClassName = true,\n mergeCSS = true,\n mergeEvent = true,\n mergeRef = true,\n mergeStyle = true,\n }: MergePropsOptions = {}) {\n let result: Dict = {}\n\n for (const props of args) {\n if (isUndefined(props)) continue\n\n for (const key in result) {\n if (mergeRef && key === \"ref\") {\n result[key] = mergeRefs(result[key], props[key])\n\n continue\n }\n\n if (\n mergeEvent &&\n isEvent(key) &&\n isFunction(result[key]) &&\n isFunction(props[key])\n ) {\n result[key] = handlerAll(result[key], props[key])\n\n continue\n }\n\n if (mergeClassName && (key === \"className\" || key === \"class\")) {\n result[key] = cx(result[key], props[key])\n\n continue\n }\n\n if (mergeStyle && key === \"style\") {\n result[key] = merge(result[key] ?? {}, props[key] ?? {})\n\n continue\n }\n\n if (mergeCSS && key === \"css\") {\n if (isArray(result[key])) {\n result[key].push(props[key])\n } else {\n result[key] ??= []\n\n result[key] = [result[key], props[key]]\n }\n\n continue\n }\n\n result[key] = !isUndefined(props[key]) ? props[key] : result[key]\n }\n\n for (const key in props) {\n if (isUndefined(result[key])) result[key] = props[key]\n }\n }\n\n return result as any\n }\n}\n\ntype CallbackProps<Y extends Dict = Dict> = (props: Y) => Y\n\ntype PropsOrCallback<Y extends Dict = Dict> = CallbackProps<Y> | Y\n\nexport function chainProps<Y extends Dict = Dict>(\n ...props: PropsOrCallback<Y>[]\n) {\n return function (options: MergePropsOptions = {}) {\n if (!props.length) return (a: Y) => a\n\n if (props.length === 1)\n return function (b: Y) {\n const a = props[0] ?? {}\n const c = isFunction(a) ? a(b) : mergeProps(a, b)(options)\n\n return c\n } as CallbackProps<Y>\n\n return props.reduce(function (a, b) {\n return function (c: Y = {} as Y) {\n const d = isFunction(a) ? a(c) : mergeProps(a, c)(options)\n const f = isFunction(b) ? b(d) : mergeProps(b, d)(options)\n\n return f\n }\n }) as CallbackProps<Y>\n }\n}\n\nexport function isEqualProps<\n Y extends Dict,\n M extends Dict,\n D extends keyof M | keyof Y,\n>(a: Y, b: M, omitKeys: D[] = []) {\n return isEqual(\n omitObject(a, omitKeys as (keyof Y)[]),\n omitObject(b, omitKeys as (keyof M)[]),\n )\n}\n\nexport function useSplitProps<Y extends Dict, M extends keyof Y>(\n props: Y,\n keys: M[] | readonly M[],\n) {\n return useMemo(() => splitObject<Y, M>(props, keys), [props, keys])\n}\n\nexport function extractProps(props: Dict, keys: readonly string[] | string[]) {\n let result: Dict = {}\n\n Object.entries(props).forEach(([key, value]) => {\n if (!cssProps.has(key)) return\n\n if (keys.includes(key)) {\n result = merge(result, { [key]: value })\n } else if (isObject(value)) {\n value = extractProps(value, keys)\n\n if (isEmptyObject(value)) return\n\n result = merge(result, { [key]: value })\n }\n })\n\n return result\n}\n\nexport function useExtractProps(\n props: Dict,\n keys: readonly string[] | string[],\n) {\n return useMemo(() => extractProps(props, keys), [props, keys])\n}\n"],"mappings":";;;;;;;;;AA8BA,SAAS,QAAQ,KAAa;AAC5B,QAAO,WAAW,KAAK,IAAI;;AAG7B,MAAa,WAAW,IAAI,IAAY,CACtC,GAAG,qBACH,GAAG,gBACJ,CAAC;AAIF,SAAgB,wBACd,eAAyB,EAAE,EACR;AACnB,QAAO,SAAU,MAAuB;AACtC,MAAI,aAAa,SAAS,KAAK,CAAE,QAAO;AAExC,MAAI,KAAK,WAAW,KAAK,CAAE,QAAO;AAElC,SAAO,CAAC,SAAS,IAAI,KAAK;;;AAkB9B,SAAgB,WAAW,GAAG,MAA4B;AACxD,QAAO,SAAU,EACf,iBAAiB,MACjB,WAAW,MACX,aAAa,MACb,WAAW,MACX,aAAa,SACQ,EAAE,EAAE;EACzB,IAAIA,SAAe,EAA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AAE,EAAE,GAAG,WAAW,GAAG,EAAE,CAAC,QAAQ;AAG1D,yCAFqB,EAAE,GAAG,EAAE,EAAE,GAAG,WAAW,GAAG,EAAE,CAAC,QAAQ;;IAI5D;;;AAIN,SAAgB,aAId,GAAM,GAAM,WAAgB,EAAE,EAAE;AAChC,QAAO,sCACM,GAAG,SAAwB,gCAC3B,GAAG,SAAwB,CACvC;;AAGH,SAAgB,cACd,OACA,MACA;AACA,QAAO,6CAAgC,OAAO,KAAK,EAAE,CAAC,OAAO,KAAK,CAAC;;AAGrE,SAAgB,aAAa,OAAa,MAAoC;CAC5E,IAAIA,SAAe,EAAE;AAErB,QAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,KAAK,WAAW;AAC9C,MAAI,CAAC,SAAS,IAAI,IAAI,CAAE;AAExB,MAAI,KAAK,SAAS,IAAI,CACpB,mCAAe,QAAQ,GAAG,MAAM,OAAO,CAAC;uCACtB,MAAM,EAAE;AAC1B,WAAQ,aAAa,OAAO,KAAK;AAEjC,wCAAkB,MAAM,CAAE;AAE1B,qCAAe,QAAQ,GAAG,MAAM,OAAO,CAAC;;GAE1C;AAEF,QAAO;;AAGT,SAAgB,gBACd,OACA,MACA;AACA,QAAO,cAAc,aAAa,OAAO,KAAK,EAAE,CAAC,OAAO,KAAK,CAAC"}
@@ -3,13 +3,11 @@ import { ThemeProps } from "../../core/system/index.types.js";
3
3
  import { Component, HTMLStyledProps } from "../../core/components/index.types.js";
4
4
  import "../../core/index.js";
5
5
  import { WithTransitionProps } from "../motion/index.types.js";
6
- import "../motion/index.js";
7
6
  import { CollapseProps } from "../collapse/collapse.js";
8
- import "../collapse/index.js";
9
7
  import "../../index.js";
10
8
  import { AccordionStyle } from "./accordion.style.js";
11
9
  import { UseAccordionItemProps, UseAccordionProps } from "./use-accordion.js";
12
- import * as react184 from "react";
10
+ import * as react26 from "react";
13
11
 
14
12
  //#region src/components/accordion/accordion.d.ts
15
13
  interface AccordionCallBackProps {
@@ -33,7 +31,7 @@ interface AccordionRootProps extends Omit<HTMLStyledProps, "onChange">, ThemePro
33
31
  */
34
32
  items?: AccordionItem[];
35
33
  }
36
- declare const AccordionPropsContext: react184.Context<Partial<AccordionRootProps> | undefined>, useAccordionPropsContext: () => Partial<AccordionRootProps> | undefined;
34
+ declare const AccordionPropsContext: react26.Context<Partial<AccordionRootProps> | undefined>, useAccordionPropsContext: () => Partial<AccordionRootProps> | undefined;
37
35
  /**
38
36
  * `Accordion` is a component for a list that displays information in an expandable or collapsible manner.
39
37
  *
@@ -3,7 +3,7 @@ import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/
3
3
  import "../../index.js";
4
4
 
5
5
  //#region src/components/accordion/accordion.style.d.ts
6
- declare const accordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "root" | "item", CSSPropObject<CSSSlotObject<"button" | "panel" | "icon" | "root" | "item">>, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "root" | "item">>, {
6
+ declare const accordionStyle: ComponentSlotStyle<"button" | "icon" | "panel" | "item" | "root", CSSPropObject<CSSSlotObject<"button" | "icon" | "panel" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"button" | "icon" | "panel" | "item" | "root">>, {
7
7
  panel: {
8
8
  button: {
9
9
  rounded: "l2";
@@ -2,10 +2,10 @@ import { HTMLProps, PropGetter } from "../../core/components/index.types.js";
2
2
  import "../../core/index.js";
3
3
  import { Descendant } from "../../hooks/use-descendants/index.js";
4
4
  import "../../index.js";
5
- import * as react172 from "react";
5
+ import * as react27 from "react";
6
6
 
7
7
  //#region src/components/accordion/use-accordion.d.ts
8
- declare const AccordionDescendantsContext: react172.Context<{
8
+ declare const AccordionDescendantsContext: react27.Context<{
9
9
  active: (target?: HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null | undefined, options?: FocusOptions) => void;
10
10
  count: (props?: Partial<{}> | undefined) => number;
11
11
  destroy: () => void;
@@ -24,7 +24,7 @@ declare const AccordionDescendantsContext: react172.Context<{
24
24
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean, props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}> | undefined;
25
25
  register: (props?: {
26
26
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
27
- } | undefined) => react172.RefCallback<HTMLButtonElement>;
27
+ } | undefined) => react27.RefCallback<HTMLButtonElement>;
28
28
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
29
29
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
30
30
  values: (props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}>[];
@@ -50,12 +50,12 @@ declare const AccordionDescendantsContext: react172.Context<{
50
50
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean, props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}> | undefined;
51
51
  register: (props?: {
52
52
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
53
- } | undefined) => react172.RefCallback<HTMLButtonElement>;
53
+ } | undefined) => react27.RefCallback<HTMLButtonElement>;
54
54
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
55
55
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
56
56
  values: (props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}>[];
57
57
  };
58
- register: react172.RefCallback<HTMLButtonElement>;
58
+ register: react27.RefCallback<HTMLButtonElement>;
59
59
  }, useAccordionDescendants: () => {
60
60
  active: (target?: HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null | undefined, options?: FocusOptions) => void;
61
61
  count: (props?: Partial<{}> | undefined) => number;
@@ -75,15 +75,15 @@ declare const AccordionDescendantsContext: react172.Context<{
75
75
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean, props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}> | undefined;
76
76
  register: (props?: {
77
77
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
78
- } | undefined) => react172.RefCallback<HTMLButtonElement>;
78
+ } | undefined) => react27.RefCallback<HTMLButtonElement>;
79
79
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
80
80
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
81
81
  values: (props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}>[];
82
82
  };
83
83
  interface AccordionContext extends Omit<UseAccordionReturn, "descendants" | "getRootProps"> {}
84
- declare const AccordionContext: react172.Context<AccordionContext>, useAccordionContext: () => AccordionContext;
84
+ declare const AccordionContext: react27.Context<AccordionContext>, useAccordionContext: () => AccordionContext;
85
85
  interface AccordionItemContext extends Omit<UseAccordionItemReturn, "getItemProps"> {}
86
- declare const AccordionItemContext: react172.Context<AccordionItemContext>, useAccordionItemContext: () => AccordionItemContext;
86
+ declare const AccordionItemContext: react27.Context<AccordionItemContext>, useAccordionItemContext: () => AccordionItemContext;
87
87
  interface UseAccordionProps extends Omit<HTMLProps, "onChange"> {
88
88
  /**
89
89
  * The initial index(es) of the accordion item to expand.
@@ -137,7 +137,7 @@ declare const useAccordion: ({
137
137
  prevValue: (indexOrNode: number | HTMLButtonElement | Descendant<HTMLButtonElement, {}> | null, loop?: boolean, props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}> | undefined;
138
138
  register: (props?: {
139
139
  disabled?: boolean | ((node: HTMLButtonElement) => boolean) | undefined;
140
- } | undefined) => react172.RefCallback<HTMLButtonElement>;
140
+ } | undefined) => react27.RefCallback<HTMLButtonElement>;
141
141
  unregister: (node?: HTMLButtonElement | null | undefined) => void;
142
142
  value: (indexOrNode: number | HTMLButtonElement | null) => Descendant<HTMLButtonElement, {}> | undefined;
143
143
  values: (props?: Partial<{}> | undefined) => Descendant<HTMLButtonElement, {}>[];
@@ -145,8 +145,8 @@ declare const useAccordion: ({
145
145
  focusedIndex: number;
146
146
  index: number | number[];
147
147
  multiple: boolean | undefined;
148
- setFocusedIndex: react172.Dispatch<react172.SetStateAction<number>>;
149
- setIndex: react172.Dispatch<react172.SetStateAction<number | number[]>>;
148
+ setFocusedIndex: react27.Dispatch<react27.SetStateAction<number>>;
149
+ setIndex: react27.Dispatch<react27.SetStateAction<number | number[]>>;
150
150
  toggle: boolean | undefined;
151
151
  getRootProps: PropGetter<"div", undefined, undefined>;
152
152
  };
@@ -3,9 +3,8 @@ import { Component } from "../../core/components/index.types.js";
3
3
  import "../../core/index.js";
4
4
  import { AiryStyle } from "./airy.style.js";
5
5
  import { HTMLMotionProps } from "../motion/index.types.js";
6
- import "../motion/index.js";
7
6
  import "../../index.js";
8
- import * as react185 from "react";
7
+ import * as react1031 from "react";
9
8
  import { ReactNode } from "react";
10
9
 
11
10
  //#region src/components/airy/airy.d.ts
@@ -57,7 +56,7 @@ interface AiryProps extends Omit<HTMLMotionProps<"button">, "onChange">, ThemePr
57
56
  */
58
57
  onChange?: (value: KeyframeIdent) => void;
59
58
  }
60
- declare const AiryPropsContext: react185.Context<Partial<AiryProps> | undefined>, useAiryPropsContext: () => Partial<AiryProps> | undefined;
59
+ declare const AiryPropsContext: react1031.Context<Partial<AiryProps> | undefined>, useAiryPropsContext: () => Partial<AiryProps> | undefined;
61
60
  /**
62
61
  * `Airy` is a component that creates an airy animation, switching between two elements when one is clicked.
63
62
  *
@@ -3,13 +3,10 @@ import { Component, HTMLStyledProps } from "../../core/components/index.types.js
3
3
  import "../../core/index.js";
4
4
  import { AlertStyle } from "./alert.style.js";
5
5
  import { IconProps } from "../icon/icon.js";
6
- import "../icon/index.js";
7
6
  import { LoadingProps } from "../loading/loading.js";
8
- import "../loading/index.js";
9
7
  import { StatusScheme } from "../status/status.js";
10
- import "../status/index.js";
11
8
  import "../../index.js";
12
- import * as react171 from "react";
9
+ import * as react1029 from "react";
13
10
 
14
11
  //#region src/components/alert/alert.d.ts
15
12
  interface AlertRootProps extends HTMLStyledProps, ThemeProps<AlertStyle> {
@@ -20,7 +17,7 @@ interface AlertRootProps extends HTMLStyledProps, ThemeProps<AlertStyle> {
20
17
  */
21
18
  status?: StatusScheme;
22
19
  }
23
- declare const AlertPropsContext: react171.Context<Partial<AlertRootProps> | undefined>, useAlertPropsContext: () => Partial<AlertRootProps> | undefined;
20
+ declare const AlertPropsContext: react1029.Context<Partial<AlertRootProps> | undefined>, useAlertPropsContext: () => Partial<AlertRootProps> | undefined;
24
21
  /**
25
22
  * `Alert` is a component that conveys information to the user.
26
23
  *
@@ -3,7 +3,7 @@ import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/
3
3
  import "../../index.js";
4
4
 
5
5
  //#region src/components/alert/alert.style.d.ts
6
- declare const alertStyle: ComponentSlotStyle<"title" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, CSSModifierObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, {
6
+ declare const alertStyle: ComponentSlotStyle<"title" | "icon" | "loading" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "icon" | "loading" | "root" | "description">>, CSSModifierObject<CSSSlotObject<"title" | "icon" | "loading" | "root" | "description">>, {
7
7
  island: {
8
8
  description: {
9
9
  color: "fg.muted";
@@ -3,9 +3,8 @@ import { Component } from "../../core/components/index.types.js";
3
3
  import "../../core/index.js";
4
4
  import { AlphaSliderStyle } from "./alpha-slider.style.js";
5
5
  import { HueSliderOverlayProps, HueSliderRootProps, HueSliderThumbProps, HueSliderTrackProps } from "../hue-slider/hue-slider.js";
6
- import "../hue-slider/index.js";
7
6
  import "../../index.js";
8
- import * as react1046 from "react";
7
+ import * as react1030 from "react";
9
8
 
10
9
  //#region src/components/alpha-slider/alpha-slider.d.ts
11
10
  interface AlphaSliderRootProps extends WithoutThemeProps<Omit<HueSliderRootProps, "color" | "max" | "step" | "thumbProps" | "trackProps">, AlphaSliderStyle> {
@@ -38,7 +37,7 @@ interface AlphaSliderRootProps extends WithoutThemeProps<Omit<HueSliderRootProps
38
37
  */
39
38
  trackProps?: AlphaSliderTrackProps;
40
39
  }
41
- declare const AlphaSliderPropsContext: react1046.Context<Partial<AlphaSliderRootProps> | undefined>, useAlphaSliderPropsContext: () => Partial<AlphaSliderRootProps> | undefined;
40
+ declare const AlphaSliderPropsContext: react1030.Context<Partial<AlphaSliderRootProps> | undefined>, useAlphaSliderPropsContext: () => Partial<AlphaSliderRootProps> | undefined;
42
41
  /**
43
42
  * `AlphaSlider` is a component used to allow the user to select color transparency.
44
43
  *
@@ -2,7 +2,7 @@ import { StyleValue } from "../../core/css/index.types.js";
2
2
  import { Component, HTMLStyledProps } from "../../core/components/index.types.js";
3
3
  import "../../core/index.js";
4
4
  import "../../index.js";
5
- import * as react1045 from "react";
5
+ import * as react1028 from "react";
6
6
 
7
7
  //#region src/components/aspect-ratio/aspect-ratio.d.ts
8
8
  interface AspectRatioProps extends HTMLStyledProps {
@@ -13,7 +13,7 @@ interface AspectRatioProps extends HTMLStyledProps {
13
13
  */
14
14
  ratio?: StyleValue<number>;
15
15
  }
16
- declare const AspectRatioPropsContext: react1045.Context<Partial<AspectRatioProps> | undefined>, useAspectRatioPropsContext: () => Partial<AspectRatioProps> | undefined;
16
+ declare const AspectRatioPropsContext: react1028.Context<Partial<AspectRatioProps> | undefined>, useAspectRatioPropsContext: () => Partial<AspectRatioProps> | undefined;
17
17
  /**
18
18
  * `AspectRatio` is a component for embedding things like videos and maps while maintaining the aspect ratio.
19
19
  *
@@ -3,15 +3,13 @@ import { Component, GenericsComponent, HTMLStyledProps } from "../../core/compon
3
3
  import "../../core/index.js";
4
4
  import { AutocompleteStyle } from "./autocomplete.style.js";
5
5
  import { PopoverContentProps, PopupAnimationProps } from "../popover/popover.js";
6
- import "../popover/index.js";
7
6
  import { UseComboboxGroupProps } from "../../hooks/use-combobox/index.js";
8
7
  import { UseInputBorderProps } from "../input/use-input-border.js";
9
8
  import { InputElementProps } from "../input/input-element.js";
10
9
  import { InputGroupRootProps } from "../input/input-group.js";
11
- import "../input/index.js";
12
10
  import { UseAutocompleteOptionProps, UseAutocompleteProps } from "./use-autocomplete.js";
13
11
  import "../../index.js";
14
- import * as react161 from "react";
12
+ import * as react852 from "react";
15
13
  import { ReactElement, ReactNode } from "react";
16
14
 
17
15
  //#region src/components/autocomplete/autocomplete.d.ts
@@ -67,7 +65,7 @@ interface AutocompleteRootProps<Multiple extends boolean = false> extends Omit<H
67
65
  */
68
66
  rootProps?: InputGroupRootProps;
69
67
  }
70
- declare const AutocompletePropsContext: react161.Context<Partial<AutocompleteRootProps<false>> | undefined>, useAutocompletePropsContext: () => Partial<AutocompleteRootProps<false>> | undefined;
68
+ declare const AutocompletePropsContext: react852.Context<Partial<AutocompleteRootProps<false>> | undefined>, useAutocompletePropsContext: () => Partial<AutocompleteRootProps<false>> | undefined;
71
69
  /**
72
70
  * `Autocomplete` is a component used to display suggestions in response to user text input.
73
71
  *