@techsio/ui-kit 0.41.1 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +2 -1
  2. package/dist/atoms/numeric-input.js +3 -3
  3. package/dist/atoms/rating.js +3 -3
  4. package/dist/atoms/tooltip.js +3 -3
  5. package/dist/internal/molecules/drawer.context.js +133 -0
  6. package/dist/internal/molecules/drawer.styles.js +107 -0
  7. package/dist/internal/organisms/sidebar.context.js +223 -0
  8. package/dist/internal/organisms/sidebar.focus.js +169 -0
  9. package/dist/internal/organisms/sidebar.styles.js +146 -0
  10. package/dist/molecules/accordion.js +3 -3
  11. package/dist/molecules/carousel.js +3 -3
  12. package/dist/molecules/chart.js +1 -1
  13. package/dist/molecules/dialog.js +3 -3
  14. package/dist/molecules/drawer.js +262 -0
  15. package/dist/molecules/menu.js +5 -5
  16. package/dist/molecules/radio-group.js +3 -3
  17. package/dist/molecules/select.js +4 -4
  18. package/dist/molecules/slider.js +3 -3
  19. package/dist/molecules/switch.js +3 -3
  20. package/dist/molecules/tabs.js +3 -3
  21. package/dist/molecules/toast.js +6 -6
  22. package/dist/molecules/tree-view.js +4 -4
  23. package/dist/organisms/data-table.fields.js +1 -1
  24. package/dist/organisms/data-table.js +7 -7
  25. package/dist/organisms/sidebar.js +448 -0
  26. package/dist/src/atoms/action-icon.d.ts +1 -1
  27. package/dist/src/atoms/button.d.ts +1 -1
  28. package/dist/src/atoms/link-button.d.ts +1 -1
  29. package/dist/src/atoms/numeric-input.d.ts +1 -1
  30. package/dist/src/atoms/status-text.d.ts +1 -1
  31. package/dist/src/internal/molecules/drawer.context.d.ts +53 -0
  32. package/dist/src/internal/molecules/drawer.context.d.ts.map +1 -0
  33. package/dist/src/internal/molecules/drawer.styles.d.ts +115 -0
  34. package/dist/src/internal/molecules/drawer.styles.d.ts.map +1 -0
  35. package/dist/src/internal/organisms/sidebar.context.d.ts +83 -0
  36. package/dist/src/internal/organisms/sidebar.context.d.ts.map +1 -0
  37. package/dist/src/internal/organisms/sidebar.focus.d.ts +16 -0
  38. package/dist/src/internal/organisms/sidebar.focus.d.ts.map +1 -0
  39. package/dist/src/internal/organisms/sidebar.styles.d.ts +149 -0
  40. package/dist/src/internal/organisms/sidebar.styles.d.ts.map +1 -0
  41. package/dist/src/molecules/accordion.d.ts +1 -1
  42. package/dist/src/molecules/breadcrumb.d.ts +2 -2
  43. package/dist/src/molecules/carousel.d.ts +2 -2
  44. package/dist/src/molecules/combobox.d.ts +1 -1
  45. package/dist/src/molecules/drawer.d.ts +112 -0
  46. package/dist/src/molecules/drawer.d.ts.map +1 -0
  47. package/dist/src/molecules/form-input.d.ts +1 -1
  48. package/dist/src/molecules/form-numeric-input.d.ts +1 -1
  49. package/dist/src/molecules/form-textarea.d.ts +1 -1
  50. package/dist/src/molecules/menu.d.ts +1 -1
  51. package/dist/src/molecules/pagination.d.ts +1 -1
  52. package/dist/src/molecules/phone-input.d.ts +3 -3
  53. package/dist/src/molecules/popover.d.ts +1 -1
  54. package/dist/src/molecules/product-card.d.ts +4 -4
  55. package/dist/src/molecules/radio-card.d.ts +2 -2
  56. package/dist/src/molecules/radio-group.d.ts +2 -2
  57. package/dist/src/molecules/search-form.d.ts +5 -5
  58. package/dist/src/molecules/select.d.ts +1 -1
  59. package/dist/src/molecules/steps.d.ts +1 -1
  60. package/dist/src/molecules/switch.d.ts +3 -3
  61. package/dist/src/molecules/tabs.d.ts +1 -1
  62. package/dist/src/molecules/toast.d.ts +6 -6
  63. package/dist/src/molecules/tree-view.d.ts +1 -1
  64. package/dist/src/organisms/data-table.d.ts +8 -8
  65. package/dist/src/organisms/data-table.fields.d.ts +2 -2
  66. package/dist/src/organisms/data-table.helpers.d.ts +1 -1
  67. package/dist/src/organisms/gallery.d.ts +2 -2
  68. package/dist/src/organisms/sidebar.d.ts +93 -0
  69. package/dist/src/organisms/sidebar.d.ts.map +1 -0
  70. package/dist/src/templates/accordion.d.ts +2 -2
  71. package/dist/src/templates/breadcrumb.d.ts +2 -2
  72. package/dist/src/templates/carousel.d.ts +2 -2
  73. package/dist/src/templates/gallery.d.ts +3 -3
  74. package/dist/src/templates/numeric-input.d.ts +2 -2
  75. package/dist/src/templates/popover.d.ts +1 -1
  76. package/dist/src/templates/product-card.d.ts +2 -2
  77. package/dist/src/templates/select.d.ts +1 -1
  78. package/dist/src/templates/tabs.d.ts +1 -1
  79. package/dist/src/theme/theme-provider.d.ts +1 -1
  80. package/dist/src/types/zag.d.ts +1 -0
  81. package/dist/src/types/zag.d.ts.map +1 -1
  82. package/dist/stories/atoms/badge.stories.d.ts +1 -1
  83. package/dist/stories/atoms/button.stories.d.ts +1 -1
  84. package/dist/stories/atoms/checkbox.stories.d.ts +1 -1
  85. package/dist/stories/atoms/icon.stories.d.ts +1 -1
  86. package/dist/stories/atoms/image.stories.d.ts +1 -1
  87. package/dist/stories/atoms/input.stories.d.ts +1 -1
  88. package/dist/stories/atoms/numeric-input.stories.d.ts +1 -1
  89. package/dist/stories/atoms/rating.stories.d.ts +1 -1
  90. package/dist/stories/atoms/skeleton.stories.d.ts +1 -1
  91. package/dist/stories/atoms/status-text.stories.d.ts +1 -1
  92. package/dist/stories/atoms/textarea.stories.d.ts +1 -1
  93. package/dist/stories/atoms/tooltip.stories.d.ts +2 -2
  94. package/dist/stories/changelog/changelog.stories.d.ts.map +1 -1
  95. package/dist/stories/helpers/icon-options.d.ts +1 -1
  96. package/dist/stories/molecules/accordion.stories.d.ts +1 -1
  97. package/dist/stories/molecules/breadcrumb.stories.d.ts +1 -1
  98. package/dist/stories/molecules/carousel.stories.d.ts +1 -1
  99. package/dist/stories/molecules/chart.stories.d.ts +1 -1
  100. package/dist/stories/molecules/color-select.stories.d.ts +1 -1
  101. package/dist/stories/molecules/combobox.stories.d.ts +1 -1
  102. package/dist/stories/molecules/dialog.stories.d.ts +1 -1
  103. package/dist/stories/molecules/drawer.stories.d.ts +158 -0
  104. package/dist/stories/molecules/drawer.stories.d.ts.map +1 -0
  105. package/dist/stories/molecules/form-checkbox.stories.d.ts +1 -1
  106. package/dist/stories/molecules/form-input.stories.d.ts +1 -1
  107. package/dist/stories/molecules/form-numeric-input.stories.d.ts +1 -1
  108. package/dist/stories/molecules/form-textarea.stories.d.ts +1 -1
  109. package/dist/stories/molecules/menu.stories.d.ts +1 -1
  110. package/dist/stories/molecules/pagination.stories.d.ts +1 -1
  111. package/dist/stories/molecules/phone-input.stories.d.ts +1 -1
  112. package/dist/stories/molecules/popover.stories.d.ts +1 -1
  113. package/dist/stories/molecules/product-card.stories.d.ts +1 -1
  114. package/dist/stories/molecules/radio-card.stories.d.ts +1 -1
  115. package/dist/stories/molecules/radio-group.stories.d.ts +1 -1
  116. package/dist/stories/molecules/search-form.stories.d.ts +1 -1
  117. package/dist/stories/molecules/select.stories.d.ts +1 -1
  118. package/dist/stories/molecules/slider.stories.d.ts +1 -1
  119. package/dist/stories/molecules/steps.stories.d.ts +1 -1
  120. package/dist/stories/molecules/switch.stories.d.ts +1 -1
  121. package/dist/stories/molecules/tabs.stories.d.ts +1 -1
  122. package/dist/stories/molecules/tree-view.stories.d.ts +1 -1
  123. package/dist/stories/organisms/data-table.stories.d.ts +1 -1
  124. package/dist/stories/organisms/footer.stories.d.ts +1 -1
  125. package/dist/stories/organisms/gallery.stories.d.ts +2 -2
  126. package/dist/stories/organisms/header.stories.d.ts +1 -1
  127. package/dist/stories/organisms/sidebar.stories.d.ts +66 -0
  128. package/dist/stories/organisms/sidebar.stories.d.ts.map +1 -0
  129. package/dist/stories/organisms/table.stories.d.ts +1 -1
  130. package/dist/stories/templates/accordion.stories.d.ts +1 -1
  131. package/dist/stories/templates/breadcrumb.stories.d.ts +1 -1
  132. package/dist/stories/templates/carousel.stories.d.ts +1 -1
  133. package/dist/stories/templates/gallery.stories.d.ts +1 -1
  134. package/dist/stories/templates/numeric-input.stories.d.ts +1 -1
  135. package/dist/stories/templates/popover.stories.d.ts +1 -1
  136. package/dist/stories/templates/product-card.stories.d.ts +1 -1
  137. package/dist/stories/templates/select.stories.d.ts +1 -1
  138. package/dist/stories/templates/tabs.stories.d.ts +1 -1
  139. package/dist/test/drawer.behavior.spec.d.ts +2 -0
  140. package/dist/test/drawer.behavior.spec.d.ts.map +1 -0
  141. package/dist/test/sidebar.behavior.spec.d.ts +2 -0
  142. package/dist/test/sidebar.behavior.spec.d.ts.map +1 -0
  143. package/dist/test/sidebar.ssr.bun.d.ts +2 -0
  144. package/dist/test/sidebar.ssr.bun.d.ts.map +1 -0
  145. package/dist/theme/theme-provider.js +4 -4
  146. package/dist/theme/theme-toggle.js +1 -1
  147. package/package.json +43 -33
  148. package/src/tokens/components/components.css +2 -0
  149. package/src/tokens/components/molecules/_drawer.css +369 -0
  150. package/src/tokens/components/organisms/_sidebar.css +93 -0
  151. package/src/tokens/styles.d.ts +3 -0
