@design-factory/core 21.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/README.md +3 -0
  2. package/accordion-B0vs8JWM.cjs +314 -0
  3. package/accordion-D9ba0XYq.js +315 -0
  4. package/alert-AhaliJ17.cjs +9 -0
  5. package/alert-Cb9FhbFQ.js +10 -0
  6. package/collapse-Bn8iHKrd.js +95 -0
  7. package/collapse-BnWw4Hnc.cjs +94 -0
  8. package/common-B5jS-Ih_.cjs +73 -0
  9. package/common-DFyZvkII.js +74 -0
  10. package/components/accordion/accordion.d.ts +333 -0
  11. package/components/accordion/index.cjs +7 -0
  12. package/components/accordion/index.d.ts +1 -0
  13. package/components/accordion/index.js +7 -0
  14. package/components/alert/alert.d.ts +37 -0
  15. package/components/alert/common.d.ts +138 -0
  16. package/components/alert/index.cjs +5 -0
  17. package/components/alert/index.d.ts +1 -0
  18. package/components/alert/index.js +5 -0
  19. package/components/carousel/carousel.d.ts +247 -0
  20. package/components/carousel/index.cjs +292 -0
  21. package/components/carousel/index.d.ts +1 -0
  22. package/components/carousel/index.js +292 -0
  23. package/components/collapse/collapse.d.ts +135 -0
  24. package/components/collapse/index.cjs +5 -0
  25. package/components/collapse/index.d.ts +1 -0
  26. package/components/collapse/index.js +5 -0
  27. package/components/commonProps.d.ts +11 -0
  28. package/components/drawer/drawer.d.ts +279 -0
  29. package/components/drawer/index.cjs +5 -0
  30. package/components/drawer/index.d.ts +1 -0
  31. package/components/drawer/index.js +5 -0
  32. package/components/modal/index.cjs +8 -0
  33. package/components/modal/index.d.ts +1 -0
  34. package/components/modal/index.js +8 -0
  35. package/components/modal/modal.d.ts +245 -0
  36. package/components/pagination/index.cjs +5 -0
  37. package/components/pagination/index.d.ts +1 -0
  38. package/components/pagination/index.js +5 -0
  39. package/components/pagination/pagination.d.ts +313 -0
  40. package/components/progressbar/index.cjs +5 -0
  41. package/components/progressbar/index.d.ts +1 -0
  42. package/components/progressbar/index.js +5 -0
  43. package/components/progressbar/progressbar.d.ts +91 -0
  44. package/components/rating/index.cjs +5 -0
  45. package/components/rating/index.d.ts +1 -0
  46. package/components/rating/index.js +5 -0
  47. package/components/rating/rating.d.ts +191 -0
  48. package/components/slider/index.cjs +5 -0
  49. package/components/slider/index.d.ts +1 -0
  50. package/components/slider/index.js +5 -0
  51. package/components/slider/slider-utils.d.ts +25 -0
  52. package/components/slider/slider.d.ts +383 -0
  53. package/components/toast/index.cjs +7 -0
  54. package/components/toast/index.d.ts +2 -0
  55. package/components/toast/index.js +7 -0
  56. package/components/toast/toast.d.ts +66 -0
  57. package/components/toast/toaster.d.ts +128 -0
  58. package/components/tree/index.cjs +5 -0
  59. package/components/tree/index.d.ts +1 -0
  60. package/components/tree/index.js +5 -0
  61. package/components/tree/tree.d.ts +143 -0
  62. package/config.cjs +36 -0
  63. package/config.d.ts +117 -0
  64. package/config.js +36 -0
  65. package/directive-CNNSo5Yn.js +524 -0
  66. package/directive-DyTodNPd.cjs +523 -0
  67. package/drawer-BIIfJa0F.js +329 -0
  68. package/drawer-C8ojtwIn.cjs +328 -0
  69. package/index.cjs +134 -0
  70. package/index.d.ts +29 -0
  71. package/index.js +134 -0
  72. package/isFocusable-Ckwus82R.js +32 -0
  73. package/isFocusable-DfzDLeAN.cjs +31 -0
  74. package/modal-C13G13jV.js +253 -0
  75. package/modal-DWv0VqiG.cjs +252 -0
  76. package/package.json +56 -0
  77. package/pagination-BLVa1UsZ.cjs +254 -0
  78. package/pagination-BQWusWXN.js +255 -0
  79. package/progressbar-RopgvVeA.cjs +86 -0
  80. package/progressbar-S1pNn5rM.js +87 -0
  81. package/promise-CxCD3NYv.cjs +118 -0
  82. package/promise-D-RZVPuv.js +119 -0
  83. package/rating-DWgGgwk3.js +184 -0
  84. package/rating-DZ3OQgtt.cjs +183 -0
  85. package/scrollbars-CT87iv_6.cjs +30 -0
  86. package/scrollbars-CcxSrnCx.js +31 -0
  87. package/services/extendWidget.cjs +41 -0
  88. package/services/extendWidget.d.ts +31 -0
  89. package/services/extendWidget.js +41 -0
  90. package/services/floatingUI.cjs +111 -0
  91. package/services/floatingUI.d.ts +76 -0
  92. package/services/floatingUI.js +111 -0
  93. package/services/focusElement.cjs +46 -0
  94. package/services/focusElement.d.ts +9 -0
  95. package/services/focusElement.js +46 -0
  96. package/services/focustrack.cjs +47 -0
  97. package/services/focustrack.d.ts +40 -0
  98. package/services/focustrack.js +47 -0
  99. package/services/hash.cjs +15 -0
  100. package/services/hash.d.ts +3 -0
  101. package/services/hash.js +15 -0
  102. package/services/intersection.cjs +53 -0
  103. package/services/intersection.d.ts +30 -0
  104. package/services/intersection.js +53 -0
  105. package/services/matchMedia.cjs +14 -0
  106. package/services/matchMedia.d.ts +8 -0
  107. package/services/matchMedia.js +14 -0
  108. package/services/navManager.cjs +166 -0
  109. package/services/navManager.d.ts +144 -0
  110. package/services/navManager.js +166 -0
  111. package/services/pointerdownPosition.cjs +60 -0
  112. package/services/pointerdownPosition.d.ts +42 -0
  113. package/services/pointerdownPosition.js +60 -0
  114. package/services/portal.cjs +42 -0
  115. package/services/portal.d.ts +16 -0
  116. package/services/portal.js +42 -0
  117. package/services/resizeObserver.cjs +54 -0
  118. package/services/resizeObserver.d.ts +18 -0
  119. package/services/resizeObserver.js +54 -0
  120. package/services/siblingsInert.cjs +44 -0
  121. package/services/siblingsInert.d.ts +16 -0
  122. package/services/siblingsInert.js +44 -0
  123. package/services/transitions/baseTransitions.cjs +186 -0
  124. package/services/transitions/baseTransitions.d.ts +166 -0
  125. package/services/transitions/baseTransitions.js +186 -0
  126. package/services/transitions/collapse.cjs +40 -0
  127. package/services/transitions/collapse.d.ts +49 -0
  128. package/services/transitions/collapse.js +40 -0
  129. package/services/transitions/cssTransitions.cjs +32 -0
  130. package/services/transitions/cssTransitions.d.ts +25 -0
  131. package/services/transitions/cssTransitions.js +32 -0
  132. package/services/transitions/simpleClassTransition.cjs +37 -0
  133. package/services/transitions/simpleClassTransition.d.ts +47 -0
  134. package/services/transitions/simpleClassTransition.js +37 -0
  135. package/slider-Br_Qiopx.js +808 -0
  136. package/slider-pgDq1V5r.cjs +807 -0
  137. package/textDirection-cNgt24LJ.js +4 -0
  138. package/textDirection-zqcZ5-eK.cjs +3 -0
  139. package/toaster-BUBzFeJM.js +162 -0
  140. package/toaster-Dlube4Ya.cjs +161 -0
  141. package/tree-Chcy4ulJ.cjs +228 -0
  142. package/tree-vD7ZkV8Z.js +229 -0
  143. package/types.cjs +6 -0
  144. package/types.d.ts +246 -0
  145. package/types.js +6 -0
  146. package/utils/directive.cjs +28 -0
  147. package/utils/directive.d.ts +352 -0
  148. package/utils/directive.js +28 -0
  149. package/utils/func.cjs +7 -0
  150. package/utils/func.d.ts +11 -0
  151. package/utils/func.js +7 -0
  152. package/utils/id.cjs +5 -0
  153. package/utils/id.d.ts +6 -0
  154. package/utils/id.js +5 -0
  155. package/utils/internal/assign.d.ts +10 -0
  156. package/utils/internal/checks.d.ts +57 -0
  157. package/utils/internal/dom.d.ts +75 -0
  158. package/utils/internal/isFocusable.d.ts +9 -0
  159. package/utils/internal/math.d.ts +5 -0
  160. package/utils/internal/promise.d.ts +98 -0
  161. package/utils/internal/scrollbars.d.ts +8 -0
  162. package/utils/internal/sort.d.ts +16 -0
  163. package/utils/internal/ssrHTMLElement.d.ts +17 -0
  164. package/utils/internal/textDirection.d.ts +7 -0
  165. package/utils/internal/traversal.d.ts +54 -0
  166. package/utils/stores.cjs +172 -0
  167. package/utils/stores.d.ts +224 -0
  168. package/utils/stores.js +172 -0
  169. package/utils/widget.cjs +8 -0
  170. package/utils/widget.d.ts +11 -0
  171. package/utils/widget.js +8 -0
  172. package/utils/writables.cjs +16 -0
  173. package/utils/writables.d.ts +95 -0
  174. package/utils/writables.js +16 -0
  175. package/writables-DYGjj5T3.js +103 -0
  176. package/writables-Dt68gADJ.cjs +102 -0
