react-restyle-components 0.4.46 → 0.4.47

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 (231) hide show
  1. package/lib/index.js +1 -3
  2. package/lib/src/core-components/index.js +1 -1
  3. package/lib/src/core-components/src/components/Accordion/AccordionSection/Accordion.js +1 -15
  4. package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionContext.js +1 -6
  5. package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionSection.js +1 -39
  6. package/lib/src/core-components/src/components/Accordion/AccordionSection/Header.js +1 -39
  7. package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.js +57 -94
  8. package/lib/src/core-components/src/components/Accordion/AccordionSection/hooks/useCurrentAccordionIndex.js +1 -13
  9. package/lib/src/core-components/src/components/Accordion/AccordionSection/index.js +1 -3
  10. package/lib/src/core-components/src/components/Accordion/AccordionSection/types.js +1 -9
  11. package/lib/src/core-components/src/components/Accordion/Collapsible/Collapsible2.component.js +1 -249
  12. package/lib/src/core-components/src/components/Action/types.js +1 -8
  13. package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +1 -45
  14. package/lib/src/core-components/src/components/AlertBanner/elements.js +45 -120
  15. package/lib/src/core-components/src/components/AlertBanner/index.js +1 -2
  16. package/lib/src/core-components/src/components/AlertBanner/types.js +1 -10
  17. package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-group-by-multiple-select-multiple-fields-display/auto-complete-filter-group-by-multiple-select-multiple-fields-display.component.js +1 -451
  18. package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-multi-fields-display-drag-drop/auto-complete-filter-multi-select-multi-fields-display-drag-drop.component.js +1 -229
  19. package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-selected-top-display/auto-complete-filter-multi-select-selected-top-display.component.js +1 -174
  20. package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +2 -129
  21. package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select/auto-complete-filter-single-select.component.js +1 -55
  22. package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +2 -308
  23. package/lib/src/core-components/src/components/AutoComplete/auto-complete-group-by/auto-complete-group-by.component.js +1 -115
  24. package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.js +2 -442
  25. package/lib/src/core-components/src/components/AutoComplete/index.js +1 -8
  26. package/lib/src/core-components/src/components/Avatar/Avatar.js +14 -148
  27. package/lib/src/core-components/src/components/Badge/Badge.js +2 -25
  28. package/lib/src/core-components/src/components/Badge/InnerBadge/Inline.js +1 -25
  29. package/lib/src/core-components/src/components/Badge/InnerBadge/InnerBadge.js +1 -25
  30. package/lib/src/core-components/src/components/Badge/InnerBadge/elements.js +32 -78
  31. package/lib/src/core-components/src/components/Badge/InnerBadge/index.js +1 -1
  32. package/lib/src/core-components/src/components/Badge/index.js +1 -1
  33. package/lib/src/core-components/src/components/Badge/types.js +1 -5
  34. package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +1 -83
  35. package/lib/src/core-components/src/components/Breadcrumb/elements.js +94 -166
  36. package/lib/src/core-components/src/components/Breadcrumb/index.js +1 -3
  37. package/lib/src/core-components/src/components/Breadcrumb/types.js +1 -3
  38. package/lib/src/core-components/src/components/Button/button.component.js +1 -18
  39. package/lib/src/core-components/src/components/Button/buttonGroup/buttonGroup.component.js +1 -4
  40. package/lib/src/core-components/src/components/Button/index.js +1 -2
  41. package/lib/src/core-components/src/components/Button/types.js +1 -1
  42. package/lib/src/core-components/src/components/Chip/Chip.js +1 -64
  43. package/lib/src/core-components/src/components/Chip/elements.js +48 -148
  44. package/lib/src/core-components/src/components/Chip/index.js +1 -2
  45. package/lib/src/core-components/src/components/Chip/types.js +1 -4
  46. package/lib/src/core-components/src/components/Divider/Divider.js +1 -25
  47. package/lib/src/core-components/src/components/Divider/elements.js +31 -68
  48. package/lib/src/core-components/src/components/Divider/index.js +1 -2
  49. package/lib/src/core-components/src/components/Divider/types.js +1 -4
  50. package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +1 -147
  51. package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +17 -24
  52. package/lib/src/core-components/src/components/DynamicGrid/elements.js +100 -162
  53. package/lib/src/core-components/src/components/DynamicGrid/index.js +1 -3
  54. package/lib/src/core-components/src/components/DynamicGrid/types.js +1 -28
  55. package/lib/src/core-components/src/components/DynamicGrid/utils.js +1 -193
  56. package/lib/src/core-components/src/components/FormField/FormField.js +1 -103
  57. package/lib/src/core-components/src/components/FormField/components/CheckboxGroupInput.js +1 -37
  58. package/lib/src/core-components/src/components/FormField/components/CheckboxInput.js +1 -8
  59. package/lib/src/core-components/src/components/FormField/components/CssMultilineInput.js +1 -192
  60. package/lib/src/core-components/src/components/FormField/components/DatePickerInput.js +1 -99
  61. package/lib/src/core-components/src/components/FormField/components/DropdownInput.js +1 -70
  62. package/lib/src/core-components/src/components/FormField/components/OtpInput.js +1 -81
  63. package/lib/src/core-components/src/components/FormField/components/PasswordInput.js +1 -40
  64. package/lib/src/core-components/src/components/FormField/components/PinInput.js +1 -75
  65. package/lib/src/core-components/src/components/FormField/components/RadioInput.js +1 -54
  66. package/lib/src/core-components/src/components/FormField/components/TextDropdownInput.js +1 -94
  67. package/lib/src/core-components/src/components/FormField/components/ToggleInput.js +1 -36
  68. package/lib/src/core-components/src/components/FormField/components/index.js +1 -11
  69. package/lib/src/core-components/src/components/FormField/css-properties.js +1 -161
  70. package/lib/src/core-components/src/components/FormField/index.js +1 -2
  71. package/lib/src/core-components/src/components/Icon/Icon.js +1 -159
  72. package/lib/src/core-components/src/components/Icon/index.js +1 -2
  73. package/lib/src/core-components/src/components/Icon/types.js +1 -9
  74. package/lib/src/core-components/src/components/Loader/loader.component.js +2 -215
  75. package/lib/src/core-components/src/components/Masonry/Masonry.js +1 -73
  76. package/lib/src/core-components/src/components/Masonry/elements.js +29 -46
  77. package/lib/src/core-components/src/components/Masonry/hooks.js +1 -100
  78. package/lib/src/core-components/src/components/Masonry/index.js +1 -3
  79. package/lib/src/core-components/src/components/Masonry/types.js +1 -1
  80. package/lib/src/core-components/src/components/Modal/BasicModal/modal.component.js +1 -116
  81. package/lib/src/core-components/src/components/Modal/index.js +1 -2
  82. package/lib/src/core-components/src/components/Modal/modal-confirm/modal-confirm.component.js +1 -147
  83. package/lib/src/core-components/src/components/Picker/color-picker/color-picker.component.js +1 -12
  84. package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +1 -40
  85. package/lib/src/core-components/src/components/Picker/index.js +1 -2
  86. package/lib/src/core-components/src/components/Selection/index.js +1 -4
  87. package/lib/src/core-components/src/components/Selection/multi-select/multi-select.component.js +1 -49
  88. package/lib/src/core-components/src/components/Selection/multi-select-with-field/multi-select-with-field.component.js +1 -58
  89. package/lib/src/core-components/src/components/Selection/multi-selection-dropdown/multi-selection-dropdown.component.js +1 -43
  90. package/lib/src/core-components/src/components/Selection/single-select/single-select.component.js +1 -87
  91. package/lib/src/core-components/src/components/Skeleton/Skeleton.js +1 -51
  92. package/lib/src/core-components/src/components/Skeleton/elements.js +54 -143
  93. package/lib/src/core-components/src/components/Skeleton/index.js +1 -2
  94. package/lib/src/core-components/src/components/Skeleton/types.js +1 -4
  95. package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +1 -128
  96. package/lib/src/core-components/src/components/SpeedDial/elements.js +62 -132
  97. package/lib/src/core-components/src/components/SpeedDial/index.js +1 -2
  98. package/lib/src/core-components/src/components/SpeedDial/types.js +1 -3
  99. package/lib/src/core-components/src/components/Stepper2/stepper.component.js +1 -139
  100. package/lib/src/core-components/src/components/Switch/Switch.js +1 -26
  101. package/lib/src/core-components/src/components/Switch/elements.js +34 -103
  102. package/lib/src/core-components/src/components/Switch/index.js +1 -2
  103. package/lib/src/core-components/src/components/Switch/types.js +1 -3
  104. package/lib/src/core-components/src/components/Table/Table.js +1 -1489
  105. package/lib/src/core-components/src/components/Table/columnReorder.js +36 -332
  106. package/lib/src/core-components/src/components/Table/columnResize.js +21 -284
  107. package/lib/src/core-components/src/components/Table/elements.js +173 -277
  108. package/lib/src/core-components/src/components/Table/filters.js +30 -555
  109. package/lib/src/core-components/src/components/Table/hooks.js +2 -536
  110. package/lib/src/core-components/src/components/Table/index.js +1 -6
  111. package/lib/src/core-components/src/components/Table/types.js +1 -1
  112. package/lib/src/core-components/src/components/Tabs/tabs.component.js +1 -22
  113. package/lib/src/core-components/src/components/Tags1/Tags.component.js +1 -118
  114. package/lib/src/core-components/src/components/Tags1/types.js +1 -20
  115. package/lib/src/core-components/src/components/Timer1/timer.component.js +1 -76
  116. package/lib/src/core-components/src/components/Toast/Toast.js +1 -50
  117. package/lib/src/core-components/src/components/Toast/elements.js +41 -122
  118. package/lib/src/core-components/src/components/Toast/index.js +1 -2
  119. package/lib/src/core-components/src/components/Toast/types.js +1 -9
  120. package/lib/src/core-components/src/components/Tooltip/Tooltip.js +1 -200
  121. package/lib/src/core-components/src/components/Tooltip/elements.js +55 -117
  122. package/lib/src/core-components/src/components/Tooltip/index.js +1 -2
  123. package/lib/src/core-components/src/components/Tooltip/types.js +1 -17
  124. package/lib/src/core-components/src/components/Tooltip/utils.js +1 -140
  125. package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +1 -303
  126. package/lib/src/core-components/src/components/TreeSelect/elements.js +117 -216
  127. package/lib/src/core-components/src/components/TreeSelect/hooks.js +1 -252
  128. package/lib/src/core-components/src/components/TreeSelect/index.js +1 -3
  129. package/lib/src/core-components/src/components/TreeSelect/types.js +1 -1
  130. package/lib/src/core-components/src/components/ag-grid/AgGrid.js +1 -1057
  131. package/lib/src/core-components/src/components/ag-grid/elements.js +396 -790
  132. package/lib/src/core-components/src/components/ag-grid/hooks.js +4 -1220
  133. package/lib/src/core-components/src/components/ag-grid/index.js +1 -15
  134. package/lib/src/core-components/src/components/ag-grid/types.js +1 -6
  135. package/lib/src/core-components/src/components/index.js +1 -31
  136. package/lib/src/core-components/src/components/pdf/pdf-images.components.js +1 -7
  137. package/lib/src/core-components/src/components/pdf/pdf-table.components.js +5 -48
  138. package/lib/src/core-components/src/components/pdf/pdf-typography.components.js +1 -70
  139. package/lib/src/core-components/src/components/pdf/pdf-wrapped-view.components.js +1 -50
  140. package/lib/src/core-components/src/core-components/Avatar.js +4 -33
  141. package/lib/src/core-components/src/core-components/CoreButton/CoreButton.js +1 -10
  142. package/lib/src/core-components/src/core-components/CoreButton/elements.js +67 -176
  143. package/lib/src/core-components/src/core-components/CoreButton/index.js +1 -3
  144. package/lib/src/core-components/src/core-components/CoreButton/types.js +1 -6
  145. package/lib/src/core-components/src/core-components/CoreButton/utils.js +1 -12
  146. package/lib/src/core-components/src/core-components/Divider/Divider.js +4 -19
  147. package/lib/src/core-components/src/core-components/Divider/index.js +1 -1
  148. package/lib/src/core-components/src/core-components/SelectionCardStrip/index.js +1 -1
  149. package/lib/src/core-components/src/core-components/SelectionCardStrip/selectionCardStrip.js +10 -33
  150. package/lib/src/core-components/src/core-components/StateLayer.js +3 -5
  151. package/lib/src/core-components/src/core-components/ToggleCore/elements.js +25 -50
  152. package/lib/src/core-components/src/core-components/ToggleCore/index.js +1 -2
  153. package/lib/src/core-components/src/core-components/ToggleCore/toggleCore.js +1 -14
  154. package/lib/src/core-components/src/core-components/atoms/Input/Input.js +1 -22
  155. package/lib/src/core-components/src/core-components/atoms/Label/Label.js +1 -21
  156. package/lib/src/core-components/src/core-components/atoms/Textarea/Textarea.js +1 -19
  157. package/lib/src/core-components/src/core-components/index.js +1 -3
  158. package/lib/src/core-components/src/helpers/constants.js +1 -11
  159. package/lib/src/core-components/src/hooks/index.js +1 -1
  160. package/lib/src/core-components/src/hooks/outside.hook.js +1 -28
  161. package/lib/src/core-components/src/index.js +1 -12
  162. package/lib/src/core-components/src/tc.global.css +1 -0
  163. package/lib/src/core-components/src/utils/abstracts/breakpoints/index.js +1 -28
  164. package/lib/src/core-components/src/utils/abstracts/colors/index.js +1 -49
  165. package/lib/src/core-components/src/utils/abstracts/index.js +1 -5
  166. package/lib/src/core-components/src/utils/abstracts/space/index.js +1 -26
  167. package/lib/src/core-components/src/utils/abstracts/theme/ThemeBoundary.js +1 -8
  168. package/lib/src/core-components/src/utils/abstracts/theme/default-themes.js +1 -30
  169. package/lib/src/core-components/src/utils/abstracts/theme/index.js +1 -3
  170. package/lib/src/core-components/src/utils/abstracts/theme/theme.js +1 -30
  171. package/lib/src/core-components/src/utils/abstracts/theme/types.js +1 -1
  172. package/lib/src/core-components/src/utils/abstracts/theme/useTheme.js +1 -17
  173. package/lib/src/core-components/src/utils/abstracts/typography/index.js +1 -25
  174. package/lib/src/core-components/src/utils/context/DefaultsProvider.js +1 -8
  175. package/lib/src/core-components/src/utils/context/InternalProvider.js +1 -24
  176. package/lib/src/core-components/src/utils/context/index.js +1 -2
  177. package/lib/src/core-components/src/utils/designTokens.js +1 -128
  178. package/lib/src/core-components/src/utils/helpers/attachSubComponents.js +1 -23
  179. package/lib/src/core-components/src/utils/helpers/flattenChildren.js +1 -11
  180. package/lib/src/core-components/src/utils/helpers/getChildByType.js +1 -3
  181. package/lib/src/core-components/src/utils/helpers/index.js +1 -5
  182. package/lib/src/core-components/src/utils/helpers/isComponentType.js +1 -16
  183. package/lib/src/core-components/src/utils/helpers/separateChildrenByType.js +1 -12
  184. package/lib/src/core-components/src/utils/hooks/index.js +1 -18
  185. package/lib/src/core-components/src/utils/hooks/useClickOutside.js +1 -18
  186. package/lib/src/core-components/src/utils/hooks/useCombinedRefs.js +1 -17
  187. package/lib/src/core-components/src/utils/hooks/useDebouncedCallback.js +1 -12
  188. package/lib/src/core-components/src/utils/hooks/useDebouncedValue.js +1 -20
  189. package/lib/src/core-components/src/utils/hooks/useDeprecation.js +1 -40
  190. package/lib/src/core-components/src/utils/hooks/useDeviceDetect.js +1 -10
  191. package/lib/src/core-components/src/utils/hooks/useDeviceForm.js +1 -24
  192. package/lib/src/core-components/src/utils/hooks/useDisableBodyScroll.js +1 -16
  193. package/lib/src/core-components/src/utils/hooks/useHoverState.js +1 -36
  194. package/lib/src/core-components/src/utils/hooks/useId.js +1 -7
  195. package/lib/src/core-components/src/utils/hooks/useIsBrowser.js +1 -11
  196. package/lib/src/core-components/src/utils/hooks/useMediaQuery.js +1 -16
  197. package/lib/src/core-components/src/utils/hooks/useOverflow.js +1 -22
  198. package/lib/src/core-components/src/utils/hooks/useSafeLayoutEffect.js +1 -5
  199. package/lib/src/core-components/src/utils/hooks/useScrollingUp.js +1 -18
  200. package/lib/src/core-components/src/utils/hooks/useTrapFocus.js +1 -30
  201. package/lib/src/core-components/src/utils/hooks/useWindowDimensions.js +1 -23
  202. package/lib/src/core-components/src/utils/index.js +1 -9
  203. package/lib/src/core-components/src/utils/stories/Wrappers.js +8 -23
  204. package/lib/src/core-components/src/utils/stories/cleanProps.js +1 -5
  205. package/lib/src/core-components/src/utils/stories/index.js +1 -4
  206. package/lib/src/core-components/src/utils/stories/sleep.js +1 -4
  207. package/lib/src/core-components/src/utils/stories/view-ports.js +1 -50
  208. package/lib/src/core-components/src/utils/styling/calcWidthOfColumns.js +1 -5
  209. package/lib/src/core-components/src/utils/styling/createGridContainer.js +6 -12
  210. package/lib/src/core-components/src/utils/styling/createTransition.js +2 -7
  211. package/lib/src/core-components/src/utils/styling/forwardProps.js +1 -10
  212. package/lib/src/core-components/src/utils/styling/index.js +1 -5
  213. package/lib/src/core-components/src/utils/styling/pxToRem.js +1 -6
  214. package/lib/src/core-components/src/utils/testing/getComputedStyle.js +1 -3
  215. package/lib/src/core-components/src/utils/testing/index.js +1 -1
  216. package/lib/src/core-components/src/utils/utility.util.js +1 -14
  217. package/lib/src/core-components/tailwind.config.js +1 -233
  218. package/lib/src/core-hooks/index.js +1 -3
  219. package/lib/src/core-hooks/src/useClickOutside/useClickOutside.hook.js +1 -46
  220. package/lib/src/core-hooks/src/useDebounce/useDebounce.hook.js +1 -30
  221. package/lib/src/core-hooks/src/usePreventEKey/usePreventEKey.hook.js +1 -8
  222. package/lib/src/core-utils/index.js +1 -7
  223. package/lib/src/core-utils/src/calculation/calculation.util.js +1 -89
  224. package/lib/src/core-utils/src/colors/color.util.js +1 -15
  225. package/lib/src/core-utils/src/convert/numberToWords/numToWords.util.js +1 -145
  226. package/lib/src/core-utils/src/convert/typography/camelCaseToTitleCase.util.js +1 -5
  227. package/lib/src/core-utils/src/form-helper/form-helper.util.js +1 -82
  228. package/lib/src/core-utils/src/index.js +1 -7
  229. package/lib/src/core-utils/src/utility/utility.util.js +1 -12
  230. package/lib/src/core-utils/src/uuid/uuid.util.js +1 -8
  231. package/package.json +1 -1