@@ -0,0 +1,169 @@
1
+ "use client";
2
+ import { useLayoutEffect, useRef } from "react";
3
+ function getPanelFocusRegion(document, panelId, isDesktop) {
4
+ const panel = document.getElementById(panelId);
5
+ if (isDesktop || !panel) return panel;
6
+ return panel.closest('[data-scope="drawer"][data-part="content"]') ?? panel;
7
+ }
8
+ function getPanelFocusTarget({ document, panelId, rootId, side, triggerValue }) {
9
+ const root = document.getElementById(rootId);
10
+ const triggers = root ? Array.from(root.querySelectorAll("button[data-sidebar-trigger]")).filter((candidate)=>candidate.closest('[data-scope="sidebar"][data-part="root"]') === root && candidate.dataset.side === side && !candidate.disabled && candidate.getClientRects().length > 0) : [];
11
+ const exactTrigger = triggerValue ? triggers.find((candidate)=>candidate.dataset.sidebarTriggerValue === triggerValue) : void 0;
12
+ const target = exactTrigger ?? triggers[0];
13
+ if (target) return target;
14
+ const panel = document.getElementById(panelId);
15
+ return panel && !panel.inert && panel.getClientRects().length > 0 ? panel : null;
16
+ }
17
+ function hasMeaningfulFocus(document) {
18
+ const activeElement = document.activeElement;
19
+ return Boolean(activeElement && activeElement !== document.body && activeElement !== document.documentElement && activeElement.isConnected);
20
+ }
21
+ function queueDocumentMicrotask(document, callback) {
22
+ const view = document.defaultView;
23
+ if (view) return void view.queueMicrotask(callback);
24
+ globalThis.queueMicrotask(callback);
25
+ }
26
+ function captureActiveFocus({ activeElement, focus, focusRegion, mode, origin, side, triggerValue }) {
27
+ if (activeElement && focusRegion?.contains(activeElement)) {
28
+ focus.capture({
29
+ mode,
30
+ node: focusRegion,
31
+ side,
32
+ triggerValue
33
+ });
34
+ return true;
35
+ }
36
+ if (activeElement && origin.node.contains(activeElement)) {
37
+ focus.capture({
38
+ mode,
39
+ node: origin.node,
40
+ side,
41
+ triggerValue: origin.triggerValue
42
+ });
43
+ return true;
44
+ }
45
+ return false;
46
+ }
47
+ function captureTransferredTarget({ document, focus, mode, origin, side, target, triggerValue }) {
48
+ if (!target || document.activeElement !== target) return;
49
+ const capturedOrigin = focus.peek(side);
50
+ if (capturedOrigin?.mode === mode && capturedOrigin.node === target) return;
51
+ focus.capture({
52
+ mode,
53
+ node: target,
54
+ side,
55
+ triggerValue: target.dataset.sidebarTriggerValue ?? origin.triggerValue ?? triggerValue
56
+ });
57
+ }
58
+ function runQueuedFocusTransfer({ document, focus, isCurrent, isDesktop, mode, origin, panelId, rootId, side, triggerValue }) {
59
+ const stale = !isCurrent() || focus.getRevision(side) !== origin.revision || !document.hasFocus();
60
+ if (stale) return;
61
+ const focusRegion = getPanelFocusRegion(document, panelId, isDesktop);
62
+ const activeElement = document.activeElement;
63
+ if (activeElement && focusRegion?.contains(activeElement)) return;
64
+ if (hasMeaningfulFocus(document)) return;
65
+ const target = getPanelFocusTarget({
66
+ document,
67
+ panelId,
68
+ rootId,
69
+ side,
70
+ triggerValue
71
+ });
72
+ target?.focus({
73
+ preventScroll: true
74
+ });
75
+ captureTransferredTarget({
76
+ document,
77
+ focus,
78
+ mode,
79
+ origin,
80
+ side,
81
+ target,
82
+ triggerValue
83
+ });
84
+ }
85
+ function cancelFocusTransfer(transition, transitionId) {
86
+ if (transition.current === transitionId) transition.current += 1;
87
+ }
88
+ function getPendingFocusOrigin(focus, side, fromMode) {
89
+ const origin = focus.peek(side);
90
+ return origin?.mode === fromMode ? origin : null;
91
+ }
92
+ function useSidebarPanelFocusTransfer({ focus, isDesktop, panelId, rootId, side, triggerValue }) {
93
+ const wasDesktop = useRef(isDesktop);
94
+ const transition = useRef(0);
95
+ const latestTriggerValue = useRef(triggerValue);
96
+ useLayoutEffect(()=>{
97
+ latestTriggerValue.current = triggerValue;
98
+ }, [
99
+ triggerValue
100
+ ]);
101
+ useLayoutEffect(()=>{
102
+ if (wasDesktop.current === isDesktop) return;
103
+ wasDesktop.current = isDesktop;
104
+ const transitionId = transition.current + 1;
105
+ transition.current = transitionId;
106
+ const mode = isDesktop ? "desktop" : "mobile";
107
+ const fromMode = isDesktop ? "mobile" : "desktop";
108
+ const pendingOrigin = getPendingFocusOrigin(focus, side, fromMode);
109
+ if (!pendingOrigin) return;
110
+ const { document } = pendingOrigin;
111
+ const focusRegion = getPanelFocusRegion(document, panelId, isDesktop);
112
+ const activeElement = document.activeElement;
113
+ const nextTriggerValue = pendingOrigin.triggerValue ?? latestTriggerValue.current;
114
+ if (captureActiveFocus({
115
+ activeElement,
116
+ focus,
117
+ focusRegion,
118
+ mode,
119
+ origin: pendingOrigin,
120
+ side,
121
+ triggerValue: nextTriggerValue
122
+ })) return;
123
+ if (hasMeaningfulFocus(document)) return void focus.clear(side, pendingOrigin.revision);
124
+ const origin = focus.claim(side, fromMode);
125
+ if (!origin) return;
126
+ queueDocumentMicrotask(document, ()=>{
127
+ runQueuedFocusTransfer({
128
+ document,
129
+ focus,
130
+ isCurrent: ()=>transition.current === transitionId,
131
+ isDesktop,
132
+ mode,
133
+ origin,
134
+ panelId,
135
+ rootId,
136
+ side,
137
+ triggerValue: origin.triggerValue ?? latestTriggerValue.current
138
+ });
139
+ });
140
+ return ()=>cancelFocusTransfer(transition, transitionId);
141
+ }, [
142
+ focus,
143
+ isDesktop,
144
+ panelId,
145
+ rootId,
146
+ side
147
+ ]);
148
+ const onFocusCapture = (event)=>{
149
+ focus.capture({
150
+ mode: isDesktop ? "desktop" : "mobile",
151
+ node: event.currentTarget,
152
+ side,
153
+ triggerValue: null
154
+ });
155
+ };
156
+ const onBlurCapture = (event)=>{
157
+ focus.blur({
158
+ mode: isDesktop ? "desktop" : "mobile",
159
+ node: event.currentTarget,
160
+ relatedTarget: event.relatedTarget,
161
+ side
162
+ });
163
+ };
164
+ return {
165
+ onBlurCapture,
166
+ onFocusCapture
167
+ };
168
+ }
169
+ export { useSidebarPanelFocusTransfer };
@@ -0,0 +1,146 @@
1
+ import { tv } from "../../utils.js";
2
+ const sidebarVariants = tv({
3
+ slots: {
4
+ root: [
5
+ "relative flex min-h-sidebar-viewport w-full min-w-0",
6
+ "bg-sidebar-root-bg text-sidebar-root-fg"
7
+ ],
8
+ breakpoint: "pointer-events-none invisible absolute sidebar-desktop:block hidden size-0",
9
+ desktopPanel: [
10
+ "group/sidebar-panel sticky top-sidebar-offset hidden h-sidebar-viewport shrink-0 flex-col overflow-hidden",
11
+ "sidebar-desktop:flex bg-sidebar-panel-bg text-sidebar-panel-fg",
12
+ "border-sidebar-panel-border transition-all duration-(--duration-sidebar) motion-reduce:transition-none",
13
+ "focus-visible:sidebar-focus-ring",
14
+ "data-[side=start]:border-e-(length:--border-width-sidebar)",
15
+ "data-[side=end]:border-s-(length:--border-width-sidebar)"
16
+ ],
17
+ mobilePanel: [
18
+ "w-full max-w-sidebar-mobile bg-sidebar-panel-bg p-0 text-sidebar-panel-fg",
19
+ "data-[swipe-direction=left]:rounded-none data-[swipe-direction=right]:rounded-none"
20
+ ],
21
+ mobileAside: "focus-visible:sidebar-focus-ring flex size-full min-h-0 flex-col overflow-hidden",
22
+ trigger: [
23
+ "bg-sidebar-trigger-bg text-sidebar-trigger-fg",
24
+ "hover:bg-sidebar-trigger-bg-hover active:bg-sidebar-trigger-bg-active"
25
+ ],
26
+ inset: [
27
+ "relative min-h-sidebar-viewport min-w-0 flex-1",
28
+ "bg-sidebar-inset-bg text-sidebar-inset-fg"
29
+ ],
30
+ header: [
31
+ "flex shrink-0 flex-col gap-sidebar-section p-sidebar-section",
32
+ "border-b-(length:--border-width-sidebar) border-sidebar-panel-border",
33
+ "group-data-[state=collapsed]/sidebar-panel:p-sidebar-section-compact",
34
+ "group-data-[size=rail]/sidebar-pane:p-sidebar-section-compact"
35
+ ],
36
+ content: [
37
+ "flex min-h-0 flex-1 flex-col gap-sidebar-content overflow-y-auto overflow-x-hidden",
38
+ "p-sidebar-content",
39
+ "group-data-[state=collapsed]/sidebar-panel:p-sidebar-content-compact",
40
+ "group-data-[size=rail]/sidebar-pane:p-sidebar-content-compact"
41
+ ],
42
+ footer: [
43
+ "flex shrink-0 flex-col gap-sidebar-section p-sidebar-section",
44
+ "border-t-(length:--border-width-sidebar) border-sidebar-panel-border",
45
+ "group-data-[state=collapsed]/sidebar-panel:p-sidebar-section-compact",
46
+ "group-data-[size=rail]/sidebar-pane:p-sidebar-section-compact"
47
+ ],
48
+ group: "flex min-w-0 flex-col gap-sidebar-group",
49
+ groupLabel: [
50
+ "sidebar-group-label-typography truncate px-sidebar-group-label",
51
+ "font-sidebar-group-label text-sidebar-group-label-fg"
52
+ ],
53
+ groupContent: "flex min-w-0 flex-col gap-sidebar-group-content",
54
+ menu: "flex min-w-0 list-none flex-col gap-sidebar-menu",
55
+ item: "relative min-w-0",
56
+ separator: [
57
+ "h-sidebar-separator w-full shrink-0 border-0",
58
+ "bg-sidebar-separator-bg"
59
+ ],
60
+ expanded: "min-w-0",
61
+ label: "min-w-0 truncate whitespace-nowrap",
62
+ paneGroup: "flex min-h-0 min-w-0 flex-1 overflow-hidden",
63
+ pane: "group/sidebar-pane flex min-h-0 min-w-0 flex-col",
64
+ rail: [
65
+ "sidebar-rail-layer absolute inset-y-sidebar-rail hidden w-sidebar-rail cursor-col-resize items-center justify-center",
66
+ "sidebar-desktop:flex text-sidebar-rail-fg hover:bg-sidebar-rail-bg-hover",
67
+ "focus-visible:sidebar-focus-ring",
68
+ "data-[side=end]:start-0 data-[side=start]:end-0",
69
+ "after:h-sidebar-rail-indicator after:w-sidebar-rail-indicator after:rounded-sidebar-rail after:bg-sidebar-rail-indicator-bg"
70
+ ]
71
+ },
72
+ variants: {
73
+ collapsible: {
74
+ icon: {},
75
+ offcanvas: {},
76
+ none: {}
77
+ },
78
+ expanded: {
79
+ true: {},
80
+ false: {}
81
+ },
82
+ paneSize: {
83
+ rail: {
84
+ pane: "w-sidebar-icon shrink-0"
85
+ },
86
+ content: {
87
+ pane: [
88
+ "border-s-(length:--border-width-sidebar) flex-1",
89
+ "border-sidebar-pane-border"
90
+ ]
91
+ },
92
+ auto: {
93
+ pane: "flex-1"
94
+ }
95
+ },
96
+ collapsed: {
97
+ true: {
98
+ label: "sr-only"
99
+ },
100
+ false: {}
101
+ }
102
+ },
103
+ compoundVariants: [
104
+ {
105
+ collapsible: "icon",
106
+ expanded: true,
107
+ class: {
108
+ desktopPanel: "w-sidebar-expanded"
109
+ }
110
+ },
111
+ {
112
+ collapsible: "icon",
113
+ expanded: false,
114
+ class: {
115
+ desktopPanel: "w-sidebar-icon"
116
+ }
117
+ },
118
+ {
119
+ collapsible: "offcanvas",
120
+ expanded: true,
121
+ class: {
122
+ desktopPanel: "w-sidebar-expanded"
123
+ }
124
+ },
125
+ {
126
+ collapsible: "offcanvas",
127
+ expanded: false,
128
+ class: {
129
+ desktopPanel: "w-0 border-transparent"
130
+ }
131
+ },
132
+ {
133
+ collapsible: "none",
134
+ class: {
135
+ desktopPanel: "w-sidebar-expanded"
136
+ }
137
+ }
138
+ ],
139
+ defaultVariants: {
140
+ collapsible: "icon",
141
+ expanded: true,
142
+ paneSize: "auto",
143
+ collapsed: false
144
+ }
145
+ });
146
+ export { sidebarVariants };
@@ -1,10 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { connect, machine } from "@zag-js/accordion";
3
2
  import { normalizeProps, useMachine } from "@zag-js/react";
