@design-factory/core 21.1.0 → 22.0.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 (131) hide show
  1. package/{accordion-D9ba0XYq.js → accordion-DUFLBQkV.js} +90 -28
  2. package/alert-Db6cG6JE.js +125 -0
  3. package/{collapse-Bn8iHKrd.js → collapse-D8Jo56k9.js} +2 -2
  4. package/{common-DFyZvkII.js → common-CP4amR0Z.js} +2 -2
  5. package/components/accordion/accordion.d.ts +80 -22
  6. package/components/accordion/index.js +1 -1
  7. package/components/alert/alert.d.ts +77 -8
  8. package/components/alert/common.d.ts +9 -9
  9. package/components/alert/index.js +2 -3
  10. package/components/carousel/index.js +2 -2
  11. package/components/collapse/index.js +1 -1
  12. package/components/drawer/drawer.d.ts +13 -0
  13. package/components/drawer/index.js +1 -1
  14. package/components/dropdown/dropdown.d.ts +110 -0
  15. package/components/dropdown/index.d.ts +1 -0
  16. package/components/dropdown/index.js +5 -0
  17. package/components/modal/index.js +1 -1
  18. package/components/pagination/index.js +1 -1
  19. package/components/progressbar/index.js +1 -1
  20. package/components/rating/index.js +1 -1
  21. package/components/slider/index.js +1 -1
  22. package/components/slider/slider.d.ts +23 -4
  23. package/components/toast/index.js +1 -1
  24. package/components/tooltip/index.d.ts +1 -0
  25. package/components/tooltip/index.js +174 -0
  26. package/components/tooltip/tooltip.d.ts +63 -0
  27. package/components/tree/index.js +1 -1
  28. package/{directive-CNNSo5Yn.js → directive-CMT2vEDg.js} +7 -4
  29. package/{drawer-CoBXUPyv.js → drawer-D4xSbhcT.js} +19 -5
  30. package/dropdown-Bjj2ql6d.js +246 -0
  31. package/index.d.ts +3 -1
  32. package/index.js +45 -39
  33. package/isFocusable-C2iRr0zh.js +72 -0
  34. package/{modal-BH9nrwVz.js → modal-CQWh2Sm5.js} +3 -3
  35. package/package.json +1 -1
  36. package/{pagination-BQWusWXN.js → pagination-DIRcpdRE.js} +2 -2
  37. package/{progressbar-S1pNn5rM.js → progressbar-Bth8r3Qu.js} +2 -2
  38. package/{promise-D-RZVPuv.js → promise-CkIc0KKt.js} +3 -3
  39. package/{rating-DWgGgwk3.js → rating-DLsgFSyB.js} +2 -2
  40. package/services/extendWidget.d.ts +1 -1
  41. package/services/focusElement.js +2 -2
  42. package/services/focustrack.js +2 -2
  43. package/services/matchMedia.js +1 -1
  44. package/services/mousetrack.d.ts +34 -0
  45. package/services/mousetrack.js +41 -0
  46. package/services/navManager.js +2 -2
  47. package/services/pointerdownPosition.js +1 -1
  48. package/services/portal.js +1 -1
  49. package/services/positioning.d.ts +101 -0
  50. package/services/positioning.js +104 -0
  51. package/services/resizeObserver.js +1 -1
  52. package/services/siblingsInert.js +1 -1
  53. package/services/transitions/baseTransitions.js +8 -8
  54. package/services/transitions/collapse.d.ts +4 -0
  55. package/services/transitions/collapse.js +23 -19
  56. package/services/transitions/cssTransitions.js +2 -2
  57. package/services/transitions/simpleClassTransition.js +1 -1
  58. package/{slider-Br_Qiopx.js → slider-tH5g55yQ.js} +132 -97
  59. package/{toaster-BUBzFeJM.js → toaster-BS9qeRLF.js} +3 -3
  60. package/{tree-vD7ZkV8Z.js → tree-DW6iLxdw.js} +2 -2
  61. package/types.d.ts +8 -1
  62. package/utils/debounceSignal.d.ts +11 -0
  63. package/utils/debounceSignal.js +18 -0
  64. package/utils/directive.js +1 -1
  65. package/utils/edgeState.d.ts +23 -0
  66. package/utils/edgeState.js +43 -0
  67. package/utils/internal/isFocusable.d.ts +40 -0
  68. package/utils/stores.d.ts +2 -16
  69. package/utils/stores.js +5 -24
  70. package/utils/writables.d.ts +27 -13
  71. package/utils/writables.js +12 -11
  72. package/{writables-DYGjj5T3.js → writables-_7BriMb2.js} +37 -12
  73. package/accordion-B0vs8JWM.cjs +0 -314
  74. package/alert-AhaliJ17.cjs +0 -9
  75. package/alert-Cb9FhbFQ.js +0 -10
  76. package/collapse-BnWw4Hnc.cjs +0 -94
  77. package/common-B5jS-Ih_.cjs +0 -73
  78. package/components/accordion/index.cjs +0 -7
  79. package/components/alert/index.cjs +0 -5
  80. package/components/carousel/index.cjs +0 -292
  81. package/components/collapse/index.cjs +0 -5
  82. package/components/drawer/index.cjs +0 -5
  83. package/components/modal/index.cjs +0 -8
  84. package/components/pagination/index.cjs +0 -5
  85. package/components/progressbar/index.cjs +0 -5
  86. package/components/rating/index.cjs +0 -5
  87. package/components/slider/index.cjs +0 -5
  88. package/components/toast/index.cjs +0 -7
  89. package/components/tree/index.cjs +0 -5
  90. package/config.cjs +0 -36
  91. package/directive-DyTodNPd.cjs +0 -523
  92. package/drawer-Ca_ktkEs.cjs +0 -328
  93. package/index.cjs +0 -134
  94. package/isFocusable-Ckwus82R.js +0 -32
  95. package/isFocusable-DfzDLeAN.cjs +0 -31
  96. package/modal-Dxdw2Pkv.cjs +0 -252
  97. package/pagination-BLVa1UsZ.cjs +0 -254
  98. package/progressbar-RopgvVeA.cjs +0 -86
  99. package/promise-CxCD3NYv.cjs +0 -118
  100. package/rating-DZ3OQgtt.cjs +0 -183
  101. package/scrollbars-f651ntzz.cjs +0 -33
  102. package/services/extendWidget.cjs +0 -41
  103. package/services/floatingUI.cjs +0 -111
  104. package/services/floatingUI.d.ts +0 -76
  105. package/services/floatingUI.js +0 -111
  106. package/services/focusElement.cjs +0 -46
  107. package/services/focustrack.cjs +0 -47
  108. package/services/hash.cjs +0 -15
  109. package/services/intersection.cjs +0 -53
  110. package/services/matchMedia.cjs +0 -14
  111. package/services/navManager.cjs +0 -166
  112. package/services/pointerdownPosition.cjs +0 -60
  113. package/services/portal.cjs +0 -42
  114. package/services/resizeObserver.cjs +0 -54
  115. package/services/siblingsInert.cjs +0 -44
  116. package/services/transitions/baseTransitions.cjs +0 -186
  117. package/services/transitions/collapse.cjs +0 -40
  118. package/services/transitions/cssTransitions.cjs +0 -32
  119. package/services/transitions/simpleClassTransition.cjs +0 -37
  120. package/slider-pgDq1V5r.cjs +0 -807
  121. package/textDirection-zqcZ5-eK.cjs +0 -3
  122. package/toaster-Dlube4Ya.cjs +0 -161
  123. package/tree-Chcy4ulJ.cjs +0 -228
  124. package/types.cjs +0 -6
  125. package/utils/directive.cjs +0 -28
  126. package/utils/func.cjs +0 -7
  127. package/utils/id.cjs +0 -5
  128. package/utils/stores.cjs +0 -172
  129. package/utils/widget.cjs +0 -8
  130. package/utils/writables.cjs +0 -16
  131. package/writables-Dt68gADJ.cjs +0 -102
