@agnos-ui/core 0.10.0-next.4 → 0.11.0-next.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 (98) hide show
  1. package/{accordion-nxveC0GZ.cjs → accordion-BNq8mApi.cjs} +16 -21
  2. package/{accordion-47EpOD36.js → accordion-CYAFmYRn.js} +19 -24
  3. package/{alert-anMaigvi.js → alert-Cb9FhbFQ.js} +1 -1
  4. package/{collapse-CrfvGo_T.js → collapse-Cg9s33tY.js} +2 -2
  5. package/{collapse-Da_27YUU.cjs → collapse-yKsOxJlH.cjs} +1 -1
  6. package/{common-CCxNtFNM.js → common-DFyZvkII.js} +1 -1
  7. package/components/accordion/accordion.d.ts +18 -8
  8. package/components/accordion/index.cjs +1 -1
  9. package/components/accordion/index.js +3 -3
  10. package/components/alert/common.d.ts +2 -2
  11. package/components/alert/index.js +1 -1
  12. package/components/carousel/index.cjs +1 -1
  13. package/components/carousel/index.js +3 -3
  14. package/components/collapse/collapse.d.ts +3 -3
  15. package/components/collapse/index.cjs +1 -1
  16. package/components/collapse/index.js +1 -1
  17. package/components/drawer/drawer.d.ts +12 -2
  18. package/components/drawer/index.cjs +1 -1
  19. package/components/drawer/index.js +1 -1
  20. package/components/modal/index.cjs +1 -1
  21. package/components/modal/index.js +4 -4
  22. package/components/pagination/index.cjs +1 -1
  23. package/components/pagination/index.js +1 -1
  24. package/components/progressbar/index.cjs +1 -1
  25. package/components/progressbar/index.js +1 -1
  26. package/components/rating/index.cjs +1 -1
  27. package/components/rating/index.js +1 -1
  28. package/components/slider/index.cjs +1 -1
  29. package/components/slider/index.js +1 -1
  30. package/components/toast/index.cjs +1 -1
  31. package/components/toast/index.js +1 -1
  32. package/components/tree/index.cjs +1 -1
  33. package/components/tree/index.js +1 -1
  34. package/config.d.ts +0 -5
  35. package/{dom-Cm9_uROp.cjs → dom-BX4ImCTd.cjs} +28 -4
  36. package/{dom-DD1hAVZy.js → dom-Bb5ZCr_a.js} +49 -25
  37. package/{drawer-CGHyRTM9.js → drawer-CYtNS8c1.js} +16 -9
  38. package/{drawer-B5Yaqpiu.cjs → drawer-DoaLRui_.cjs} +13 -6
  39. package/index.cjs +12 -14
  40. package/index.d.ts +0 -1
  41. package/index.js +56 -58
  42. package/{modal-B_3Uxplo.cjs → modal-CMeWLNO-.cjs} +1 -1
  43. package/{modal-cKd3qUn1.js → modal-EHJERSIp.js} +6 -6
  44. package/package.json +1 -1
  45. package/{pagination-DlOyP_2C.js → pagination-BDKo2d3i.js} +2 -2
  46. package/{pagination-2Vor6JPZ.cjs → pagination-Ddk3z56A.cjs} +1 -1
  47. package/{progressbar-B5g76eMV.js → progressbar-BFdAfV5g.js} +2 -2
  48. package/{progressbar-DyBRINco.cjs → progressbar-ysfDQD0Q.cjs} +1 -1
  49. package/{promise-Y53vc4Ia.js → promise-D-RZVPuv.js} +1 -1
  50. package/{rating-C7C4-p4B.js → rating-D04FQgtR.js} +2 -2
  51. package/{rating-C0y1j4SC.cjs → rating-DO_fKNp3.cjs} +1 -1
  52. package/services/floatingUI.cjs +1 -1
  53. package/services/floatingUI.js +2 -2
  54. package/services/focusElement.cjs +1 -1
  55. package/services/focusElement.js +1 -1
  56. package/services/focustrack.cjs +1 -1
  57. package/services/focustrack.js +1 -1
  58. package/services/matchMedia.cjs +1 -1
  59. package/services/matchMedia.js +1 -1
  60. package/services/navManager.cjs +5 -5
  61. package/services/navManager.js +2 -2
  62. package/services/pointerdownPosition.cjs +1 -1
  63. package/services/pointerdownPosition.js +1 -1
  64. package/services/portal.cjs +1 -1
  65. package/services/portal.js +1 -1
  66. package/services/resizeObserver.cjs +1 -1
  67. package/services/resizeObserver.js +1 -1
  68. package/services/siblingsInert.cjs +1 -1
  69. package/services/siblingsInert.js +1 -1
  70. package/services/transitions/baseTransitions.cjs +1 -1
  71. package/services/transitions/baseTransitions.js +3 -3
  72. package/services/transitions/collapse.cjs +1 -1
  73. package/services/transitions/collapse.js +1 -1
  74. package/services/transitions/cssTransitions.cjs +1 -1
  75. package/services/transitions/cssTransitions.js +2 -2
  76. package/services/transitions/simpleClassTransition.cjs +1 -1
  77. package/services/transitions/simpleClassTransition.js +1 -1
  78. package/{slider-B4WrdTeE.js → slider-BPQIKRKL.js} +3 -3
  79. package/{slider-DTO58syz.cjs → slider-BRktp0--.cjs} +1 -1
  80. package/textDirection-cNgt24LJ.js +4 -0
  81. package/textDirection-zqcZ5-eK.cjs +3 -0
  82. package/{toaster-CT148JSJ.cjs → toaster-Kq-cZoiD.cjs} +1 -1
  83. package/{toaster-CRPErgI2.js → toaster-y_hXuh4o.js} +3 -3
  84. package/{tree-CHpFqJPx.js → tree-AM_J23Hz.js} +2 -2
  85. package/{tree-C4l2Wqny.cjs → tree-BAE89Xjn.cjs} +1 -1
  86. package/utils/directive.cjs +2 -1
  87. package/utils/directive.d.ts +8 -0
  88. package/utils/directive.js +20 -19
  89. package/utils/stores.cjs +5 -2
  90. package/utils/stores.js +6 -3
  91. package/utils/writables.js +11 -11
  92. package/{writables-Is1bF1Vt.js → writables-DYGjj5T3.js} +10 -10
  93. package/components/select/index.cjs +0 -5
  94. package/components/select/index.d.ts +0 -1
  95. package/components/select/index.js +0 -5
  96. package/components/select/select.d.ts +0 -311
  97. package/select-Dhsb9msC.cjs +0 -376
  98. package/select-nnl00UWY.js +0 -377