4
3
  import { createContext, useContext, useId } from "react";
5
4
  import { Button } from "../atoms/button.js";
6
5
  import { Icon } from "../atoms/icon.js";
7
6
  import { tv } from "../utils.js";
7
+ import * as __rspack_external__zag_js_accordion_dea8b50f from "@zag-js/accordion";
8
8
  const accordionVariants = tv({
9
9
  slots: {
10
10
  root: [
@@ -109,7 +109,7 @@ function useAccordionItemContext() {
109
109
  function Accordion({ id, defaultValue, value, collapsible = true, multiple = false, dir = "ltr", onChange, size, shadow, disabled = false, children, ref, className, variant, ...props }) {
110
110
  const generatedId = useId();
111
111
  const uniqueId = id || generatedId;
112
- const service = useMachine(machine, {
112
+ const service = useMachine(__rspack_external__zag_js_accordion_dea8b50f.machine, {
113
113
  id: uniqueId,
114
114
  value,
115
115
  defaultValue,
@@ -122,7 +122,7 @@ function Accordion({ id, defaultValue, value, collapsible = true, multiple = fal
122
122
  onChange?.(newValue);
123
123
  }
124
124
  });
125
- const api = connect(service, normalizeProps);
125
+ const api = __rspack_external__zag_js_accordion_dea8b50f.connect(service, normalizeProps);
126
126
  const styles = accordionVariants({
127
127
  size,
128
128
  shadow,
@@ -1,10 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { connect, machine } from "@zag-js/carousel";
3
2
  import { normalizeProps, useMachine } from "@zag-js/react";
4
3
  import { createContext, useContext, useId } from "react";
5
4
  import { tv } from "tailwind-variants";
6
5
  import { Button } from "../atoms/button.js";
7
6
  import { Image } from "../atoms/image.js";
7
+ import * as __rspack_external__zag_js_carousel_a12b93a3 from "@zag-js/carousel";
8
8
  const carouselVariants = tv({
9
9
  slots: {
10
10
  wrapper: [
@@ -186,7 +186,7 @@ const useCarouselContext = ()=>{
186
186
  };
187
187
  function Carousel({ id, size, objectFit, aspectRatio, orientation = "horizontal", slideCount = 1, loop = true, autoplay = false, allowMouseDrag = true, slidesPerPage = 1, slidesPerMove = 1, spacing = "0px", padding = "0px", dir = "ltr", snapType = "mandatory", className, children, width, height, onPageChange, ...props }) {
188
188
  const fallbackId = useId();
189
- const service = useMachine(machine, {
189
+ const service = useMachine(__rspack_external__zag_js_carousel_a12b93a3.machine, {
190
190
  id: id ?? fallbackId,
191
191
  slideCount,
192
192
  autoplay,
@@ -202,7 +202,7 @@ function Carousel({ id, size, objectFit, aspectRatio, orientation = "horizontal"
202
202
  onPageChange,
203
203
  ...props
204
204
  });
205
- const api = connect(service, normalizeProps);
205
+ const api = __rspack_external__zag_js_carousel_a12b93a3.connect(service, normalizeProps);
206
206
  const { wrapper, root } = carouselVariants({
207
207
  size,
208
208
  objectFit,
@@ -158,7 +158,7 @@ function resolveBuild(config) {
158
158
  };
159
159
  }
160
160
  function warnOnSeriesOverflow(data, getColorIdentity) {
161
- const isProduction = "undefined" != typeof process && process.env?.NODE_ENV === "production";
161
+ const isProduction = "u" > typeof process && process.env?.NODE_ENV === "production";
162
162
  if (null == getColorIdentity || isProduction) return;
163
163
  const distinct = new Set(data.map((datum)=>String(getColorIdentity(datum))));
164
164
  if (distinct.size > MAX_SERIES) console.warn(`Chart: ${distinct.size} distinct colors exceeds the ${MAX_SERIES}-color palette; everything beyond the sixth reuses an earlier color and cannot be told apart. Group the long tail into an “Other” bucket, or split into small multiples.`);
@@ -1,10 +1,10 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { connect, machine } from "@zag-js/dialog";
3
2
  import { Portal, normalizeProps, useMachine } from "@zag-js/react";
4
3
  import { useId } from "react";
5
4
  import { tv } from "tailwind-variants";
6
5
  import { ActionIcon } from "../atoms/action-icon.js";
7
6
  import { Button } from "../atoms/button.js";
7
+ import * as __rspack_external__zag_js_dialog_5c81bb31 from "@zag-js/dialog";
8
8
  const dialogVariants = tv({
9
9
  slots: {
10
10
  backdrop: [
@@ -227,7 +227,7 @@ const dialogVariants = tv({
227
227
  function Dialog({ id, open, onOpenChange, initialFocusEl, finalFocusEl, role = "dialog", placement = "center", position = "fixed", size = "md", behavior = "modal", closeOnEscape = true, closeOnInteractOutside = true, preventScroll = true, trapFocus = true, customTrigger = false, triggerText = "Open", title, description, children, hideCloseButton = false, actions, className, modal = true, portal = true }) {
228
228
  const generatedId = useId();
229
229
  const uniqueId = id || generatedId;
230
- const service = useMachine(machine, {
230
+ const service = useMachine(__rspack_external__zag_js_dialog_5c81bb31.machine, {
231
231
  id: uniqueId,
232
232
  onOpenChange,
233
233
  role,
@@ -242,7 +242,7 @@ function Dialog({ id, open, onOpenChange, initialFocusEl, finalFocusEl, role = "
242
242
  open
243
243
  }
244
244
  });
245
- const api = connect(service, normalizeProps);
245
+ const api = __rspack_external__zag_js_dialog_5c81bb31.connect(service, normalizeProps);
246
246
  const contentProps = api.getContentProps();
247
247
  const handleContentKeyDown = (event)=>{
248
248
  contentProps.onKeyDown?.(event);
@@ -0,0 +1,262 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { Portal, mergeProps } from "@zag-js/react";
4
+ import { ActionIcon } from "../atoms/action-icon.js";
5
+ import { Button } from "../atoms/button.js";
6
+ import { DrawerProvider, DrawerStackProvider, getDrawerPresenceProps, useComposedRefs, useDrawer, useDrawerContext, useDrawerPresence, useDrawerStackContext } from "../internal/molecules/drawer.context.js";
7
+ import { drawerVariants } from "../internal/molecules/drawer.styles.js";
8
+ const drawer_useDrawer = useDrawer;
9
+ const swipeDirectionByPlacement = {
10
+ bottom: "down",
11
+ end: "end",
12
+ start: "start",
13
+ top: "up"
14
+ };
15
+ function Drawer({ children, immediate, lazyMount = true, onEnterComplete, onExitComplete, placement = "end", size, skipAnimationOnMount = false, unmountOnExit = true, ...machineProps }) {
16
+ const api = drawer_useDrawer({
17
+ ...machineProps,
18
+ swipeDirection: swipeDirectionByPlacement[placement]
19
+ });
20
+ return /*#__PURE__*/ jsx(DrawerProvider, {
21
+ api: api,
22
+ immediate: immediate,
23
+ lazyMount: lazyMount,
24
+ onEnterComplete: onEnterComplete,
25
+ onExitComplete: onExitComplete,
26
+ size: size,
27
+ skipAnimationOnMount: skipAnimationOnMount,
28
+ unmountOnExit: unmountOnExit,
29
+ children: children
30
+ });
31
+ }
32
+ Drawer.Root = Drawer;
33
+ Drawer.RootProvider = function({ children, immediate, lazyMount = true, onEnterComplete, onExitComplete, size, skipAnimationOnMount = false, unmountOnExit = true, value }) {
34
+ return /*#__PURE__*/ jsx(DrawerProvider, {
35
+ api: value,
36
+ immediate: immediate,
37
+ lazyMount: lazyMount,
38
+ onEnterComplete: onEnterComplete,
39
+ onExitComplete: onExitComplete,
40
+ size: size,
41
+ skipAnimationOnMount: skipAnimationOnMount,
42
+ unmountOnExit: unmountOnExit,
43
+ children: children
44
+ });
45
+ };
46
+ Drawer.Trigger = function({ className, ref, value, ...props }) {
47
+ const { api, styles } = useDrawerContext();
48
+ const mergedProps = mergeProps(api.getTriggerProps({
49
+ value
50
+ }), props);
51
+ return /*#__PURE__*/ jsx(Button, {
52
+ ...mergedProps,
53
+ className: styles.trigger({
54
+ className
55
+ }),
56
+ ref: ref
57
+ });
58
+ };
59
+ Drawer.Portal = function(props) {
60
+ return /*#__PURE__*/ jsx(Portal, {
61
+ ...props
62
+ });
63
+ };
64
+ Drawer.Backdrop = function({ className, ref, ...props }) {
65
+ const { api, presenceOptions, styles } = useDrawerContext();
66
+ const presence = useDrawerPresence({
67
+ ...presenceOptions,
68
+ present: api.open
69
+ });
70
+ const composedRef = useComposedRefs(presence.ref, ref);
71
+ if (presence.unmounted) return null;
72
+ const mergedProps = mergeProps(api.getBackdropProps(), getDrawerPresenceProps(api.open, presence), props);
73
+ return /*#__PURE__*/ jsx("div", {
74
+ ...mergedProps,
75
+ className: styles.backdrop({
76
+ className
77
+ }),
78
+ ref: composedRef
79
+ });
80
+ };
81
+ Drawer.Positioner = function({ className, ref, ...props }) {
82
+ const { api, presence, styles } = useDrawerContext();
83
+ if (presence.unmounted) return null;
84
+ const mergedProps = mergeProps(api.getPositionerProps(), getDrawerPresenceProps(api.open, presence), props);
85
+ return /*#__PURE__*/ jsx("div", {
86
+ ...mergedProps,
87
+ className: styles.positioner({
88
+ className
89
+ }),
90
+ ref: ref
91
+ });
92
+ };
93
+ Drawer.Content = function({ className, draggable = true, ref, ...props }) {
94
+ const { api, presence, styles } = useDrawerContext();
95
+ const composedRef = useComposedRefs(presence.ref, ref);
96
+ if (presence.unmounted) return null;
97
+ const mergedProps = mergeProps(api.getContentProps({
98
+ draggable
99
+ }), getDrawerPresenceProps(api.open, presence), props);
100
+ return /*#__PURE__*/ jsx("div", {
101
+ ...mergedProps,
102
+ className: styles.content({
103
+ className
104
+ }),
105
+ ref: composedRef
106
+ });
107
+ };
108
+ Drawer.Header = function({ className, ref, ...props }) {
109
+ const { styles } = useDrawerContext();
110
+ return /*#__PURE__*/ jsx("div", {
111
+ className: styles.header({
112
+ className
113
+ }),
114
+ ref: ref,
115
+ ...props
116
+ });
117
+ };
118
+ Drawer.Body = function({ className, ref, ...props }) {
119
+ const { styles } = useDrawerContext();
120
+ return /*#__PURE__*/ jsx("div", {
121
+ className: styles.body({
122
+ className
123
+ }),
124
+ ref: ref,
125
+ ...props
126
+ });
127
+ };
128
+ Drawer.Footer = function({ className, ref, ...props }) {
129
+ const { styles } = useDrawerContext();
130
+ return /*#__PURE__*/ jsx("div", {
131
+ className: styles.footer({
132
+ className
133
+ }),
134
+ ref: ref,
135
+ ...props
136
+ });
137
+ };
138
+ Drawer.Title = function({ className, ref, ...props }) {
139
+ const { api, styles } = useDrawerContext();
140
+ return /*#__PURE__*/ jsx("h2", {
141
+ ...mergeProps(api.getTitleProps(), props),
142
+ className: styles.title({
143
+ className
144
+ }),
145
+ ref: ref
146
+ });
147
+ };
148
+ Drawer.Description = function({ className, ref, ...props }) {
149
+ const { api, styles } = useDrawerContext();
150
+ return /*#__PURE__*/ jsx("p", {
151
+ ...mergeProps(api.getDescriptionProps(), props),
152
+ className: styles.description({
153
+ className
154
+ }),
155
+ ref: ref
156
+ });
157
+ };
158
+ Drawer.CloseTrigger = function(props) {
159
+ const { api, styles } = useDrawerContext();
160
+ const { onClick: onMachineClick, ...machineProps } = api.getCloseTriggerProps();
161
+ if (null == props.children) {
162
+ const { children: _children, className: iconClassName, icon: iconName = "token-icon-drawer-close", onClick: onIconClick, ref: iconRef, size: iconSize = "md", tone = "neutral", type: iconType = "button", ...iconProps } = props;
163
+ const mergedProps = mergeProps(iconProps, machineProps);
164
+ return /*#__PURE__*/ jsx(ActionIcon, {
165
+ ...mergedProps,
166
+ "aria-label": mergedProps["aria-label"] ?? "Close drawer",
167
+ className: styles.closeTrigger({
168
+ className: iconClassName
169
+ }),
170
+ icon: iconName,
171
+ onClick: (event)=>{
172
+ onIconClick?.(event);
173
+ if (!event.defaultPrevented) onMachineClick?.(event);
174
+ },
175
+ ref: iconRef,
176
+ size: iconSize,
177
+ tone: tone,
178
+ type: iconType
179
+ });
180
+ }
181
+ const { children, className, icon, onClick, ref, size = "current", theme = "unstyled", type = "button", ...buttonProps } = props;
182
+ const mergedProps = mergeProps(buttonProps, machineProps);
183
+ return /*#__PURE__*/ jsx(Button, {
184
+ ...mergedProps,
185
+ className: styles.closeTrigger({
186
+ className
187
+ }),
188
+ icon: icon,
189
+ onClick: (event)=>{
190
+ onClick?.(event);
191
+ if (!event.defaultPrevented) onMachineClick?.(event);
192
+ },
193
+ ref: ref,
194
+ size: size,
195
+ theme: theme,
196
+ type: type,
197
+ children: children
198
+ });
199
+ };
200
+ Drawer.Grabber = function({ className, ref, ...props }) {
201
+ const { api, styles } = useDrawerContext();
202
+ const mergedProps = mergeProps(api.getGrabberProps(), props);
203
+ return /*#__PURE__*/ jsx("div", {
204
+ ...mergedProps,
205
+ className: styles.grabber({
206
+ className
207
+ }),
208
+ "data-swipe-direction": api.swipeDirection,
209
+ ref: ref
210
+ });
211
+ };
212
+ Drawer.GrabberIndicator = function({ className, ref, ...props }) {
213
+ const { api, styles } = useDrawerContext();
214
+ return /*#__PURE__*/ jsx("div", {
215
+ ...mergeProps(api.getGrabberIndicatorProps(), props),
216
+ className: styles.grabberIndicator({
217
+ className
218
+ }),
219
+ ref: ref
220
+ });
221
+ };
222
+ Drawer.SwipeArea = function({ className, disabled, ref, swipeDirection, ...props }) {
223
+ const { api, styles } = useDrawerContext();
224
+ return /*#__PURE__*/ jsx("div", {
225
+ ...mergeProps(api.getSwipeAreaProps({
226
+ disabled,
227
+ swipeDirection
228
+ }), props),
229
+ className: styles.swipeArea({
230
+ className
231
+ }),
232
+ ref: ref
233
+ });
234
+ };
235
+ Drawer.Context = function({ children }) {
236
+ return children(useDrawerContext().api);
237
+ };
238
+ Drawer.Stack = DrawerStackProvider;
239
+ Drawer.Indent = function({ className, ref, ...props }) {
240
+ const api = useDrawerStackContext();
241
+ const { indent } = drawerVariants();
242
+ return /*#__PURE__*/ jsx("div", {
243
+ ...mergeProps(api.getIndentProps(), props),
244
+ className: indent({
245
+ className
246
+ }),
247
+ ref: ref
248
+ });
249
+ };
250
+ Drawer.IndentBackground = function({ className, ref, ...props }) {
251
+ const api = useDrawerStackContext();
252
+ const { indentBackground } = drawerVariants();
253
+ return /*#__PURE__*/ jsx("div", {
254
+ ...mergeProps(api.getIndentBackgroundProps(), props),
255
+ className: indentBackground({
256
+ className
257
+ }),
258
+ ref: ref
259
+ });
260
+ };
261
+ Drawer.displayName = "Drawer";
262
+ export { Drawer, drawer_useDrawer as useDrawer };