@@ -1,252 +0,0 @@
1
- "use strict";
2
- const tansu = require("@amadeus-it-group/tansu");
3
- const utils_writables = require("./writables-Dt68gADJ.cjs");
4
- const utils_stores = require("./utils/stores.cjs");
5
- const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
6
- const promise = require("./promise-CxCD3NYv.cjs");
7
- const utils_func = require("./utils/func.cjs");
8
- const scrollbars = require("./scrollbars-f651ntzz.cjs");
9
- const utils_directive = require("./directive-DyTodNPd.cjs");
10
- const services_portal = require("./services/portal.cjs");
11
- const services_siblingsInert = require("./services/siblingsInert.cjs");
12
- const utils_widget = require("./utils/widget.cjs");
13
- const services_focusElement = require("./services/focusElement.cjs");
14
- const modalOutsideClick = /* @__PURE__ */ Symbol();
15
- const modalCloseButtonClick = /* @__PURE__ */ Symbol();
16
- const modalCloseEscape = /* @__PURE__ */ Symbol();
17
- const defaultConfig = {
18
- animated: true,
19
- ariaCloseButtonLabel: "Close",
20
- backdrop: true,
21
- backdropClass: "",
22
- backdropTransition: utils_func.noop,
23
- closeButton: true,
24
- closeOnOutsideClick: true,
25
- container: typeof window !== "undefined" ? document.body : null,
26
- className: "",
27
- modalTransition: utils_func.noop,
28
- onBeforeClose: utils_func.noop,
29
- onVisibleChange: utils_func.noop,
30
- onHidden: utils_func.noop,
31
- onShown: utils_func.noop,
32
- visible: false
33
- };
34
- const configValidator = {
35
- animated: utils_writables.typeBoolean,
36
- ariaCloseButtonLabel: utils_writables.typeString,
37
- backdrop: utils_writables.typeBoolean,
38
- backdropClass: utils_writables.typeString,
39
- backdropTransition: utils_writables.typeFunction,
40
- closeButton: utils_writables.typeBoolean,
41
- closeOnOutsideClick: utils_writables.typeBoolean,
42
- container: utils_writables.typeHTMLElementOrNull,
43
- className: utils_writables.typeString,
44
- modalTransition: utils_writables.typeFunction,
45
- onBeforeClose: utils_writables.typeFunction,
46
- onVisibleChange: utils_writables.typeFunction,
47
- onHidden: utils_writables.typeFunction,
48
- onShown: utils_writables.typeFunction,
49
- visible: utils_writables.typeBoolean
50
- };
51
- function getModalDefaultConfig() {
52
- return { ...defaultConfig };
53
- }
54
- const modals$ = utils_directive.registrationArray();
55
- const hasModals$ = tansu.computed(() => modals$().length > 0);
56
- const scrollbarsAction$ = tansu.computed(() => {
57
- if (hasModals$()) {
58
- scrollbars.removeScrollbars();
59
- } else {
60
- scrollbars.revertScrollbars();
61
- }
62
- });
63
- const modalsAction$ = tansu.computed(() => {
64
- scrollbarsAction$();
65
- });
66
- const createModal = utils_widget.createWidgetFactory(
67
- "modal",
68
- (config$) => {
69
- const [
70
- {
71
- animated$,
72
- backdrop$,
73
- backdropTransition$,
74
- closeOnOutsideClick$,
75
- container$,
76
- modalTransition$,
77
- onBeforeClose$,
78
- onVisibleChange$,
79
- onHidden$,
80
- onShown$,
81
- ariaCloseButtonLabel$,
82
- className$,
83
- backdropClass$,
84
- visible$: requestedVisible$,
85
- ...stateProps
86
- },
87
- patch
88
- ] = utils_stores.writablesForProps(defaultConfig, config$, configValidator);
89
- const modalTransition = services_transitions_baseTransitions.createTransition({
90
- props: {
91
- transition: modalTransition$,
92
- visible: requestedVisible$,
93
- animated: animated$,
94
- animatedOnInit: animated$,
95
- onVisibleChange: onVisibleChange$,
96
- // TODO: for onHidden and onShown, should we combine with information from the backdrop transition?
97
- // (especially in case one of the two transitions takes more time than the other)
98
- onHidden: onHidden$,
99
- onShown: onShown$
100
- }
101
- });
102
- const visible$ = modalTransition.stores.visible$;
103
- const backdropTransition = services_transitions_baseTransitions.createTransition({
104
- props: {
105
- transition: backdropTransition$,
106
- visible: requestedVisible$,
107
- animated: animated$,
108
- animatedOnInit: animated$
109
- }
110
- });
111
- const transitioning$ = tansu.computed(
112
- () => modalTransition.stores.transitioning$() || backdrop$() && backdropTransition.stores.transitioning$()
113
- );
114
- const hidden$ = tansu.computed(() => !transitioning$() && !visible$());
115
- const backdropHidden$ = tansu.computed(() => !backdrop$() || hidden$());
116
- let hideResult;
117
- const close = (result) => {
118
- hideResult = result;
119
- const beforeCloseEvent = {
120
- get result() {
121
- return hideResult;
122
- },
123
- set result(value) {
124
- hideResult = value;
125
- },
126
- cancel: false
127
- };
128
- onBeforeClose$()(beforeCloseEvent);
129
- if (beforeCloseEvent.cancel) {
130
- return;
131
- }
132
- patch({ visible: false });
133
- };
134
- const modalPortalDirective = utils_directive.bindDirective(
135
- services_portal.portal,
136
- tansu.computed(() => ({ container: container$() }))
137
- );
138
- const backdropPortalDirective = utils_directive.bindDirective(
139
- services_portal.portal,
140
- tansu.computed(() => {
141
- const container = container$();
142
- const element = container ? modalTransition.stores.element$() : void 0;
143
- return {
144
- container,
145
- insertBefore: element?.parentElement === container ? element : void 0
146
- };
147
- })
148
- );
149
- const registerModalAction$ = tansu.readable(void 0, () => modals$.register(res));
150
- const action$ = tansu.computed(() => {
151
- if (modalTransition.stores.elementPresent$() && !hidden$()) {
152
- registerModalAction$();
153
- }
154
- modalsAction$();
155
- });
156
- const closeButtonDirective = utils_directive.createAttributesDirective(() => ({
157
- attributes: {
158
- type: tansu.readable("button"),
159
- "aria-label": ariaCloseButtonLabel$
160
- },
161
- events: {
162
- click: () => close(modalCloseButtonClick)
163
- }
164
- }));
165
- const backdropAttributeDirective = utils_directive.createAttributesDirective(() => ({
166
- attributes: {
167
- class: backdropClass$
168
- }
169
- }));
170
- const modalAttributeDirective = utils_directive.createAttributesDirective(() => ({
171
- attributes: {
172
- class: className$,
173
- tabIndex: tansu.readable("-1")
174
- },
175
- events: {
176
- click: (event) => {
177
- if (event.currentTarget === event.target && closeOnOutsideClick$()) {
178
- close(modalOutsideClick);
179
- }
180
- },
181
- keydown: (event) => {
182
- const { key } = event;
183
- switch (key) {
184
- case "Escape":
185
- close(modalCloseEscape);
186
- event.stopPropagation();
187
- break;
188
- }
189
- }
190
- }
191
- }));
192
- const res = {
193
- ...utils_stores.stateStores({
194
- backdropHidden$,
195
- container$,
196
- hidden$,
197
- transitioning$,
198
- visible$,
199
- modalElement$: modalTransition.stores.element$,
200
- ariaCloseButtonLabel$,
201
- className$,
202
- backdropClass$,
203
- ...stateProps
204
- }),
205
- directives: {
206
- modalPortalDirective,
207
- backdropPortalDirective,
208
- backdropDirective: utils_directive.mergeDirectives(backdropTransition.directives.directive, backdropAttributeDirective),
209
- modalDirective: utils_directive.mergeDirectives(
210
- modalTransition.directives.directive,
211
- utils_directive.bindDirectiveNoArg(services_siblingsInert.siblingsInert),
212
- utils_directive.directiveSubscribe(action$),
213
- modalAttributeDirective,
214
- services_focusElement.focusElement
215
- ),
216
- closeButtonDirective,
217
- dialogDirective: utils_directive.bindDirective(
218
- utils_directive.browserDirective((dialog, visible) => {
219
- const update = (visible2) => {
220
- if (visible2) {
221
- dialog.showModal();
222
- } else {
223
- dialog.close();
224
- }
225
- };
226
- update(visible);
227
- return {
228
- update
229
- };
230
- }),
231
- visible$
232
- )
233
- },
234
- patch,
235
- api: {
236
- close,
237
- async open() {
238
- patch({ visible: true });
239
- await promise.promiseFromStore(hidden$).promise;
240
- return hideResult;
241
- },
242
- patch
243
- }
244
- };
245
- return res;
246
- }
247
- );
248
- exports.createModal = createModal;
249
- exports.getModalDefaultConfig = getModalDefaultConfig;
250
- exports.modalCloseButtonClick = modalCloseButtonClick;
251
- exports.modalCloseEscape = modalCloseEscape;
252
- exports.modalOutsideClick = modalOutsideClick;
@@ -1,254 +0,0 @@
1
- "use strict";
2
- const tansu = require("@amadeus-it-group/tansu");
3
- const utils_stores = require("./utils/stores.cjs");
4
- const utils_writables = require("./writables-Dt68gADJ.cjs");
5
- const utils_func = require("./utils/func.cjs");
6
- const utils_directive = require("./directive-DyTodNPd.cjs");
7
- const utils_widget = require("./utils/widget.cjs");
8
- const PAGE_LINK_DEFAULT = "#";
9
- const defaultConfig = {
10
- page: 1,
11
- collectionSize: 0,
12
- pageSize: 10,
13
- disabled: false,
14
- directionLinks: true,
15
- boundaryLinks: false,
16
- onPageChange: utils_func.noop,
17
- pagesFactory: (_page, pageCount) => {
18
- const pages = [];
19
- for (let i = 1; i <= pageCount; i++) {
20
- pages.push(i);
21
- }
22
- return pages;
23
- },
24
- ariaLabel: "Page navigation",
25
- activeLabel: "(current)",
26
- ariaPageLabel: (processPage, pageCount) => `Page ${processPage} of ${pageCount}`,
27
- ariaFirstLabel: "Action link for first page",
28
- ariaPreviousLabel: "Action link for previous page",
29
- ariaNextLabel: "Action link for next page",
30
- ariaLastLabel: "Action link for last page",
31
- ariaEllipsisLabel: "Ellipsis page element",
32
- ariaLiveLabel: (currentPage) => `Current page is ${currentPage}`,
33
- className: "",
34
- pageLink: (_page) => PAGE_LINK_DEFAULT
35
- };
36
- function getPaginationDefaultConfig() {
37
- return { ...defaultConfig };
38
- }
39
- const configValidator = {
40
- page: utils_writables.typeNumber,
41
- collectionSize: utils_writables.typeNumber,
42
- pageSize: utils_writables.typeNumber,
43
- disabled: utils_writables.typeBoolean,
44
- directionLinks: utils_writables.typeBoolean,
45
- boundaryLinks: utils_writables.typeBoolean,
46
- onPageChange: utils_writables.typeFunction,
47
- pagesFactory: utils_writables.typeFunction,
48
- ariaLabel: utils_writables.typeString,
49
- activeLabel: utils_writables.typeString,
50
- ariaPageLabel: utils_writables.typeFunction,
51
- ariaFirstLabel: utils_writables.typeString,
52
- ariaPreviousLabel: utils_writables.typeString,
53
- ariaNextLabel: utils_writables.typeString,
54
- ariaLastLabel: utils_writables.typeString,
55
- ariaLiveLabel: utils_writables.typeFunction,
56
- className: utils_writables.typeString,
57
- pageLink: utils_writables.typeFunction,
58
- ariaEllipsisLabel: utils_writables.typeString
59
- };
60
- const createPagination = utils_widget.createWidgetFactory(
61
- "pagination",
62
- (config) => {
63
- const [
64
- {
65
- // dirty inputs that need adjustment:
66
- page$: _dirtyPage$,
67
- // clean inputs with value validation:
68
- collectionSize$,
69
- pageSize$,
70
- onPageChange$,
71
- pagesFactory$,
72
- ariaPageLabel$,
73
- ariaLiveLabel$,
74
- pageLink$,
75
- disabled$,
76
- ariaFirstLabel$,
77
- ariaLastLabel$,
78
- ariaNextLabel$,
79
- ariaPreviousLabel$,
80
- ...stateProps
81
- },
82
- patch
83
- ] = utils_stores.writablesForProps(defaultConfig, config, configValidator);
84
- const pageCount$ = tansu.computed(() => {
85
- let pageCount = Math.ceil(collectionSize$() / pageSize$());
86
- if (!utils_writables.isNumber(pageCount) || pageCount < 1) {
87
- pageCount = 1;
88
- }
89
- return pageCount;
90
- });
91
- const page$ = utils_stores.bindableProp(_dirtyPage$, onPageChange$, (dirtyPage) => utils_writables.clamp(dirtyPage, pageCount$(), 1));
92
- const pages$ = tansu.computed(() => pagesFactory$()(page$(), pageCount$()));
93
- const nextDisabled$ = tansu.computed(() => page$() === pageCount$() || disabled$());
94
- const previousDisabled$ = tansu.computed(() => page$() === 1 || disabled$());
95
- const pagesLabel$ = tansu.computed(() => {
96
- const ariaPageLabel = ariaPageLabel$();
97
- const pageCount = pageCount$();
98
- return pages$().map((page) => ariaPageLabel(page, pageCount));
99
- });
100
- const pagesHrefs$ = tansu.computed(() => {
101
- const pageLinkFactory = pageLink$();
102
- const pageCount = pageCount$();
103
- return Array.from({ length: pageCount }, (_, index) => pageLinkFactory(index + 1));
104
- });
105
- const directionsHrefs$ = tansu.computed(() => {
106
- const pagesHrefs = pagesHrefs$();
107
- const pageIndex = page$() - 1;
108
- return {
109
- previous: pagesHrefs.at(pageIndex > 0 ? pageIndex - 1 : 0),
110
- next: pagesHrefs.at(pageIndex + 1) ?? pagesHrefs.at(-1)
111
- };
112
- });
113
- const ariaLiveLabelText$ = tansu.computed(() => ariaLiveLabel$()(page$(), pageCount$()));
114
- function handleNavigation(pageNumber, event) {
115
- if (pagesHrefs$()[pageNumber - 1] === PAGE_LINK_DEFAULT) {
116
- event?.preventDefault();
117
- }
118
- if (!event || !(event.ctrlKey || event.metaKey)) {
119
- event?.preventDefault();
120
- page$.set(pageNumber);
121
- }
122
- }
123
- const widget = {
124
- ...utils_stores.stateStores({
125
- pageCount$,
126
- page$,
127
- pages$,
128
- nextDisabled$,
129
- previousDisabled$,
130
- pagesLabel$,
131
- pagesHrefs$,
132
- directionsHrefs$,
133
- disabled$,
134
- ariaFirstLabel$,
135
- ariaLastLabel$,
136
- ariaNextLabel$,
137
- ariaPreviousLabel$,
138
- ariaLiveLabelText$,
139
- ...stateProps
140
- }),
141
- patch,
142
- api: {
143
- /**
144
- * Set the current page pageNumber (starting from 1)
145
- * @param pageNumber - Current page number to set.
146
- * Value is normalized between 1 and the number of page
147
- */
148
- select(pageNumber) {
149
- page$.set(pageNumber);
150
- },
151
- /**
152
- * Select the first page
153
- */
154
- first() {
155
- page$.set(1);
156
- },
157
- /**
158
- * Select the previous page
159
- */
160
- previous() {
161
- page$.update((p) => p - 1);
162
- },
163
- /**
164
- * Select the next page
165
- */
166
- next() {
167
- page$.update((p) => p + 1);
168
- },
169
- /**
170
- * Select the last page
171
- */
172
- last() {
173
- page$.set(pageCount$());
174
- }
175
- },
176
- directives: {
177
- pageLink: utils_directive.createAttributesDirective((pageLinkContext$) => ({
178
- events: {
179
- click: (e) => handleNavigation(pageLinkContext$().page, e)
180
- },
181
- attributes: {
182
- "aria-current": tansu.computed(() => page$() === pageLinkContext$().page ? "page" : void 0),
183
- "aria-label": tansu.computed(() => pagesLabel$()[pageLinkContext$().page - 1]),
184
- href: tansu.computed(() => pagesHrefs$()[pageLinkContext$().page - 1]),
185
- tabindex: tansu.computed(() => disabled$() ? "-1" : void 0),
186
- "aria-disabled": tansu.computed(() => disabled$() ? "true" : void 0)
187
- },
188
- classNames: {
189
- "au-page": utils_stores.true$
190
- }
191
- })),
192
- pageFirst: utils_directive.createAttributesDirective(() => ({
193
- events: {
194
- click: (e) => handleNavigation(1, e)
195
- },
196
- attributes: {
197
- "aria-label": ariaFirstLabel$,
198
- href: tansu.computed(() => pagesHrefs$()[0]),
199
- tabindex: tansu.computed(() => previousDisabled$() ? "-1" : void 0),
200
- "aria-disabled": tansu.computed(() => previousDisabled$() ? "true" : void 0)
201
- },
202
- classNames: {
203
- "au-first": utils_stores.true$
204
- }
205
- })),
206
- pagePrev: utils_directive.createAttributesDirective(() => ({
207
- events: {
208
- click: (e) => handleNavigation(page$() - 1, e)
209
- },
210
- attributes: {
211
- "aria-label": ariaPreviousLabel$,
212
- href: tansu.computed(() => directionsHrefs$().previous),
213
- tabindex: tansu.computed(() => previousDisabled$() ? "-1" : void 0),
214
- "aria-disabled": tansu.computed(() => previousDisabled$() ? "true" : void 0)
215
- },
216
- classNames: {
217
- "au-previous": utils_stores.true$
218
- }
219
- })),
220
- pageNext: utils_directive.createAttributesDirective(() => ({
221
- events: {
222
- click: (e) => handleNavigation(page$() + 1, e)
223
- },
224
- attributes: {
225
- "aria-label": ariaNextLabel$,
226
- href: tansu.computed(() => directionsHrefs$().next),
227
- tabindex: tansu.computed(() => nextDisabled$() ? "-1" : void 0),
228
- "aria-disabled": tansu.computed(() => nextDisabled$() ? "true" : void 0)
229
- },
230
- classNames: {
231
- "au-next": utils_stores.true$
232
- }
233
- })),
234
- pageLast: utils_directive.createAttributesDirective(() => ({
235
- events: {
236
- click: (e) => handleNavigation(pageCount$(), e)
237
- },
238
- attributes: {
239
- "aria-label": ariaLastLabel$,
240
- href: tansu.computed(() => pagesHrefs$().at(-1)),
241
- tabindex: tansu.computed(() => nextDisabled$() ? "-1" : void 0),
242
- "aria-disabled": tansu.computed(() => nextDisabled$() ? "true" : void 0)
243
- },
244
- classNames: {
245
- "au-last": utils_stores.true$
246
- }
247
- }))
248
- }
249
- };
250
- return widget;
251
- }
252
- );
253
- exports.createPagination = createPagination;
254
- exports.getPaginationDefaultConfig = getPaginationDefaultConfig;
@@ -1,86 +0,0 @@
1
- "use strict";
2
- const utils_writables = require("./writables-Dt68gADJ.cjs");
3
- const utils_stores = require("./utils/stores.cjs");
4
- const tansu = require("@amadeus-it-group/tansu");
5
- const utils_directive = require("./directive-DyTodNPd.cjs");
6
- const utils_widget = require("./utils/widget.cjs");
7
- const defaultConfig = {
8
- min: 0,
9
- max: 100,
10
- value: 0,
11
- ariaLabel: "Progressbar",
12
- className: "",
13
- ariaValueTextFn: () => void 0
14
- };
15
- function getProgressbarDefaultConfig() {
16
- return { ...defaultConfig };
17
- }
18
- const configValidator = {
19
- min: utils_writables.typeNumber,
20
- max: utils_writables.typeNumber,
21
- value: utils_writables.typeNumber,
22
- ariaLabel: utils_writables.typeString,
23
- className: utils_writables.typeString,
24
- ariaValueTextFn: utils_writables.typeFunction
25
- };
26
- const createProgressbar = utils_widget.createWidgetFactory(
27
- "progressbar",
28
- (config) => {
29
- const [
30
- {
31
- // dirty inputs that need adjustment:
32
- max$: _dirtyMaximum$,
33
- value$: _dirtyValue$,
34
- // clean inputs
35
- min$,
36
- ariaValueTextFn$,
37
- ariaLabel$,
38
- ...stateProps
39
- },
40
- patch
41
- ] = utils_stores.writablesForProps(defaultConfig, config, configValidator);
42
- const max$ = tansu.computed(() => Math.max(min$(), _dirtyMaximum$()));
43
- const value$ = tansu.computed(() => utils_writables.clamp(_dirtyValue$(), max$(), min$()));
44
- const percentage$ = tansu.computed(() => {
45
- const max = max$();
46
- const min = min$();
47
- if (max > min) {
48
- return utils_writables.clamp((value$() - min) * 100 / (max - min), 100, 0);
49
- } else {
50
- return 0;
51
- }
52
- });
53
- const started$ = tansu.computed(() => value$() > min$());
54
- const finished$ = tansu.computed(() => value$() === max$());
55
- const ariaValueText$ = tansu.computed(() => ariaValueTextFn$()(value$(), min$(), max$()));
56
- return {
57
- ...utils_stores.stateStores({
58
- min$,
59
- max$,
60
- value$,
61
- percentage$,
62
- started$,
63
- finished$,
64
- ariaValueText$,
65
- ariaLabel$,
66
- ...stateProps
67
- }),
68
- patch,
69
- api: {},
70
- directives: {
71
- ariaDirective: utils_directive.createAttributesDirective(() => ({
72
- attributes: {
73
- role: tansu.readable("progressbar"),
74
- "aria-label": ariaLabel$,
75
- "aria-valuenow": value$,
76
- "aria-valuemin": min$,
77
- "aria-valuemax": max$,
78
- "aria-valuetext": ariaValueText$
79
- }
80
- }))
81
- }
82
- };
83
- }
84
- );
85
- exports.createProgressbar = createProgressbar;
86
- exports.getProgressbarDefaultConfig = getProgressbarDefaultConfig;
@@ -1,118 +0,0 @@
1
- "use strict";
2
- const tansu = require("@amadeus-it-group/tansu");
3
- const utils_func = require("./utils/func.cjs");
4
- const promisePending = { status: "pending" };
5
- const isThenable = (value) => {
6
- const type = typeof value;
7
- return type === "object" && value !== null || type === "function" ? typeof value.then === "function" : false;
8
- };
9
- const createPromiseStateStore = (promise) => {
10
- const store = tansu.writable(promisePending);
11
- Promise.resolve(promise).then(
12
- (value) => store.set({ status: "fulfilled", value }),
13
- (reason) => store.set({ status: "rejected", reason })
14
- );
15
- return tansu.asReadable(store);
16
- };
17
- const promiseWeakMap = /* @__PURE__ */ new WeakMap();
18
- const promiseStateStore = (value) => {
19
- if (!isThenable(value)) {
20
- return tansu.readable({ status: "fulfilled", value });
21
- }
22
- let response = promiseWeakMap.get(value);
23
- if (!response) {
24
- response = createPromiseStateStore(value);
25
- promiseWeakMap.set(value, response);
26
- }
27
- return response;
28
- };
29
- const promiseStateStoreEqual = (a, b) => Object.is(a, b) || a.status === b.status && (a.status !== "fulfilled" || tansu.equal(a.value, b.value)) && (a.status !== "rejected" || tansu.equal(a.reason, b.reason));
30
- const promiseStoreToPromiseStateStore = (promiseStore$) => tansu.computed(() => promiseStateStore(promiseStore$())(), { equal: promiseStateStoreEqual });
31
- const promiseStateStoreToValueStore = (store$, initialValue, equal2) => tansu.derived(
32
- store$,
33
- {
34
- derive: (state, set) => {
35
- if (state.status === "fulfilled") {
36
- set(state.value);
37
- }
38
- },
39
- equal: equal2
40
- },
41
- initialValue
42
- );
43
- const promiseStoreToValueStore = (promiseStore$, initialValue, equal2) => promiseStateStoreToValueStore(promiseStoreToPromiseStateStore(promiseStore$), initialValue, equal2);
44
- const truthyValue = (value) => !!value;
45
- const promiseFromStore = (store, condition = truthyValue) => {
46
- let resolve;
47
- const promise = new Promise((r) => resolve = r);
48
- let unsubscribe = () => {
49
- storeUnsubscribe();
50
- unsubscribe = utils_func.noop;
51
- };
52
- let storeUnsubscribe = utils_func.noop;
53
- storeUnsubscribe = store.subscribe((value) => {
54
- if (condition(value)) {
55
- resolve(value);
56
- unsubscribe();
57
- }
58
- });
59
- if (unsubscribe === utils_func.noop) {
60
- storeUnsubscribe();
61
- }
62
- return {
63
- promise,
64
- unsubscribe() {
65
- unsubscribe();
66
- }
67
- };
68
- };
69
- const promiseFromEvent = (element, event) => {
70
- let resolve;
71
- const promise = new Promise((r) => resolve = r);
72
- let unsubscribe = () => {
73
- element.removeEventListener(event, eventListener);
74
- unsubscribe = utils_func.noop;
75
- };
76
- const eventListener = (event2) => {
77
- if (event2.target === element) {
78
- resolve(event2);
79
- unsubscribe();
80
- }
81
- };
82
- element.addEventListener(event, eventListener);
83
- return {
84
- promise,
85
- unsubscribe() {
86
- unsubscribe();
87
- }
88
- };
89
- };
90
- const promiseFromTimeout = (delay) => {
91
- let timeout;
92
- return {
93
- promise: new Promise((r) => {
94
- timeout = setTimeout(() => {
95
- timeout = void 0;
96
- r();
97
- }, delay);
98
- }),
99
- unsubscribe() {
100
- if (timeout) {
101
- clearTimeout(timeout);
102
- timeout = void 0;
103
- }
104
- }
105
- };
106
- };
107
- const promiseWithResolve = () => {
108
- let resolve;
109
- const promise = new Promise((r) => {
110
- resolve = r;
111
- });
112
- return { promise, resolve };
113
- };
114
- exports.promiseFromEvent = promiseFromEvent;
115
- exports.promiseFromStore = promiseFromStore;
116
- exports.promiseFromTimeout = promiseFromTimeout;
117
- exports.promiseStoreToValueStore = promiseStoreToValueStore;
118
- exports.promiseWithResolve = promiseWithResolve;