@@ -0,0 +1,329 @@
1
+ import { computed, asWritable, readable, writable, untrack } from "@amadeus-it-group/tansu";
2
+ import { focusElement } from "./services/focusElement.js";
3
+ import { createPointerdownPositionDirective } from "./services/pointerdownPosition.js";
4
+ import { portal } from "./services/portal.js";
5
+ import { siblingsInert } from "./services/siblingsInert.js";
6
+ import { createTransition } from "./services/transitions/baseTransitions.js";
7
+ import { b as bindDirective, i as createBrowserStoreDirective, s as mergeDirectives, g as createAttributesDirective, q as isBrowserHTMLElement, f as conditionalDirective, o as directiveSubscribe } from "./directive-CNNSo5Yn.js";
8
+ import { noop } from "./utils/func.js";
9
+ import { a as revertScrollbars, r as removeScrollbars } from "./scrollbars-CcxSrnCx.js";
10
+ import { writablesForProps, bindableProp, stateStores, true$ } from "./utils/stores.js";
11
+ import { createWidgetFactory } from "./utils/widget.js";
12
+ import { b as typeBoolean, i as typeNumberOrNull, e as typeFunction, f as typeHTMLElementOrNull, j as typeString, c as createTypeEnum } from "./writables-DYGjj5T3.js";
13
+ import { g as getTextDirection } from "./textDirection-cNgt24LJ.js";
14
+ function getDrawerDefaultConfig() {
15
+ return {
16
+ ...defaultDrawerConfig
17
+ };
18
+ }
19
+ const defaultDrawerConfig = {
20
+ animated: true,
21
+ ariaDescribedBy: "",
22
+ ariaLabelledBy: "",
23
+ backdropClass: "",
24
+ backdropTransition: noop,
25
+ className: "",
26
+ visible: false,
27
+ container: typeof window !== "undefined" ? document.body : null,
28
+ transition: noop,
29
+ verticalTransition: noop,
30
+ onHidden: noop,
31
+ onShown: noop,
32
+ onSizeChange: noop,
33
+ onVisibleChange: noop,
34
+ onMinimizedChange: noop,
35
+ onMaximizedChange: noop,
36
+ onResizingChange: noop,
37
+ resizable: false,
38
+ backdrop: true,
39
+ bodyScroll: false,
40
+ size: null,
41
+ focusOnInit: true,
42
+ configuration: "overlay",
43
+ position: "inline-start"
44
+ };
45
+ const configValidator = {
46
+ animated: typeBoolean,
47
+ ariaDescribedBy: typeString,
48
+ ariaLabelledBy: typeString,
49
+ backdropClass: typeString,
50
+ backdropTransition: typeFunction,
51
+ className: typeString,
52
+ visible: typeBoolean,
53
+ transition: typeFunction,
54
+ verticalTransition: typeFunction,
55
+ container: typeHTMLElementOrNull,
56
+ onHidden: typeFunction,
57
+ onShown: typeFunction,
58
+ onSizeChange: typeFunction,
59
+ onVisibleChange: typeFunction,
60
+ onMinimizedChange: typeFunction,
61
+ onMaximizedChange: typeFunction,
62
+ onResizingChange: typeFunction,
63
+ resizable: typeBoolean,
64
+ backdrop: typeBoolean,
65
+ bodyScroll: typeBoolean,
66
+ size: typeNumberOrNull,
67
+ focusOnInit: typeBoolean,
68
+ configuration: createTypeEnum(["inline", "overlay"]),
69
+ position: createTypeEnum(["inline-start", "inline-end", "block-start", "block-end"])
70
+ };
71
+ const createDrawer = createWidgetFactory(
72
+ "drawer",
73
+ (config) => {
74
+ const [
75
+ {
76
+ backdrop$: _backdrop$,
77
+ backdropTransition$,
78
+ backdropClass$,
79
+ bodyScroll$: _bodyScroll$,
80
+ transition$,
81
+ verticalTransition$,
82
+ visible$: requestedVisible$,
83
+ container$: _container$,
84
+ className$,
85
+ size$: _dirtySize$,
86
+ animated$,
87
+ ariaDescribedBy$,
88
+ ariaLabelledBy$,
89
+ onHidden$,
90
+ onShown$,
91
+ onSizeChange$,
92
+ onVisibleChange$,
93
+ onMinimizedChange$,
94
+ onMaximizedChange$,
95
+ onResizingChange$,
96
+ focusOnInit$,
97
+ configuration$,
98
+ position$,
99
+ ...stateProps
100
+ },
101
+ patch
102
+ ] = writablesForProps(defaultDrawerConfig, config, configValidator);
103
+ const inline$ = computed(() => configuration$() === "inline");
104
+ const backdrop$ = computed(() => inline$() ? false : _backdrop$());
105
+ const bodyScroll$ = computed(() => inline$() ? true : _bodyScroll$());
106
+ const container$ = computed(() => inline$() ? null : _container$());
107
+ const size$ = bindableProp(_dirtySize$, onSizeChange$, (value) => value ? Math.round(value) : value);
108
+ const isVertical$ = computed(() => {
109
+ const position = position$();
110
+ return position === "block-start" || position === "block-end";
111
+ });
112
+ const combinedClass$ = computed(() => `df-${position$()} ${className$()}`);
113
+ const transition = createTransition({
114
+ props: {
115
+ animated: animated$,
116
+ animatedOnInit: animated$,
117
+ transition: asWritable(computed(() => isVertical$() ? verticalTransition$() : transition$())),
118
+ visible: requestedVisible$,
119
+ onVisibleChange: onVisibleChange$,
120
+ onHidden: onHidden$,
121
+ onShown: onShown$
122
+ }
123
+ });
124
+ const drawerPortalDirective = bindDirective(
125
+ portal,
126
+ computed(() => ({ container: container$() }))
127
+ );
128
+ const { directive: drawerElementDirective, element$: drawerElement$ } = createBrowserStoreDirective();
129
+ const drawerAttributeDirective = mergeDirectives(
130
+ drawerElementDirective,
131
+ createAttributesDirective(() => ({
132
+ attributes: {
133
+ class: combinedClass$,
134
+ role: computed(() => inline$() ? "complementary" : "dialog"),
135
+ "aria-describedby": computed(() => ariaDescribedBy$() || void 0),
136
+ "aria-labelledby": computed(() => ariaLabelledBy$() || void 0),
137
+ "aria-modal": computed(() => inline$() ? void 0 : "true"),
138
+ tabIndex: readable("-1")
139
+ },
140
+ styles: {
141
+ position: computed(() => {
142
+ if (inline$()) {
143
+ return "relative";
144
+ }
145
+ const container = container$();
146
+ return container && isBrowserHTMLElement(container) && container !== document.body ? "relative" : "fixed";
147
+ }),
148
+ outline: readable("none")
149
+ },
150
+ events: {
151
+ keydown: (e) => {
152
+ if (e.key === "Escape") {
153
+ void transition.api.hide();
154
+ }
155
+ }
156
+ }
157
+ }))
158
+ );
159
+ const backdropTransition = createTransition({
160
+ props: {
161
+ animated: animated$,
162
+ transition: backdropTransition$
163
+ }
164
+ });
165
+ const backdropPortalDirective = bindDirective(
166
+ portal,
167
+ computed(() => {
168
+ const container = container$();
169
+ const element = container ? transition.stores.element$() : void 0;
170
+ return {
171
+ container,
172
+ insertBefore: element?.parentElement === container ? element : void 0
173
+ };
174
+ })
175
+ );
176
+ const backdropHidden$ = computed(() => {
177
+ if (!bodyScroll$()) {
178
+ if (hidden$()) {
179
+ revertScrollbars();
180
+ } else {
181
+ removeScrollbars();
182
+ }
183
+ }
184
+ return !backdrop$() || hidden$();
185
+ });
186
+ const backdropAttributeDirective = createAttributesDirective(() => ({
187
+ attributes: {
188
+ class: backdropClass$,
189
+ "data-agnos-ignore-inert": true$
190
+ },
191
+ events: {
192
+ click: () => void transition.api.hide()
193
+ }
194
+ }));
195
+ const direction$ = computed(() => {
196
+ const position = position$();
197
+ return position === "inline-start" || position === "block-start" ? 1 : -1;
198
+ });
199
+ const isMinimized$ = writable(void 0);
200
+ const isMaximized$ = writable(void 0);
201
+ function setSize(size) {
202
+ const drawerElement = drawerElement$();
203
+ const isVertical = isVertical$();
204
+ size = Math.round(Math.max(0, size));
205
+ drawerElement.style[isVertical ? "height" : "width"] = `${size}px`;
206
+ const elementSize = Math.round(drawerElement[isVertical ? "offsetHeight" : "offsetWidth"]);
207
+ size$.set(elementSize);
208
+ isMinimized$.set(size != null && (size < elementSize || size === 0));
209
+ isMaximized$.set(!!size && size > elementSize);
210
+ return elementSize;
211
+ }
212
+ const splitterDirective = mergeDirectives(
213
+ createPointerdownPositionDirective((event) => {
214
+ const drawerElement = drawerElement$();
215
+ const isVertical = isVertical$();
216
+ const documentDirection = getTextDirection(drawerElement) === "ltr" ? 1 : -1;
217
+ const directionFactor = isVertical ? 1 : documentDirection;
218
+ const startSize = drawerElement[isVertical ? "offsetHeight" : "offsetWidth"];
219
+ const clientXorY = isVertical ? "clientY" : "clientX";
220
+ const startPos = event[clientXorY];
221
+ const direction = direction$();
222
+ let isResizing = false;
223
+ return {
224
+ onMove(event2) {
225
+ setSize(startSize + directionFactor * direction * (event2[clientXorY] - startPos));
226
+ if (!isResizing) {
227
+ isResizing = true;
228
+ onResizingChange$()(true);
229
+ }
230
+ },
231
+ onEnd() {
232
+ drawerElement.style[isVertical ? "height" : "width"] = "";
233
+ if (isResizing) {
234
+ onResizingChange$()(false);
235
+ isResizing = false;
236
+ }
237
+ }
238
+ };
239
+ }),
240
+ createAttributesDirective(() => ({
241
+ events: {
242
+ keydown: (e) => {
243
+ const { key } = e;
244
+ const size = size$() || drawerElement$()?.[isVertical$() ? "offsetHeight" : "offsetWidth"];
245
+ if (size != null) {
246
+ switch (key) {
247
+ case "ArrowLeft":
248
+ case "ArrowDown":
249
+ onResizingChange$()(true);
250
+ setSize(size - 10);
251
+ onResizingChange$()(false);
252
+ break;
253
+ case "ArrowRight":
254
+ case "ArrowUp":
255
+ onResizingChange$()(true);
256
+ setSize(size + 10);
257
+ onResizingChange$()(false);
258
+ break;
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }))
264
+ );
265
+ const visible$ = transition.stores.visible$;
266
+ const transitioning$ = computed(
267
+ () => transition.stores.transitioning$() || backdropTransition.stores.transitioning$()
268
+ );
269
+ const hidden$ = computed(() => !transitioning$() && !visible$());
270
+ const minSizeAction$ = computed(() => {
271
+ const isMinimized = isMinimized$();
272
+ if (isMinimized != null) {
273
+ untrack(() => onMinimizedChange$()(isMinimized));
274
+ }
275
+ });
276
+ const maxSizeAction$ = computed(() => {
277
+ const isMaximized = isMaximized$();
278
+ if (isMaximized != null) {
279
+ untrack(() => onMaximizedChange$()(isMaximized));
280
+ }
281
+ });
282
+ const action$ = computed(() => {
283
+ minSizeAction$();
284
+ maxSizeAction$();
285
+ });
286
+ const widget = {
287
+ ...stateStores({
288
+ ...stateProps,
289
+ backdropClass$,
290
+ className$,
291
+ position$,
292
+ container$,
293
+ size$,
294
+ visible$,
295
+ backdropHidden$,
296
+ hidden$,
297
+ isVertical$,
298
+ configuration$
299
+ }),
300
+ patch,
301
+ api: {
302
+ open: transition.api.show,
303
+ close: transition.api.hide
304
+ },
305
+ directives: {
306
+ drawerPortalDirective,
307
+ drawerDirective: mergeDirectives(
308
+ directiveSubscribe(action$),
309
+ drawerAttributeDirective,
310
+ bindDirective(
311
+ siblingsInert,
312
+ computed(() => !bodyScroll$())
313
+ ),
314
+ // This directive must come after the attribute directive, to ensure that all the classes and attributes are applied for the transition
315
+ transition.directives.directive,
316
+ conditionalDirective(focusElement, focusOnInit$)
317
+ ),
318
+ backdropPortalDirective,
319
+ backdropDirective: mergeDirectives(backdropTransition.directives.directive, backdropAttributeDirective),
320
+ splitterDirective
321
+ }
322
+ };
323
+ return widget;
324
+ }
325
+ );
326
+ export {
327
+ createDrawer as c,
328
+ getDrawerDefaultConfig as g
329
+ };
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+ const tansu = require("@amadeus-it-group/tansu");
3
+ const services_focusElement = require("./services/focusElement.cjs");
4
+ const services_pointerdownPosition = require("./services/pointerdownPosition.cjs");
5
+ const services_portal = require("./services/portal.cjs");
6
+ const services_siblingsInert = require("./services/siblingsInert.cjs");
7
+ const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
8
+ const utils_directive = require("./directive-DyTodNPd.cjs");
9
+ const utils_func = require("./utils/func.cjs");
10
+ const scrollbars = require("./scrollbars-CT87iv_6.cjs");
11
+ const utils_stores = require("./utils/stores.cjs");
12
+ const utils_widget = require("./utils/widget.cjs");
13
+ const utils_writables = require("./writables-Dt68gADJ.cjs");
14
+ const textDirection = require("./textDirection-zqcZ5-eK.cjs");
15
+ function getDrawerDefaultConfig() {
16
+ return {
17
+ ...defaultDrawerConfig
18
+ };
19
+ }
20
+ const defaultDrawerConfig = {
21
+ animated: true,
22
+ ariaDescribedBy: "",
23
+ ariaLabelledBy: "",
24
+ backdropClass: "",
25
+ backdropTransition: utils_func.noop,
26
+ className: "",
27
+ visible: false,
28
+ container: typeof window !== "undefined" ? document.body : null,
29
+ transition: utils_func.noop,
30
+ verticalTransition: utils_func.noop,
31
+ onHidden: utils_func.noop,
32
+ onShown: utils_func.noop,
33
+ onSizeChange: utils_func.noop,
34
+ onVisibleChange: utils_func.noop,
35
+ onMinimizedChange: utils_func.noop,
36
+ onMaximizedChange: utils_func.noop,
37
+ onResizingChange: utils_func.noop,
38
+ resizable: false,
39
+ backdrop: true,
40
+ bodyScroll: false,
41
+ size: null,
42
+ focusOnInit: true,
43
+ configuration: "overlay",
44
+ position: "inline-start"
45
+ };
46
+ const configValidator = {
47
+ animated: utils_writables.typeBoolean,
48
+ ariaDescribedBy: utils_writables.typeString,
49
+ ariaLabelledBy: utils_writables.typeString,
50
+ backdropClass: utils_writables.typeString,
51
+ backdropTransition: utils_writables.typeFunction,
52
+ className: utils_writables.typeString,
53
+ visible: utils_writables.typeBoolean,
54
+ transition: utils_writables.typeFunction,
55
+ verticalTransition: utils_writables.typeFunction,
56
+ container: utils_writables.typeHTMLElementOrNull,
57
+ onHidden: utils_writables.typeFunction,
58
+ onShown: utils_writables.typeFunction,
59
+ onSizeChange: utils_writables.typeFunction,
60
+ onVisibleChange: utils_writables.typeFunction,
61
+ onMinimizedChange: utils_writables.typeFunction,
62
+ onMaximizedChange: utils_writables.typeFunction,
63
+ onResizingChange: utils_writables.typeFunction,
64
+ resizable: utils_writables.typeBoolean,
65
+ backdrop: utils_writables.typeBoolean,
66
+ bodyScroll: utils_writables.typeBoolean,
67
+ size: utils_writables.typeNumberOrNull,
68
+ focusOnInit: utils_writables.typeBoolean,
69
+ configuration: utils_writables.createTypeEnum(["inline", "overlay"]),
70
+ position: utils_writables.createTypeEnum(["inline-start", "inline-end", "block-start", "block-end"])
71
+ };
72
+ const createDrawer = utils_widget.createWidgetFactory(
73
+ "drawer",
74
+ (config) => {
75
+ const [
76
+ {
77
+ backdrop$: _backdrop$,
78
+ backdropTransition$,
79
+ backdropClass$,
80
+ bodyScroll$: _bodyScroll$,
81
+ transition$,
82
+ verticalTransition$,
83
+ visible$: requestedVisible$,
84
+ container$: _container$,
85
+ className$,
86
+ size$: _dirtySize$,
87
+ animated$,
88
+ ariaDescribedBy$,
89
+ ariaLabelledBy$,
90
+ onHidden$,
91
+ onShown$,
92
+ onSizeChange$,
93
+ onVisibleChange$,
94
+ onMinimizedChange$,
95
+ onMaximizedChange$,
96
+ onResizingChange$,
97
+ focusOnInit$,
98
+ configuration$,
99
+ position$,
100
+ ...stateProps
101
+ },
102
+ patch
103
+ ] = utils_stores.writablesForProps(defaultDrawerConfig, config, configValidator);
104
+ const inline$ = tansu.computed(() => configuration$() === "inline");
105
+ const backdrop$ = tansu.computed(() => inline$() ? false : _backdrop$());
106
+ const bodyScroll$ = tansu.computed(() => inline$() ? true : _bodyScroll$());
107
+ const container$ = tansu.computed(() => inline$() ? null : _container$());
108
+ const size$ = utils_stores.bindableProp(_dirtySize$, onSizeChange$, (value) => value ? Math.round(value) : value);
109
+ const isVertical$ = tansu.computed(() => {
110
+ const position = position$();
111
+ return position === "block-start" || position === "block-end";
112
+ });
113
+ const combinedClass$ = tansu.computed(() => `df-${position$()} ${className$()}`);
114
+ const transition = services_transitions_baseTransitions.createTransition({
115
+ props: {
116
+ animated: animated$,
117
+ animatedOnInit: animated$,
118
+ transition: tansu.asWritable(tansu.computed(() => isVertical$() ? verticalTransition$() : transition$())),
119
+ visible: requestedVisible$,
120
+ onVisibleChange: onVisibleChange$,
121
+ onHidden: onHidden$,
122
+ onShown: onShown$
123
+ }
124
+ });
125
+ const drawerPortalDirective = utils_directive.bindDirective(
126
+ services_portal.portal,
127
+ tansu.computed(() => ({ container: container$() }))
128
+ );
129
+ const { directive: drawerElementDirective, element$: drawerElement$ } = utils_directive.createBrowserStoreDirective();
130
+ const drawerAttributeDirective = utils_directive.mergeDirectives(
131
+ drawerElementDirective,
132
+ utils_directive.createAttributesDirective(() => ({
133
+ attributes: {
134
+ class: combinedClass$,
135
+ role: tansu.computed(() => inline$() ? "complementary" : "dialog"),
136
+ "aria-describedby": tansu.computed(() => ariaDescribedBy$() || void 0),
137
+ "aria-labelledby": tansu.computed(() => ariaLabelledBy$() || void 0),
138
+ "aria-modal": tansu.computed(() => inline$() ? void 0 : "true"),
139
+ tabIndex: tansu.readable("-1")
140
+ },
141
+ styles: {
142
+ position: tansu.computed(() => {
143
+ if (inline$()) {
144
+ return "relative";
145
+ }
146
+ const container = container$();
147
+ return container && utils_directive.isBrowserHTMLElement(container) && container !== document.body ? "relative" : "fixed";
148
+ }),
149
+ outline: tansu.readable("none")
150
+ },
151
+ events: {
152
+ keydown: (e) => {
153
+ if (e.key === "Escape") {
154
+ void transition.api.hide();
155
+ }
156
+ }
157
+ }
158
+ }))
159
+ );
160
+ const backdropTransition = services_transitions_baseTransitions.createTransition({
161
+ props: {
162
+ animated: animated$,
163
+ transition: backdropTransition$
164
+ }
165
+ });
166
+ const backdropPortalDirective = utils_directive.bindDirective(
167
+ services_portal.portal,
168
+ tansu.computed(() => {
169
+ const container = container$();
170
+ const element = container ? transition.stores.element$() : void 0;
171
+ return {
172
+ container,
173
+ insertBefore: element?.parentElement === container ? element : void 0
174
+ };
175
+ })
176
+ );
177
+ const backdropHidden$ = tansu.computed(() => {
178
+ if (!bodyScroll$()) {
179
+ if (hidden$()) {
180
+ scrollbars.revertScrollbars();
181
+ } else {
182
+ scrollbars.removeScrollbars();
183
+ }
184
+ }
185
+ return !backdrop$() || hidden$();
186
+ });
187
+ const backdropAttributeDirective = utils_directive.createAttributesDirective(() => ({
188
+ attributes: {
189
+ class: backdropClass$,
190
+ "data-agnos-ignore-inert": utils_stores.true$
191
+ },
192
+ events: {
193
+ click: () => void transition.api.hide()
194
+ }
195
+ }));
196
+ const direction$ = tansu.computed(() => {
197
+ const position = position$();
198
+ return position === "inline-start" || position === "block-start" ? 1 : -1;
199
+ });
200
+ const isMinimized$ = tansu.writable(void 0);
201
+ const isMaximized$ = tansu.writable(void 0);
202
+ function setSize(size) {
203
+ const drawerElement = drawerElement$();
204
+ const isVertical = isVertical$();
205
+ size = Math.round(Math.max(0, size));
206
+ drawerElement.style[isVertical ? "height" : "width"] = `${size}px`;
207
+ const elementSize = Math.round(drawerElement[isVertical ? "offsetHeight" : "offsetWidth"]);
208
+ size$.set(elementSize);
209
+ isMinimized$.set(size != null && (size < elementSize || size === 0));
210
+ isMaximized$.set(!!size && size > elementSize);
211
+ return elementSize;
212
+ }
213
+ const splitterDirective = utils_directive.mergeDirectives(
214
+ services_pointerdownPosition.createPointerdownPositionDirective((event) => {
215
+ const drawerElement = drawerElement$();
216
+ const isVertical = isVertical$();
217
+ const documentDirection = textDirection.getTextDirection(drawerElement) === "ltr" ? 1 : -1;
218
+ const directionFactor = isVertical ? 1 : documentDirection;
219
+ const startSize = drawerElement[isVertical ? "offsetHeight" : "offsetWidth"];
220
+ const clientXorY = isVertical ? "clientY" : "clientX";
221
+ const startPos = event[clientXorY];
222
+ const direction = direction$();
223
+ let isResizing = false;
224
+ return {
225
+ onMove(event2) {
226
+ setSize(startSize + directionFactor * direction * (event2[clientXorY] - startPos));
227
+ if (!isResizing) {
228
+ isResizing = true;
229
+ onResizingChange$()(true);
230
+ }
231
+ },
232
+ onEnd() {
233
+ drawerElement.style[isVertical ? "height" : "width"] = "";
234
+ if (isResizing) {
235
+ onResizingChange$()(false);
236
+ isResizing = false;
237
+ }
238
+ }
239
+ };
240
+ }),
241
+ utils_directive.createAttributesDirective(() => ({
242
+ events: {
243
+ keydown: (e) => {
244
+ const { key } = e;
245
+ const size = size$() || drawerElement$()?.[isVertical$() ? "offsetHeight" : "offsetWidth"];
246
+ if (size != null) {
247
+ switch (key) {
248
+ case "ArrowLeft":
249
+ case "ArrowDown":
250
+ onResizingChange$()(true);
251
+ setSize(size - 10);
252
+ onResizingChange$()(false);
253
+ break;
254
+ case "ArrowRight":
255
+ case "ArrowUp":
256
+ onResizingChange$()(true);
257
+ setSize(size + 10);
258
+ onResizingChange$()(false);
259
+ break;
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }))
265
+ );
266
+ const visible$ = transition.stores.visible$;
267
+ const transitioning$ = tansu.computed(
268
+ () => transition.stores.transitioning$() || backdropTransition.stores.transitioning$()
269
+ );
270
+ const hidden$ = tansu.computed(() => !transitioning$() && !visible$());
271
+ const minSizeAction$ = tansu.computed(() => {
272
+ const isMinimized = isMinimized$();
273
+ if (isMinimized != null) {
274
+ tansu.untrack(() => onMinimizedChange$()(isMinimized));
275
+ }
276
+ });
277
+ const maxSizeAction$ = tansu.computed(() => {
278
+ const isMaximized = isMaximized$();
279
+ if (isMaximized != null) {
280
+ tansu.untrack(() => onMaximizedChange$()(isMaximized));
281
+ }
282
+ });
283
+ const action$ = tansu.computed(() => {
284
+ minSizeAction$();
285
+ maxSizeAction$();
286
+ });
287
+ const widget = {
288
+ ...utils_stores.stateStores({
289
+ ...stateProps,
290
+ backdropClass$,
291
+ className$,
292
+ position$,
293
+ container$,
294
+ size$,
295
+ visible$,
296
+ backdropHidden$,
297
+ hidden$,
298
+ isVertical$,
299
+ configuration$
300
+ }),
301
+ patch,
302
+ api: {
303
+ open: transition.api.show,
304
+ close: transition.api.hide
305
+ },
306
+ directives: {
307
+ drawerPortalDirective,
308
+ drawerDirective: utils_directive.mergeDirectives(
309
+ utils_directive.directiveSubscribe(action$),
310
+ drawerAttributeDirective,
311
+ utils_directive.bindDirective(
312
+ services_siblingsInert.siblingsInert,
313
+ tansu.computed(() => !bodyScroll$())
314
+ ),
315
+ // This directive must come after the attribute directive, to ensure that all the classes and attributes are applied for the transition
316
+ transition.directives.directive,
317
+ utils_directive.conditionalDirective(services_focusElement.focusElement, focusOnInit$)
318
+ ),
319
+ backdropPortalDirective,
320
+ backdropDirective: utils_directive.mergeDirectives(backdropTransition.directives.directive, backdropAttributeDirective),
321
+ splitterDirective
322
+ }
323
+ };
324
+ return widget;
325
+ }
326
+ );
327
+ exports.createDrawer = createDrawer;
328
+ exports.getDrawerDefaultConfig = getDrawerDefaultConfig;