@@ -1,73 +1 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { forwardRef, useCallback, useState, useEffect } from 'react';
4
- import { MasonryContainer, MasonryColumn, MasonryItemWrapper, MasonryImage, ImagePlaceholder, EmptyState, MasonryCard, MasonryCardContent, } from './elements';
5
- import { useResponsiveValue, useColumnDistribution, useImageLoading } from './hooks';
6
- // Default empty icon
7
- const EmptyIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [_jsx("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "14", width: "7", height: "7", rx: "1" })] }));
8
- export const Masonry = forwardRef(function MasonryComponent(props, ref) {
9
- const { items, columns = 3, gutter = 16, renderItem, sequential = false, animationDuration = 300, animated = true, staggerDelay = 50, classNames = {}, styles = {}, className, style, onImageLoad, onLayoutComplete, minItemHeight, loadingPlaceholder, emptyState, } = props;
10
- // Get responsive values
11
- const columnCount = useResponsiveValue(columns, 3);
12
- const gutterSize = useResponsiveValue(gutter, 16);
13
- // Distribute items into columns
14
- const columnData = useColumnDistribution(items, columnCount, sequential);
15
- // Image loading state
16
- const { setLoading, isLoading } = useImageLoading();
17
- // Track global item index for stagger animation
18
- let globalIndex = 0;
19
- // Layout complete callback
20
- useEffect(() => {
21
- if (items.length > 0) {
22
- const timeout = setTimeout(() => {
23
- onLayoutComplete?.();
24
- }, animationDuration + staggerDelay * items.length);
25
- return () => clearTimeout(timeout);
26
- }
27
- }, [items, animationDuration, staggerDelay, onLayoutComplete]);
28
- // Handle image load
29
- const handleImageLoad = useCallback((item, e) => {
30
- const img = e.currentTarget;
31
- setLoading(item.id, false);
32
- onImageLoad?.(item, img.naturalWidth, img.naturalHeight);
33
- }, [setLoading, onImageLoad]);
34
- // Default render function
35
- const defaultRenderItem = useCallback((item, index, columnIndex) => {
36
- if (item.src) {
37
- // Image item
38
- return (_jsxs(MasonryCard, { "$borderRadius": 8, children: [isLoading(item.id) && (_jsx(ImagePlaceholder, { "$height": item.height, "$borderRadius": 8 })), _jsx(MasonryImage, { src: item.src, alt: item.alt || '', "$objectFit": "cover", "$borderRadius": 0, "$isLoading": isLoading(item.id), onLoad: (e) => handleImageLoad(item, e), onError: () => setLoading(item.id, false) }), item.content && (_jsx(MasonryCardContent, { children: item.content }))] }));
39
- }
40
- // Content item
41
- if (item.content) {
42
- return item.content;
43
- }
44
- return null;
45
- }, [isLoading, handleImageLoad, setLoading]);
46
- // Use custom render or default
47
- const render = renderItem || defaultRenderItem;
48
- // Empty state
49
- if (items.length === 0) {
50
- return (_jsx(EmptyState, { className: classNames.root, style: styles.root, children: emptyState || (_jsxs(_Fragment, { children: [_jsx(EmptyIcon, {}), _jsx("span", { children: "No items to display" })] })) }));
51
- }
52
- return (_jsx(MasonryContainer, { ref: ref, "$gutter": gutterSize, className: className || classNames.root, style: { ...styles.root, ...style }, role: "grid", "aria-label": "Masonry layout", children: columnData.map((columnItems, columnIndex) => (_jsx(MasonryColumn, { "$gutter": gutterSize, "$columnCount": columnCount, className: classNames.column, style: styles.column, role: "gridcell", children: columnItems.map((item, itemIndex) => {
53
- const currentGlobalIndex = globalIndex++;
54
- return (_jsx(MasonryItemWrapper, { "$animated": animated, "$animationDuration": animationDuration, "$staggerIndex": currentGlobalIndex, "$staggerDelay": staggerDelay, "$minHeight": minItemHeight, className: classNames.item, style: styles.item, children: render(item, itemIndex, columnIndex) }, item.id));
55
- }) }, columnIndex))) }));
56
- });
57
- // Display name
58
- Masonry.displayName = 'Masonry';
59
- // MasonryImage component for standalone use
60
- export const MasonryImageComponent = forwardRef(function MasonryImageComponent(props, ref) {
61
- const { src, alt = '', className, style, onLoad, onError, objectFit = 'cover', borderRadius = 8, } = props;
62
- const [isLoading, setIsLoading] = useState(true);
63
- const handleLoad = (e) => {
64
- setIsLoading(false);
65
- onLoad?.(e);
66
- };
67
- const handleError = (e) => {
68
- setIsLoading(false);
69
- onError?.(e);
70
- };
71
- return (_jsxs(_Fragment, { children: [isLoading && _jsx(ImagePlaceholder, { "$borderRadius": borderRadius }), _jsx(MasonryImage, { ref: ref, src: src, alt: alt, className: className, style: style, "$objectFit": objectFit, "$borderRadius": borderRadius, "$isLoading": isLoading, onLoad: handleLoad, onError: handleError })] }));
72
- });
73
- MasonryImageComponent.displayName = 'MasonryImage';
1
+ "use strict";"use client";import{jsx as t,jsxs as u,Fragment as j}from"react/jsx-runtime";import{forwardRef as E,useCallback as w,useState as z,useEffect as B}from"react";import{MasonryContainer as G,MasonryColumn as V,MasonryItemWrapper as A,MasonryImage as D,ImagePlaceholder as v,EmptyState as J,MasonryCard as K,MasonryCardContent as O}from"./elements";import{useResponsiveValue as F,useColumnDistribution as Q,useImageLoading as U}from"./hooks";const X=()=>u("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),t("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),t("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),t("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]});export const Masonry=E(function(m,g){const{items:r,columns:h=3,gutter:y=16,renderItem:f,sequential:p=!1,animationDuration:i=300,animated:x=!0,staggerDelay:a=50,classNames:o={},styles:n={},className:$,style:I,onImageLoad:s,onLayoutComplete:L,minItemHeight:k,loadingPlaceholder:Y,emptyState:H}=m,M=F(h,3),N=F(y,16),T=Q(r,M,p),{setLoading:d,isLoading:b}=U();let W=0;B(()=>{if(r.length>0){const e=setTimeout(()=>{L?.()},i+a*r.length);return()=>clearTimeout(e)}},[r,i,a,L]);const R=w((e,c)=>{const l=c.currentTarget;d(e.id,!1),s?.(e,l.naturalWidth,l.naturalHeight)},[d,s]),_=w((e,c,l)=>e.src?u(K,{$borderRadius:8,children:[b(e.id)&&t(v,{$height:e.height,$borderRadius:8}),t(D,{src:e.src,alt:e.alt||"",$objectFit:"cover",$borderRadius:0,$isLoading:b(e.id),onLoad:C=>R(e,C),onError:()=>d(e.id,!1)}),e.content&&t(O,{children:e.content})]}):e.content?e.content:null,[b,R,d]),P=f||_;return r.length===0?t(J,{className:o.root,style:n.root,children:H||u(j,{children:[t(X,{}),t("span",{children:"No items to display"})]})}):t(G,{ref:g,$gutter:N,className:$||o.root,style:{...n.root,...I},role:"grid","aria-label":"Masonry layout",children:T.map((e,c)=>t(V,{$gutter:N,$columnCount:M,className:o.column,style:n.column,role:"gridcell",children:e.map((l,C)=>{const q=W++;return t(A,{$animated:x,$animationDuration:i,$staggerIndex:q,$staggerDelay:a,$minHeight:k,className:o.item,style:n.item,children:P(l,C,c)},l.id)})},c))})});Masonry.displayName="Masonry";export const MasonryImageComponent=E(function(m,g){const{src:r,alt:h="",className:y,style:f,onLoad:p,onError:i,objectFit:x="cover",borderRadius:a=8}=m,[o,n]=z(!0),$=s=>{n(!1),p?.(s)},I=s=>{n(!1),i?.(s)};return u(j,{children:[o&&t(v,{$borderRadius:a}),t(D,{ref:g,src:r,alt:h,className:y,style:f,$objectFit:x,$borderRadius:a,$isLoading:o,onLoad:$,onError:I})]})});MasonryImageComponent.displayName="MasonryImage";
@@ -1,7 +1,4 @@
1
- import { styled, css, keyframes } from 'styled-components';
2
- import { tokens } from '../../utils/designTokens';
3
- // Animations
4
- const fadeIn = keyframes `
1
+ "use strict";import{styled as t,css as n,keyframes as a}from"styled-components";import{tokens as e}from"../../utils/designTokens";const s=a`
5
2
  from {
6
3
  opacity: 0;
7
4
  transform: translateY(10px);
@@ -10,44 +7,38 @@ const fadeIn = keyframes `
10
7
  opacity: 1;
11
8
  transform: translateY(0);
12
9
  }
13
- `;
14
- const shimmer = keyframes `
10
+ `,x=a`
15
11
  0% {
16
12
  background-position: -200% 0;
17
13
  }
18
14
  100% {
19
15
  background-position: 200% 0;
20
16
  }
21
- `;
22
- export const MasonryContainer = styled.div `
17
+ `;export const MasonryContainer=t.div`
23
18
  display: flex;
24
19
  width: 100%;
25
20
  box-sizing: border-box;
26
- gap: ${({ $gutter }) => $gutter}px;
27
- `;
28
- export const MasonryColumn = styled.div `
21
+ gap: ${({$gutter:o})=>o}px;
22
+ `,MasonryColumn=t.div`
29
23
  display: flex;
30
24
  flex-direction: column;
31
25
  flex: 1;
32
26
  min-width: 0;
33
- gap: ${({ $gutter }) => $gutter}px;
34
- `;
35
- export const MasonryItemWrapper = styled.div `
27
+ gap: ${({$gutter:o})=>o}px;
28
+ `,MasonryItemWrapper=t.div`
36
29
  width: 100%;
37
30
  box-sizing: border-box;
38
31
  overflow: hidden;
39
32
 
40
- ${({ $minHeight }) => $minHeight &&
41
- css `
42
- min-height: ${$minHeight}px;
33
+ ${({$minHeight:o})=>o&&n`
34
+ min-height: ${o}px;
43
35
  `}
44
36
 
45
37
  /* Animation */
46
- ${({ $animated, $animationDuration, $staggerIndex, $staggerDelay }) => $animated &&
47
- css `
38
+ ${({$animated:o,$animationDuration:i,$staggerIndex:r,$staggerDelay:p})=>o&&n`
48
39
  opacity: 0;
49
- animation: ${fadeIn} ${$animationDuration}ms ease-out forwards;
50
- animation-delay: ${$staggerIndex * $staggerDelay}ms;
40
+ animation: ${s} ${i}ms ease-out forwards;
41
+ animation-delay: ${r*p}ms;
51
42
  `}
52
43
 
53
44
  /* Reduce motion */
@@ -55,41 +46,37 @@ export const MasonryItemWrapper = styled.div `
55
46
  animation: none;
56
47
  opacity: 1;
57
48
  }
58
- `;
59
- export const MasonryImage = styled.img `
49
+ `,MasonryImage=t.img`
60
50
  width: 100%;
61
51
  height: auto;
62
52
  display: block;
63
- object-fit: ${({ $objectFit }) => $objectFit};
64
- border-radius: ${({ $borderRadius }) => typeof $borderRadius === 'number' ? `${$borderRadius}px` : $borderRadius};
53
+ object-fit: ${({$objectFit:o})=>o};
54
+ border-radius: ${({$borderRadius:o})=>typeof o=="number"?`${o}px`:o};
65
55
  transition: opacity 0.3s ease;
66
56
 
67
- ${({ $isLoading }) => $isLoading &&
68
- css `
57
+ ${({$isLoading:o})=>o&&n`
69
58
  opacity: 0;
70
59
  `}
71
- `;
72
- export const ImagePlaceholder = styled.div `
60
+ `,ImagePlaceholder=t.div`
73
61
  width: 100%;
74
- height: ${({ $height }) => $height ? (typeof $height === 'number' ? `${$height}px` : $height) : '200px'};
62
+ height: ${({$height:o})=>o?typeof o=="number"?`${o}px`:o:"200px"};
75
63
  background: linear-gradient(
76
64
  90deg,
77
- ${tokens.surface || '#f0f0f0'} 25%,
78
- ${tokens.outlineSoft || '#e5e5e5'} 50%,
79
- ${tokens.surface || '#f0f0f0'} 75%
65
+ ${e.surface||"#f0f0f0"} 25%,
66
+ ${e.outlineSoft||"#e5e5e5"} 50%,
67
+ ${e.surface||"#f0f0f0"} 75%
80
68
  );
81
69
  background-size: 400% 100%;
82
- animation: ${shimmer} 1.5s ease-in-out infinite;
83
- border-radius: ${({ $borderRadius }) => typeof $borderRadius === 'number' ? `${$borderRadius}px` : $borderRadius};
84
- `;
85
- export const EmptyState = styled.div `
70
+ animation: ${x} 1.5s ease-in-out infinite;
71
+ border-radius: ${({$borderRadius:o})=>typeof o=="number"?`${o}px`:o};
72
+ `,EmptyState=t.div`
86
73
  display: flex;
87
74
  flex-direction: column;
88
75
  align-items: center;
89
76
  justify-content: center;
90
77
  padding: 48px 24px;
91
78
  text-align: center;
92
- color: ${tokens.onSurface ? `${tokens.onSurface}80` : '#6b7280'};
79
+ color: ${e.onSurface?`${e.onSurface}80`:"#6b7280"};
93
80
  font-size: 14px;
94
81
 
95
82
  svg {
@@ -98,11 +85,9 @@ export const EmptyState = styled.div `
98
85
  margin-bottom: 16px;
99
86
  opacity: 0.5;
100
87
  }
101
- `;
102
- // Card style for default item rendering
103
- export const MasonryCard = styled.div `
88
+ `,MasonryCard=t.div`
104
89
  background: white;
105
- border-radius: ${({ $borderRadius }) => typeof $borderRadius === 'number' ? `${$borderRadius}px` : $borderRadius};
90
+ border-radius: ${({$borderRadius:o})=>typeof o=="number"?`${o}px`:o};
106
91
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
107
92
  overflow: hidden;
108
93
  transition: transform 0.2s ease, box-shadow 0.2s ease;
@@ -111,12 +96,10 @@ export const MasonryCard = styled.div `
111
96
  transform: translateY(-2px);
112
97
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
113
98
  }
114
- `;
115
- export const MasonryCardImage = styled.img `
99
+ `,MasonryCardImage=t.img`
116
100
  width: 100%;
117
101
  height: auto;
118
102
  display: block;
119
- `;
120
- export const MasonryCardContent = styled.div `
103
+ `,MasonryCardContent=t.div`
121
104
  padding: 12px 16px;
122
105
  `;
@@ -1,100 +1 @@
1
- import { useState, useEffect, useCallback, useMemo } from 'react';
2
- // Breakpoint values in pixels
3
- const BREAKPOINT_VALUES = {
4
- xs: 0,
5
- sm: 640,
6
- md: 768,
7
- lg: 1024,
8
- xl: 1280,
9
- '2xl': 1536,
10
- };
11
- /**
12
- * Hook to get responsive value based on current viewport width
13
- */
14
- export function useResponsiveValue(value, defaultValue) {
15
- const [currentValue, setCurrentValue] = useState(() => {
16
- if (typeof value === 'number')
17
- return value;
18
- return getResponsiveValue(value, defaultValue, typeof window !== 'undefined' ? window.innerWidth : 1024);
19
- });
20
- useEffect(() => {
21
- if (typeof value === 'number') {
22
- setCurrentValue(value);
23
- return;
24
- }
25
- const handleResize = () => {
26
- const width = window.innerWidth;
27
- setCurrentValue(getResponsiveValue(value, defaultValue, width));
28
- };
29
- handleResize();
30
- window.addEventListener('resize', handleResize);
31
- return () => window.removeEventListener('resize', handleResize);
32
- }, [value, defaultValue]);
33
- return currentValue;
34
- }
35
- function getResponsiveValue(breakpoints, defaultValue, width) {
36
- const sortedBreakpoints = Object.entries(BREAKPOINT_VALUES)
37
- .sort(([, a], [, b]) => b - a);
38
- for (const [key, breakpointWidth] of sortedBreakpoints) {
39
- if (width >= breakpointWidth && breakpoints[key] !== undefined) {
40
- return breakpoints[key];
41
- }
42
- }
43
- return defaultValue;
44
- }
45
- /**
46
- * Hook to distribute items into columns
47
- */
48
- export function useColumnDistribution(items, columnCount, sequential = false) {
49
- return useMemo(() => {
50
- const columns = Array.from({ length: columnCount }, () => []);
51
- if (sequential) {
52
- // Sequential: place items in order, filling columns one by one
53
- items.forEach((item, index) => {
54
- const columnIndex = item.column !== undefined
55
- ? Math.min(item.column, columnCount - 1)
56
- : index % columnCount;
57
- columns[columnIndex].push(item);
58
- });
59
- }
60
- else {
61
- // Balanced: distribute items to shortest column
62
- const columnHeights = Array(columnCount).fill(0);
63
- items.forEach((item) => {
64
- let targetColumn;
65
- if (item.column !== undefined) {
66
- // Respect specified column
67
- targetColumn = Math.min(item.column, columnCount - 1);
68
- }
69
- else {
70
- // Find shortest column
71
- targetColumn = columnHeights.indexOf(Math.min(...columnHeights));
72
- }
73
- columns[targetColumn].push(item);
74
- // Increment height (use 1 as placeholder, actual heights vary)
75
- columnHeights[targetColumn]++;
76
- });
77
- }
78
- return columns;
79
- }, [items, columnCount, sequential]);
80
- }
81
- /**
82
- * Hook to track image loading states
83
- */
84
- export function useImageLoading() {
85
- const [loadingStates, setLoadingStates] = useState({});
86
- const [loadedImages, setLoadedImages] = useState(new Set());
87
- const setLoading = useCallback((id, isLoading) => {
88
- setLoadingStates(prev => ({ ...prev, [id]: isLoading }));
89
- if (!isLoading) {
90
- setLoadedImages(prev => new Set(prev).add(id));
91
- }
92
- }, []);
93
- const isLoading = useCallback((id) => {
94
- return loadingStates[id] ?? true;
95
- }, [loadingStates]);
96
- const isLoaded = useCallback((id) => {
97
- return loadedImages.has(id);
98
- }, [loadedImages]);
99
- return { setLoading, isLoading, isLoaded };
100
- }
1
+ "use strict";import{useState as c,useEffect as m,useCallback as f,useMemo as w}from"react";const g={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536};export function useResponsiveValue(n,t){const[s,o]=c(()=>typeof n=="number"?n:h(n,t,typeof window<"u"?window.innerWidth:1024));return m(()=>{if(typeof n=="number"){o(n);return}const e=()=>{const r=window.innerWidth;o(h(n,t,r))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[n,t]),s}function h(n,t,s){const o=Object.entries(g).sort(([,e],[,r])=>r-e);for(const[e,r]of o)if(s>=r&&n[e]!==void 0)return n[e];return t}export function useColumnDistribution(n,t,s=!1){return w(()=>{const o=Array.from({length:t},()=>[]);if(s)n.forEach((e,r)=>{const i=e.column!==void 0?Math.min(e.column,t-1):r%t;o[i].push(e)});else{const e=Array(t).fill(0);n.forEach(r=>{let i;r.column!==void 0?i=Math.min(r.column,t-1):i=e.indexOf(Math.min(...e)),o[i].push(r),e[i]++})}return o},[n,t,s])}export function useImageLoading(){const[n,t]=c({}),[s,o]=c(new Set),e=f((d,a)=>{t(u=>({...u,[d]:a})),a||o(u=>new Set(u).add(d))},[]),r=f(d=>n[d]??!0,[n]),i=f(d=>s.has(d),[s]);return{setLoading:e,isLoading:r,isLoaded:i}}
@@ -1,3 +1 @@
1
- export { Masonry, MasonryImageComponent as MasonryImage } from './Masonry';
2
- export * from './types';
3
- export { useResponsiveValue, useColumnDistribution, useImageLoading } from './hooks';
1
+ "use strict";export{Masonry,MasonryImageComponent as MasonryImage}from"./Masonry";export*from"./types";export{useResponsiveValue,useColumnDistribution,useImageLoading}from"./hooks";
@@ -1 +1 @@
1
- export {};
1
+ "use strict";export{};
@@ -1,116 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
3
- import s from '../../../tc.module.css';
4
- import { cn } from '../../../utils';
5
- export const Modal = ({ visible, title = '', className = '', contentClassName = '', headerClassName = '', style = {}, contentStyle = {}, onClose, isAutoClose = false, autoCloseDelay = 1000, size = 'md', position = 'center', showCloseButton = true, closeButton, overlayOpacity = 0.5, overlayColor, closeOnOverlayClick = true, closeOnEscape = true, showHeader = true, headerBgColor, headerTextColor, borderRadius = '0.5rem', maxWidth, contentPadding = '1rem', headerPadding = '1rem', animationDuration = 300, classNames = {}, styles = {}, children, }) => {
6
- const [showModal, setShowModal] = useState(visible);
7
- const [isAnimating, setIsAnimating] = useState(false);
8
- useEffect(() => {
9
- if (visible) {
10
- setShowModal(true);
11
- setTimeout(() => setIsAnimating(true), 10);
12
- }
13
- else {
14
- setIsAnimating(false);
15
- setTimeout(() => setShowModal(false), animationDuration);
16
- }
17
- }, [visible, animationDuration]);
18
- useEffect(() => {
19
- if (showModal && isAutoClose) {
20
- const delay = typeof isAutoClose === 'number' ? isAutoClose : autoCloseDelay;
21
- const timer = setTimeout(() => {
22
- onClose && onClose();
23
- }, delay);
24
- return () => clearTimeout(timer);
25
- }
26
- }, [showModal, isAutoClose, autoCloseDelay, onClose]);
27
- useEffect(() => {
28
- if (!closeOnEscape || !showModal)
29
- return;
30
- const handleEscape = (e) => {
31
- if (e.key === 'Escape') {
32
- onClose && onClose();
33
- }
34
- };
35
- document.addEventListener('keydown', handleEscape);
36
- return () => document.removeEventListener('keydown', handleEscape);
37
- }, [showModal, closeOnEscape, onClose]);
38
- const handleOverlayClick = (e) => {
39
- if (closeOnOverlayClick && e.target === e.currentTarget) {
40
- onClose && onClose();
41
- }
42
- };
43
- const handleClose = () => {
44
- onClose && onClose();
45
- };
46
- const sizeMaxWidths = {
47
- sm: '28rem',
48
- md: '32rem',
49
- lg: '42rem',
50
- xl: '56rem',
51
- full: '95%',
52
- };
53
- const positionClasses = {
54
- center: s['items-center'],
55
- top: s['items-start'],
56
- bottom: s['items-end'],
57
- };
58
- const modalMaxWidth = maxWidth || (size !== 'full' ? sizeMaxWidths[size] : '95%');
59
- if (!showModal)
60
- return null;
61
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: cn(s['fixed'], s['inset-0'], s['z-40'], s['bg-black'], classNames.overlay), style: {
62
- opacity: isAnimating ? overlayOpacity : 0,
63
- transition: `opacity ${animationDuration}ms ease-in-out`,
64
- backgroundColor: overlayColor || undefined,
65
- ...styles.overlay,
66
- }, onClick: handleOverlayClick }), _jsx("div", { className: cn(s['flex'], s['justify-center'], positionClasses[position], s['overflow-x-hidden'], s['overflow-y-auto'], s['fixed'], s['inset-0'], s['z-50'], s['outline-none'], s['focus:outline-none'], className, classNames.container), style: {
67
- ...style,
68
- transition: `opacity ${animationDuration}ms ease-in-out`,
69
- opacity: isAnimating ? 1 : 0,
70
- ...styles.container,
71
- }, onClick: handleOverlayClick, children: _jsx("div", { className: cn(s['relative'], s['w-full'], s['my-5'], s['mx-auto'], classNames.wrapper), style: {
72
- maxWidth: modalMaxWidth,
73
- marginLeft: size === 'full' ? '1rem' : undefined,
74
- marginRight: size === 'full' ? '1rem' : undefined,
75
- transform: isAnimating
76
- ? position === 'center'
77
- ? 'scale(1)'
78
- : position === 'top'
79
- ? 'translateY(0)'
80
- : 'translateY(0)'
81
- : position === 'center'
82
- ? 'scale(0.95)'
83
- : position === 'top'
84
- ? 'translateY(-20px)'
85
- : 'translateY(20px)',
86
- transition: `transform ${animationDuration}ms ease-out, opacity ${animationDuration}ms ease-out`,
87
- opacity: isAnimating ? 1 : 0,
88
- ...styles.wrapper,
89
- }, onClick: (e) => e.stopPropagation(), children: _jsxs("div", { className: cn(s['border-0'], s['shadow-xl'], s['relative'], s['flex'], s['flex-col'], s['bg-white'], s['outline-none'], s['focus:outline-none'], contentClassName, classNames.content), style: {
90
- borderRadius,
91
- ...contentStyle,
92
- ...styles.content,
93
- }, children: [showHeader && (_jsxs("div", { className: cn(s['flex'], s['items-center'], s['justify-between'], s['border-b'], s['border-solid'], s['border-gray-200'], headerClassName, classNames.header), style: {
94
- padding: headerPadding,
95
- backgroundColor: headerBgColor,
96
- borderTopLeftRadius: borderRadius,
97
- borderTopRightRadius: borderRadius,
98
- borderBottom: title || showCloseButton ? undefined : 'none',
99
- ...styles.header,
100
- }, children: [title && (_jsx("h3", { className: cn(s['text-xl'], s['font-semibold'], s['m-0'], s['flex-1'], classNames.title), style: { color: headerTextColor, ...styles.title }, children: title })), showCloseButton && (_jsx("button", { type: "button", className: cn(s['p-1'], s['ml-4'], s['border-0'], s['bg-transparent'], s['cursor-pointer'], s['outline-none'], s['focus:outline-none'], s['transition-colors'], s['hover:bg-gray-100'], s['rounded'], classNames.closeButton), onClick: handleClose, "aria-label": "Close modal", style: {
101
- marginLeft: title ? '1rem' : 0,
102
- marginRight: title ? 0 : 'auto',
103
- ...styles.closeButton,
104
- }, children: closeButton || (_jsx("span", { className: cn(s['block'], s['text-2xl'], s['leading-none'], s['font-light']), style: {
105
- color: headerTextColor || '#1f2937',
106
- height: '1.5rem',
107
- width: '1.5rem',
108
- display: 'flex',
109
- alignItems: 'center',
110
- justifyContent: 'center',
111
- lineHeight: 1,
112
- }, children: "\u00D7" })) }))] })), _jsx("div", { className: cn(s['flex'], s['flex-col'], s['w-full'], s['h-auto'], s['overflow-y-auto'], classNames.body), style: {
113
- padding: contentPadding,
114
- ...styles.body,
115
- }, children: children })] }) }) })] }));
116
- };
1
+ "use strict";import{jsx as a,jsxs as y,Fragment as Q}from"react/jsx-runtime";import{useEffect as x,useState as M}from"react";import e from"../../../tc.module.css";import{cn as r}from"../../../utils";export const Modal=({visible:h,title:d="",className:E="",contentClassName:Y="",headerClassName:$="",style:R={},contentStyle:W={},onClose:t,isAutoClose:s=!1,autoCloseDelay:b=1e3,size:f="md",position:c="center",showCloseButton:v=!0,closeButton:_,overlayOpacity:B=.5,overlayColor:F,closeOnOverlayClick:I=!0,closeOnEscape:w=!0,showHeader:N=!0,headerBgColor:S,headerTextColor:k,borderRadius:p="0.5rem",maxWidth:H,contentPadding:P="1rem",headerPadding:q="1rem",animationDuration:i=300,classNames:n={},styles:o={},children:z})=>{const[m,j]=M(h),[u,T]=M(!1);x(()=>{h?(j(!0),setTimeout(()=>T(!0),10)):(T(!1),setTimeout(()=>j(!1),i))},[h,i]),x(()=>{if(m&&s){const g=setTimeout(()=>{t&&t()},typeof s=="number"?s:b);return()=>clearTimeout(g)}},[m,s,b,t]),x(()=>{if(!w||!m)return;const l=g=>{g.key==="Escape"&&t&&t()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[m,w,t]);const L=l=>{I&&l.target===l.currentTarget&&t&&t()},G=()=>{t&&t()},J={sm:"28rem",md:"32rem",lg:"42rem",xl:"56rem",full:"95%"},K={center:e["items-center"],top:e["items-start"],bottom:e["items-end"]},O=H||(f!=="full"?J[f]:"95%");return m?y(Q,{children:[a("div",{className:r(e.fixed,e["inset-0"],e["z-40"],e["bg-black"],n.overlay),style:{opacity:u?B:0,transition:`opacity ${i}ms ease-in-out`,backgroundColor:F||void 0,...o.overlay},onClick:L}),a("div",{className:r(e.flex,e["justify-center"],K[c],e["overflow-x-hidden"],e["overflow-y-auto"],e.fixed,e["inset-0"],e["z-50"],e["outline-none"],e["focus:outline-none"],E,n.container),style:{...R,transition:`opacity ${i}ms ease-in-out`,opacity:u?1:0,...o.container},onClick:L,children:a("div",{className:r(e.relative,e["w-full"],e["my-5"],e["mx-auto"],n.wrapper),style:{maxWidth:O,marginLeft:f==="full"?"1rem":void 0,marginRight:f==="full"?"1rem":void 0,transform:u?c==="center"?"scale(1)":"translateY(0)":c==="center"?"scale(0.95)":c==="top"?"translateY(-20px)":"translateY(20px)",transition:`transform ${i}ms ease-out, opacity ${i}ms ease-out`,opacity:u?1:0,...o.wrapper},onClick:l=>l.stopPropagation(),children:y("div",{className:r(e["border-0"],e["shadow-xl"],e.relative,e.flex,e["flex-col"],e["bg-white"],e["outline-none"],e["focus:outline-none"],Y,n.content),style:{borderRadius:p,...W,...o.content},children:[N&&y("div",{className:r(e.flex,e["items-center"],e["justify-between"],e["border-b"],e["border-solid"],e["border-gray-200"],$,n.header),style:{padding:q,backgroundColor:S,borderTopLeftRadius:p,borderTopRightRadius:p,borderBottom:d||v?void 0:"none",...o.header},children:[d&&a("h3",{className:r(e["text-xl"],e["font-semibold"],e["m-0"],e["flex-1"],n.title),style:{color:k,...o.title},children:d}),v&&a("button",{type:"button",className:r(e["p-1"],e["ml-4"],e["border-0"],e["bg-transparent"],e["cursor-pointer"],e["outline-none"],e["focus:outline-none"],e["transition-colors"],e["hover:bg-gray-100"],e.rounded,n.closeButton),onClick:G,"aria-label":"Close modal",style:{marginLeft:d?"1rem":0,marginRight:d?0:"auto",...o.closeButton},children:_||a("span",{className:r(e.block,e["text-2xl"],e["leading-none"],e["font-light"]),style:{color:k||"#1f2937",height:"1.5rem",width:"1.5rem",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"\xD7"})})]}),a("div",{className:r(e.flex,e["flex-col"],e["w-full"],e["h-auto"],e["overflow-y-auto"],n.body),style:{padding:P,...o.body},children:z})]})})})]}):null};
@@ -1,2 +1 @@
1
- export * from './BasicModal/modal.component';
2
- export * from './modal-confirm/modal-confirm.component';
1
+ "use strict";export*from"./BasicModal/modal.component";export*from"./modal-confirm/modal-confirm.component";
@@ -1,147 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect, useState, useCallback } from 'react';
3
- import { Container } from 'reactstrap';
4
- import s from '../../../tc.module.css';
5
- import { cn } from '../../../utils';
6
- export const ModalConfirm = ({ visible = false, title = 'Confirm', message, submitTitle = 'Send', closeTitle = 'Close', isClick = true, isClose = true, animationDuration = 200, classNames = {}, styles = {}, onClick, onClose, }) => {
7
- const [showModal, setShowModal] = useState(false);
8
- const [isAnimating, setIsAnimating] = useState(false);
9
- const [isClosing, setIsClosing] = useState(false);
10
- useEffect(() => {
11
- if (visible) {
12
- setShowModal(true);
13
- // Trigger animation after mount
14
- requestAnimationFrame(() => {
15
- setIsAnimating(true);
16
- });
17
- }
18
- else if (showModal) {
19
- handleCloseAnimation();
20
- }
21
- // eslint-disable-next-line react-hooks/exhaustive-deps
22
- }, [visible]);
23
- const handleCloseAnimation = useCallback(() => {
24
- setIsClosing(true);
25
- setIsAnimating(false);
26
- setTimeout(() => {
27
- setShowModal(false);
28
- setIsClosing(false);
29
- }, animationDuration);
30
- }, [animationDuration]);
31
- const handleClose = useCallback(() => {
32
- handleCloseAnimation();
33
- setTimeout(() => {
34
- onClose && onClose();
35
- }, animationDuration);
36
- }, [handleCloseAnimation, onClose, animationDuration]);
37
- const handleSubmit = useCallback(() => {
38
- handleCloseAnimation();
39
- setTimeout(() => {
40
- onClick && onClick();
41
- }, animationDuration);
42
- }, [handleCloseAnimation, onClick, animationDuration]);
43
- // Animation styles
44
- const overlayAnimationStyle = {
45
- opacity: isAnimating ? 1 : 0,
46
- transition: `opacity ${animationDuration}ms ease-out`,
47
- backdropFilter: isAnimating ? 'blur(4px)' : 'blur(0px)',
48
- WebkitBackdropFilter: isAnimating ? 'blur(4px)' : 'blur(0px)',
49
- };
50
- const contentAnimationStyle = {
51
- opacity: isAnimating ? 1 : 0,
52
- transform: isAnimating
53
- ? 'scale(1) translateY(0)'
54
- : 'scale(0.95) translateY(-10px)',
55
- transition: `opacity ${animationDuration}ms ease-out, transform ${animationDuration}ms ease-out`,
56
- };
57
- return (_jsx(_Fragment, { children: _jsx(Container, { children: showModal && (_jsxs(_Fragment, { children: [_jsx("div", { className: cn(s['fixed'], s['inset-0'], s['z-40'], s['bg-black'], classNames.overlay), style: {
58
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
59
- ...overlayAnimationStyle,
60
- ...styles.overlay,
61
- }, onClick: handleClose }), _jsx("div", { className: cn(s['flex'], s['justify-center'], s['items-center'], s['overflow-x-hidden'], s['overflow-y-auto'], s['fixed'], s['inset-0'], s['z-50'], s['outline-none'], s['focus:outline-none'], s['p-4'], classNames.container), style: styles.container, children: _jsx("div", { className: cn(s['relative'], s['w-full'], classNames.wrapper), style: {
62
- maxWidth: '28rem',
63
- ...contentAnimationStyle,
64
- ...styles.wrapper,
65
- }, children: _jsxs("div", { className: cn(s['border-0'], s['rounded-lg'], s['shadow-lg'], s['relative'], s['flex'], s['flex-col'], s['w-full'], s['bg-white'], s['outline-none'], s['focus:outline-none'], classNames.content), style: {
66
- boxShadow: '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
67
- borderRadius: '16px',
68
- ...styles.content,
69
- }, children: [_jsxs("div", { className: cn(s['flex'], s['items-center'], s['justify-between'], s['p-4'], s['border-b'], s['border-solid'], s['border-gray-300'], classNames.header), style: {
70
- borderTopLeftRadius: '16px',
71
- borderTopRightRadius: '16px',
72
- background: 'linear-gradient(to right, #f8fafc, #f1f5f9)',
73
- ...styles.header,
74
- }, children: [_jsx("h3", { className: cn(s['text-xl'], s['font-semibold'], classNames.title), style: {
75
- color: '#1e293b',
76
- margin: 0,
77
- ...styles.title,
78
- }, children: title }), _jsx("button", { className: cn(s['flex'], s['items-center'], s['justify-center'], s['border-0'], s['outline-none'], s['focus:outline-none'], classNames.closeButton), style: {
79
- width: '32px',
80
- height: '32px',
81
- borderRadius: '8px',
82
- backgroundColor: 'transparent',
83
- color: '#64748b',
84
- fontSize: '24px',
85
- lineHeight: 1,
86
- cursor: 'pointer',
87
- transition: 'all 0.15s ease',
88
- ...styles.closeButton,
89
- }, onMouseEnter: (e) => {
90
- e.currentTarget.style.backgroundColor = '#fee2e2';
91
- e.currentTarget.style.color = '#dc2626';
92
- }, onMouseLeave: (e) => {
93
- e.currentTarget.style.backgroundColor = 'transparent';
94
- e.currentTarget.style.color = '#64748b';
95
- }, onClick: handleClose, "aria-label": "Close modal", children: _jsx("span", { style: { marginTop: '-2px' }, children: "\u00D7" }) })] }), _jsx("div", { className: cn(s['flex'], s['p-4'], classNames.body), style: {
96
- padding: '24px',
97
- ...styles.body,
98
- }, children: _jsx("div", { className: cn(s['flex'], s['w-full']), children: typeof message === 'string' ? (_jsx("span", { style: {
99
- color: '#475569',
100
- fontSize: '15px',
101
- lineHeight: 1.6,
102
- }, children: message })) : (message) }) }), _jsxs("div", { className: cn(s['flex'], s['items-center'], s['justify-end'], s['p-4'], s['border-t'], s['border-solid'], s['border-gray-300'], classNames.footer), style: {
103
- borderBottomLeftRadius: '16px',
104
- borderBottomRightRadius: '16px',
105
- backgroundColor: '#f8fafc',
106
- gap: '12px',
107
- flexWrap: 'wrap',
108
- ...styles.footer,
109
- }, children: [isClose && (_jsx("button", { className: cn(classNames.cancelButton), type: "button", style: {
110
- backgroundColor: '#e2e8f0',
111
- color: '#475569',
112
- fontWeight: 600,
113
- fontSize: '14px',
114
- padding: '10px 20px',
115
- borderRadius: '8px',
116
- border: 'none',
117
- cursor: 'pointer',
118
- transition: 'all 0.15s ease',
119
- minWidth: '100px',
120
- ...styles.cancelButton,
121
- }, onMouseEnter: (e) => {
122
- e.currentTarget.style.backgroundColor = '#cbd5e1';
123
- }, onMouseLeave: (e) => {
124
- e.currentTarget.style.backgroundColor = '#e2e8f0';
125
- }, onClick: handleClose, children: closeTitle })), isClick && (_jsx("button", { className: cn(classNames.submitButton), type: "button", style: {
126
- background: 'linear-gradient(135deg, #22c55e 0%, #16a34a 100%)',
127
- color: 'white',
128
- fontWeight: 600,
129
- fontSize: '14px',
130
- padding: '10px 20px',
131
- borderRadius: '8px',
132
- border: 'none',
133
- cursor: 'pointer',
134
- transition: 'all 0.15s ease',
135
- boxShadow: '0 4px 12px rgba(34, 197, 94, 0.3)',
136
- minWidth: '100px',
137
- ...styles.submitButton,
138
- }, onMouseEnter: (e) => {
139
- e.currentTarget.style.transform = 'translateY(-1px)';
140
- e.currentTarget.style.boxShadow =
141
- '0 6px 16px rgba(34, 197, 94, 0.4)';
142
- }, onMouseLeave: (e) => {
143
- e.currentTarget.style.transform = 'translateY(0)';
144
- e.currentTarget.style.boxShadow =
145
- '0 4px 12px rgba(34, 197, 94, 0.3)';
146
- }, onClick: handleSubmit, children: submitTitle }))] })] }) }) })] })) }) }));
147
- };
1
+ "use strict";import{jsx as t,jsxs as d,Fragment as C}from"react/jsx-runtime";import{useEffect as W,useState as b,useCallback as x}from"react";import{Container as z}from"reactstrap";import e from"../../../tc.module.css";import{cn as o}from"../../../utils";export const ModalConfirm=({visible:g=!1,title:k="Confirm",message:c,submitTitle:v="Send",closeTitle:T="Close",isClick:S=!0,isClose:R=!0,animationDuration:a=200,classNames:n={},styles:l={},onClick:u,onClose:p})=>{const[h,m]=b(!1),[i,y]=b(!1),[A,w]=b(!1);W(()=>{g?(m(!0),requestAnimationFrame(()=>{y(!0)})):h&&s()},[g]);const s=x(()=>{w(!0),y(!1),setTimeout(()=>{m(!1),w(!1)},a)},[a]),f=x(()=>{s(),setTimeout(()=>{p&&p()},a)},[s,p,a]),B=x(()=>{s(),setTimeout(()=>{u&&u()},a)},[s,u,a]),M={opacity:i?1:0,transition:`opacity ${a}ms ease-out`,backdropFilter:i?"blur(4px)":"blur(0px)",WebkitBackdropFilter:i?"blur(4px)":"blur(0px)"},j={opacity:i?1:0,transform:i?"scale(1) translateY(0)":"scale(0.95) translateY(-10px)",transition:`opacity ${a}ms ease-out, transform ${a}ms ease-out`};return t(C,{children:t(z,{children:h&&d(C,{children:[t("div",{className:o(e.fixed,e["inset-0"],e["z-40"],e["bg-black"],n.overlay),style:{backgroundColor:"rgba(0, 0, 0, 0.5)",...M,...l.overlay},onClick:f}),t("div",{className:o(e.flex,e["justify-center"],e["items-center"],e["overflow-x-hidden"],e["overflow-y-auto"],e.fixed,e["inset-0"],e["z-50"],e["outline-none"],e["focus:outline-none"],e["p-4"],n.container),style:l.container,children:t("div",{className:o(e.relative,e["w-full"],n.wrapper),style:{maxWidth:"28rem",...j,...l.wrapper},children:d("div",{className:o(e["border-0"],e["rounded-lg"],e["shadow-lg"],e.relative,e.flex,e["flex-col"],e["w-full"],e["bg-white"],e["outline-none"],e["focus:outline-none"],n.content),style:{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",borderRadius:"16px",...l.content},children:[d("div",{className:o(e.flex,e["items-center"],e["justify-between"],e["p-4"],e["border-b"],e["border-solid"],e["border-gray-300"],n.header),style:{borderTopLeftRadius:"16px",borderTopRightRadius:"16px",background:"linear-gradient(to right, #f8fafc, #f1f5f9)",...l.header},children:[t("h3",{className:o(e["text-xl"],e["font-semibold"],n.title),style:{color:"#1e293b",margin:0,...l.title},children:k}),t("button",{className:o(e.flex,e["items-center"],e["justify-center"],e["border-0"],e["outline-none"],e["focus:outline-none"],n.closeButton),style:{width:"32px",height:"32px",borderRadius:"8px",backgroundColor:"transparent",color:"#64748b",fontSize:"24px",lineHeight:1,cursor:"pointer",transition:"all 0.15s ease",...l.closeButton},onMouseEnter:r=>{r.currentTarget.style.backgroundColor="#fee2e2",r.currentTarget.style.color="#dc2626"},onMouseLeave:r=>{r.currentTarget.style.backgroundColor="transparent",r.currentTarget.style.color="#64748b"},onClick:f,"aria-label":"Close modal",children:t("span",{style:{marginTop:"-2px"},children:"\xD7"})})]}),t("div",{className:o(e.flex,e["p-4"],n.body),style:{padding:"24px",...l.body},children:t("div",{className:o(e.flex,e["w-full"]),children:typeof c=="string"?t("span",{style:{color:"#475569",fontSize:"15px",lineHeight:1.6},children:c}):c})}),d("div",{className:o(e.flex,e["items-center"],e["justify-end"],e["p-4"],e["border-t"],e["border-solid"],e["border-gray-300"],n.footer),style:{borderBottomLeftRadius:"16px",borderBottomRightRadius:"16px",backgroundColor:"#f8fafc",gap:"12px",flexWrap:"wrap",...l.footer},children:[R&&t("button",{className:o(n.cancelButton),type:"button",style:{backgroundColor:"#e2e8f0",color:"#475569",fontWeight:600,fontSize:"14px",padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",transition:"all 0.15s ease",minWidth:"100px",...l.cancelButton},onMouseEnter:r=>{r.currentTarget.style.backgroundColor="#cbd5e1"},onMouseLeave:r=>{r.currentTarget.style.backgroundColor="#e2e8f0"},onClick:f,children:T}),S&&t("button",{className:o(n.submitButton),type:"button",style:{background:"linear-gradient(135deg, #22c55e 0%, #16a34a 100%)",color:"white",fontWeight:600,fontSize:"14px",padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",transition:"all 0.15s ease",boxShadow:"0 4px 12px rgba(34, 197, 94, 0.3)",minWidth:"100px",...l.submitButton},onMouseEnter:r=>{r.currentTarget.style.transform="translateY(-1px)",r.currentTarget.style.boxShadow="0 6px 16px rgba(34, 197, 94, 0.4)"},onMouseLeave:r=>{r.currentTarget.style.transform="translateY(0)",r.currentTarget.style.boxShadow="0 4px 12px rgba(34, 197, 94, 0.3)"},onClick:B,children:v})]})]})})})]})})})};