@@ -1,377 +0,0 @@
1
- import { computed, writable, asWritable, readable, batch } from "@amadeus-it-group/tansu";
2
- import { offset, autoPlacement, size } from "@floating-ui/dom";
3
- import { createFloatingUI } from "./services/floatingUI.js";
4
- import { createHasFocus } from "./services/focustrack.js";
5
- import { createNavManager } from "./services/navManager.js";
6
- import { v as generateId, n as mergeDirectives, p as createAttributesDirective, a as bindDirective } from "./dom-DD1hAVZy.js";
7
- import { noop } from "./utils/func.js";
8
- import { writablesForProps, bindableProp, bindableDerived, stateStores, true$ } from "./utils/stores.js";
9
- import { createWidgetFactory } from "./utils/widget.js";
10
- const defaultConfig = {
11
- id: void 0,
12
- ariaLabel: "Select",
13
- open: false,
14
- disabled: false,
15
- items: [],
16
- filterText: "",
17
- loading: false,
18
- selected: [],
19
- navSelector: (node) => node.querySelectorAll(".au-select-badge,input"),
20
- itemIdFn: (item) => "" + item,
21
- onOpenChange: noop,
22
- onFilterTextChange: noop,
23
- onSelectedChange: noop,
24
- allowedPlacements: ["bottom-start", "top-start", "bottom-end", "top-end"],
25
- className: "",
26
- menuClassName: "",
27
- menuItemClassName: "",
28
- badgeClassName: ""
29
- };
30
- function getSelectDefaultConfig() {
31
- return { ...defaultConfig };
32
- }
33
- const createSelect = createWidgetFactory("select", (config) => {
34
- const [
35
- {
36
- id$: _dirtyId$,
37
- open$: _dirtyOpen$,
38
- filterText$: _dirtyFilterText$,
39
- items$,
40
- itemIdFn$,
41
- onOpenChange$,
42
- onFilterTextChange$,
43
- onSelectedChange$,
44
- allowedPlacements$,
45
- navSelector$,
46
- className$,
47
- badgeClassName$,
48
- ariaLabel$,
49
- menuClassName$,
50
- ...stateProps
51
- },
52
- patch
53
- ] = writablesForProps(defaultConfig, config);
54
- const { selected$ } = stateProps;
55
- const id$ = computed(() => _dirtyId$() ?? generateId());
56
- const filterText$ = bindableProp(_dirtyFilterText$, onFilterTextChange$);
57
- const { hasFocus$, directive: hasFocusDirective } = createHasFocus();
58
- const open$ = bindableDerived(onOpenChange$, [_dirtyOpen$, hasFocus$], ([_dirtyOpen, hasFocus]) => _dirtyOpen && hasFocus);
59
- const selectedContextsMap$ = computed(() => {
60
- const selectedItemsContext = /* @__PURE__ */ new Map();
61
- const itemIdFn = itemIdFn$();
62
- for (const item of selected$()) {
63
- const id = itemIdFn(item);
64
- selectedItemsContext.set(id, {
65
- item,
66
- id: itemIdFn(item),
67
- selected: true
68
- });
69
- }
70
- return selectedItemsContext;
71
- });
72
- const selectedContexts$ = computed(() => [...selectedContextsMap$().values()]);
73
- const highlightedIndex$ = (function() {
74
- const store = writable(0);
75
- return asWritable(store, (index) => {
76
- const { length } = visibleItems$();
77
- if (index != void 0) {
78
- if (!length) {
79
- index = void 0;
80
- } else if (index < 0) {
81
- index = length - 1;
82
- } else if (index >= length) {
83
- index = 0;
84
- }
85
- }
86
- store.set(index);
87
- });
88
- })();
89
- const itemContexts$ = computed(() => {
90
- const itemContexts = /* @__PURE__ */ new Map();
91
- if (open$()) {
92
- const selectedContextsMap = selectedContextsMap$();
93
- const itemIdFn = itemIdFn$();
94
- for (const item of items$()) {
95
- const id = itemIdFn(item);
96
- itemContexts.set(id, {
97
- item,
98
- id,
99
- selected: selectedContextsMap.has(id)
100
- });
101
- }
102
- }
103
- return itemContexts;
104
- });
105
- const visibleItems$ = computed(() => open$() ? [...itemContexts$().values()] : []);
106
- const highlighted$ = computed(() => {
107
- const visibleItems = visibleItems$();
108
- const highlightedIndex = highlightedIndex$();
109
- return visibleItems.length && highlightedIndex != void 0 ? visibleItems[highlightedIndex] : void 0;
110
- });
111
- const {
112
- directives: { floatingDirective, referenceDirective },
113
- stores: { placement$ }
114
- } = createFloatingUI({
115
- props: {
116
- computePositionOptions: asWritable(
117
- computed(() => ({
118
- middleware: [
119
- offset(5),
120
- autoPlacement({
121
- allowedPlacements: allowedPlacements$()
122
- }),
123
- size()
124
- ]
125
- }))
126
- )
127
- }
128
- });
129
- const { directive: navDirective, refreshElements, focusFirst, focusLast, focusLeft, focusRight } = createNavManager();
130
- const navManagerConfig$ = computed(
131
- () => ({
132
- keys: {
133
- Home: focusFirst,
134
- End: focusLast,
135
- ArrowLeft: focusLeft,
136
- ArrowRight: focusRight
137
- },
138
- selector: navSelector$()
139
- })
140
- );
141
- const onRemoveBadge = (event, item) => {
142
- const referenceElement = event.target;
143
- refreshElements();
144
- widget.api.unselect(item);
145
- if (referenceElement instanceof HTMLElement) {
146
- setTimeout(() => {
147
- if (!focusLeft({ event, referenceElement })) {
148
- focusRight({ event, referenceElement });
149
- }
150
- });
151
- }
152
- event.preventDefault();
153
- };
154
- const inputContainerAttributesDirective = createAttributesDirective(() => ({
155
- attributes: {
156
- role: readable("combobox"),
157
- "aria-haspopup": readable("listbox"),
158
- "aria-expanded": computed(() => `${open$()}`),
159
- "aria-controls": computed(() => `${id$()}-menu`)
160
- }
161
- }));
162
- const badgeAttributesDirective = createAttributesDirective((itemContext$) => ({
163
- attributes: {
164
- tabindex: readable(-1),
165
- class: badgeClassName$
166
- },
167
- classNames: {
168
- "au-select-badge": true$
169
- },
170
- events: {
171
- keydown: (event) => {
172
- let keyManaged = false;
173
- switch (event.key) {
174
- case "Backspace":
175
- case "Delete": {
176
- onRemoveBadge(event, itemContext$().item);
177
- keyManaged = true;
178
- break;
179
- }
180
- }
181
- if (keyManaged) {
182
- event.preventDefault();
183
- }
184
- }
185
- }
186
- }));
187
- const menuAttributesDirective = createAttributesDirective(() => ({
188
- attributes: {
189
- role: readable("listbox"),
190
- id: computed(() => `${id$()}-menu`),
191
- "data-popper-placement": placement$,
192
- class: menuClassName$
193
- },
194
- events: {
195
- mousedown: (e) => e.preventDefault()
196
- }
197
- }));
198
- const itemAttributesDirective = createAttributesDirective((itemContext$) => ({
199
- attributes: {
200
- role: readable("option"),
201
- "aria-selected": computed(() => `${itemContext$().selected}`),
202
- style: readable("cursor: pointer")
203
- },
204
- classNames: {
205
- "au-select-item": true$,
206
- selected: computed(() => itemContext$().selected)
207
- },
208
- events: {
209
- click: () => widget.api.toggleItem(itemContext$().item)
210
- }
211
- }));
212
- const inputDirective = createAttributesDirective(() => ({
213
- attributes: {
214
- id: id$,
215
- type: readable("text"),
216
- "aria-label": ariaLabel$,
217
- "aria-autocomplete": readable("list"),
218
- autocorrect: readable("off"),
219
- autocapitalize: readable("none"),
220
- autocomplete: readable("off")
221
- },
222
- classNames: {
223
- "au-select-input": true$
224
- },
225
- events: {
226
- input: (event) => {
227
- const value = event.target.value;
228
- batch(() => {
229
- open$.set(value != null && value !== "");
230
- filterText$.set(value);
231
- });
232
- },
233
- keydown: ({ ctrlKey, key, preventDefault }) => {
234
- let keyManaged = true;
235
- switch (key) {
236
- case "ArrowDown": {
237
- const isOpen = open$();
238
- if (isOpen) {
239
- if (ctrlKey) {
240
- widget.api.highlightLast();
241
- } else {
242
- widget.api.highlightNext();
243
- }
244
- } else {
245
- widget.api.open();
246
- widget.api.highlightFirst();
247
- }
248
- break;
249
- }
250
- case "ArrowUp":
251
- if (ctrlKey) {
252
- widget.api.highlightFirst();
253
- } else {
254
- widget.api.highlightPrevious();
255
- }
256
- break;
257
- case "Enter": {
258
- const itemCtx = highlighted$();
259
- if (itemCtx) {
260
- widget.api.toggleItem(itemCtx.item);
261
- }
262
- break;
263
- }
264
- case "Escape":
265
- open$.set(false);
266
- break;
267
- default:
268
- keyManaged = false;
269
- }
270
- if (keyManaged) {
271
- preventDefault();
272
- }
273
- }
274
- }
275
- }));
276
- const badgeCloseButtonDirective = createAttributesDirective((itemContext$) => ({
277
- events: {
278
- click: (event) => {
279
- onRemoveBadge(event, itemContext$().item);
280
- }
281
- }
282
- }));
283
- const widget = {
284
- ...stateStores({
285
- id$,
286
- visibleItems$,
287
- highlighted$,
288
- open$,
289
- selectedContexts$,
290
- filterText$,
291
- placement$,
292
- className$,
293
- badgeClassName$,
294
- ariaLabel$,
295
- menuClassName$,
296
- ...stateProps
297
- }),
298
- patch,
299
- api: {
300
- clear() {
301
- selected$.set([]);
302
- },
303
- select(item) {
304
- widget.api.toggleItem(item, true);
305
- },
306
- unselect(item) {
307
- widget.api.toggleItem(item, false);
308
- },
309
- toggleItem(item, selected) {
310
- const itemIdFn = itemIdFn$();
311
- const itemId = itemIdFn(item);
312
- const selectedContextsMap = selectedContextsMap$();
313
- const isInSelected = selectedContextsMap.has(itemId);
314
- if (selected == null) {
315
- selected = !isInSelected;
316
- }
317
- if (selected && !itemContexts$().has(itemId) || !selected && !isInSelected) {
318
- return;
319
- }
320
- selected$.update((selectedItems) => {
321
- selectedItems = [...selectedItems];
322
- if (selected && !isInSelected) {
323
- selectedItems.push(item);
324
- } else if (!selected && isInSelected) {
325
- const index = selectedItems.findIndex((item2) => itemIdFn(item2) === itemId);
326
- selectedItems.splice(index, 1);
327
- }
328
- onSelectedChange$()?.(selectedItems);
329
- return selectedItems;
330
- });
331
- },
332
- clearText() {
333
- },
334
- highlight(item) {
335
- const index = visibleItems$().findIndex((itemCtx) => itemCtx.item === item);
336
- highlightedIndex$.set(index === -1 ? void 0 : index);
337
- },
338
- highlightFirst() {
339
- highlightedIndex$.set(0);
340
- },
341
- highlightPrevious() {
342
- highlightedIndex$.update((highlightedIndex) => {
343
- return highlightedIndex != null ? highlightedIndex - 1 : -1;
344
- });
345
- },
346
- highlightNext() {
347
- highlightedIndex$.update((highlightedIndex) => {
348
- return highlightedIndex != null ? highlightedIndex + 1 : Infinity;
349
- });
350
- },
351
- highlightLast() {
352
- highlightedIndex$.set(-1);
353
- },
354
- open: () => widget.api.toggle(true),
355
- close: () => widget.api.toggle(false),
356
- toggle(isOpen) {
357
- open$.update((value) => isOpen != null ? isOpen : !value);
358
- }
359
- },
360
- directives: {
361
- hasFocusDirective,
362
- floatingDirective,
363
- referenceDirective,
364
- inputContainerDirective: mergeDirectives(bindDirective(navDirective, navManagerConfig$), inputContainerAttributesDirective),
365
- badgeAttributesDirective,
366
- menuAttributesDirective,
367
- itemAttributesDirective,
368
- inputDirective,
369
- badgeCloseButtonDirective
370
- }
371
- };
372
- return widget;
373
- });
374
- export {
375
- createSelect as c,
376
- getSelectDefaultConfig as g
377
- };