@design-factory/angular 21.0.3 → 21.1.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 (194) hide show
  1. package/drawer/README.md +54 -0
  2. package/fesm2022/design-factory-angular-drawer.mjs +202 -67
  3. package/fesm2022/design-factory-angular-drawer.mjs.map +1 -1
  4. package/fesm2022/design-factory-angular-internals.mjs +439 -17
  5. package/fesm2022/design-factory-angular-internals.mjs.map +1 -1
  6. package/fesm2022/design-factory-angular-sidenav.mjs +223 -210
  7. package/fesm2022/design-factory-angular-sidenav.mjs.map +1 -1
  8. package/fesm2022/design-factory-angular-theme.mjs +198 -0
  9. package/fesm2022/design-factory-angular-theme.mjs.map +1 -0
  10. package/fesm2022/design-factory-angular-topnav.mjs +1538 -0
  11. package/fesm2022/design-factory-angular-topnav.mjs.map +1 -0
  12. package/node_modules/@agnos-ui/core/README.md +5 -0
  13. package/node_modules/@agnos-ui/core/accordion-BC_9xn23.cjs +314 -0
  14. package/node_modules/@agnos-ui/core/accordion-Ca_0T8Bc.js +315 -0
  15. package/node_modules/@agnos-ui/core/alert-AhaliJ17.cjs +9 -0
  16. package/node_modules/@agnos-ui/core/alert-Cb9FhbFQ.js +10 -0
  17. package/node_modules/@agnos-ui/core/collapse-COriZO7o.cjs +94 -0
  18. package/node_modules/@agnos-ui/core/collapse-CP79atna.js +95 -0
  19. package/node_modules/@agnos-ui/core/common-B5jS-Ih_.cjs +73 -0
  20. package/node_modules/@agnos-ui/core/common-DFyZvkII.js +74 -0
  21. package/node_modules/@agnos-ui/core/components/accordion/accordion.d.ts +333 -0
  22. package/node_modules/@agnos-ui/core/components/accordion/index.cjs +7 -0
  23. package/node_modules/@agnos-ui/core/components/accordion/index.d.ts +1 -0
  24. package/node_modules/@agnos-ui/core/components/accordion/index.js +7 -0
  25. package/node_modules/@agnos-ui/core/components/alert/alert.d.ts +37 -0
  26. package/node_modules/@agnos-ui/core/components/alert/common.d.ts +138 -0
  27. package/node_modules/@agnos-ui/core/components/alert/index.cjs +5 -0
  28. package/node_modules/@agnos-ui/core/components/alert/index.d.ts +1 -0
  29. package/node_modules/@agnos-ui/core/components/alert/index.js +5 -0
  30. package/node_modules/@agnos-ui/core/components/carousel/carousel.d.ts +247 -0
  31. package/node_modules/@agnos-ui/core/components/carousel/index.cjs +292 -0
  32. package/node_modules/@agnos-ui/core/components/carousel/index.d.ts +1 -0
  33. package/node_modules/@agnos-ui/core/components/carousel/index.js +292 -0
  34. package/node_modules/@agnos-ui/core/components/collapse/collapse.d.ts +135 -0
  35. package/node_modules/@agnos-ui/core/components/collapse/index.cjs +5 -0
  36. package/node_modules/@agnos-ui/core/components/collapse/index.d.ts +1 -0
  37. package/node_modules/@agnos-ui/core/components/collapse/index.js +5 -0
  38. package/node_modules/@agnos-ui/core/components/commonProps.d.ts +11 -0
  39. package/node_modules/@agnos-ui/core/components/drawer/drawer.d.ts +279 -0
  40. package/node_modules/@agnos-ui/core/components/drawer/index.cjs +5 -0
  41. package/node_modules/@agnos-ui/core/components/drawer/index.d.ts +1 -0
  42. package/node_modules/@agnos-ui/core/components/drawer/index.js +5 -0
  43. package/node_modules/@agnos-ui/core/components/modal/index.cjs +8 -0
  44. package/node_modules/@agnos-ui/core/components/modal/index.d.ts +1 -0
  45. package/node_modules/@agnos-ui/core/components/modal/index.js +8 -0
  46. package/node_modules/@agnos-ui/core/components/modal/modal.d.ts +245 -0
  47. package/node_modules/@agnos-ui/core/components/pagination/index.cjs +5 -0
  48. package/node_modules/@agnos-ui/core/components/pagination/index.d.ts +1 -0
  49. package/node_modules/@agnos-ui/core/components/pagination/index.js +5 -0
  50. package/node_modules/@agnos-ui/core/components/pagination/pagination.d.ts +313 -0
  51. package/node_modules/@agnos-ui/core/components/progressbar/index.cjs +5 -0
  52. package/node_modules/@agnos-ui/core/components/progressbar/index.d.ts +1 -0
  53. package/node_modules/@agnos-ui/core/components/progressbar/index.js +5 -0
  54. package/node_modules/@agnos-ui/core/components/progressbar/progressbar.d.ts +91 -0
  55. package/node_modules/@agnos-ui/core/components/rating/index.cjs +5 -0
  56. package/node_modules/@agnos-ui/core/components/rating/index.d.ts +1 -0
  57. package/node_modules/@agnos-ui/core/components/rating/index.js +5 -0
  58. package/node_modules/@agnos-ui/core/components/rating/rating.d.ts +191 -0
  59. package/node_modules/@agnos-ui/core/components/slider/index.cjs +5 -0
  60. package/node_modules/@agnos-ui/core/components/slider/index.d.ts +1 -0
  61. package/node_modules/@agnos-ui/core/components/slider/index.js +5 -0
  62. package/node_modules/@agnos-ui/core/components/slider/slider-utils.d.ts +25 -0
  63. package/node_modules/@agnos-ui/core/components/slider/slider.d.ts +383 -0
  64. package/node_modules/@agnos-ui/core/components/toast/index.cjs +7 -0
  65. package/node_modules/@agnos-ui/core/components/toast/index.d.ts +2 -0
  66. package/node_modules/@agnos-ui/core/components/toast/index.js +7 -0
  67. package/node_modules/@agnos-ui/core/components/toast/toast.d.ts +66 -0
  68. package/node_modules/@agnos-ui/core/components/toast/toaster.d.ts +128 -0
  69. package/node_modules/@agnos-ui/core/components/tree/index.cjs +5 -0
  70. package/node_modules/@agnos-ui/core/components/tree/index.d.ts +1 -0
  71. package/node_modules/@agnos-ui/core/components/tree/index.js +5 -0
  72. package/node_modules/@agnos-ui/core/components/tree/tree.d.ts +143 -0
  73. package/node_modules/@agnos-ui/core/config.cjs +36 -0
  74. package/node_modules/@agnos-ui/core/config.d.ts +117 -0
  75. package/node_modules/@agnos-ui/core/config.js +36 -0
  76. package/node_modules/@agnos-ui/core/directive-Bsreu2z1.js +523 -0
  77. package/node_modules/@agnos-ui/core/directive-DCaXmRe_.cjs +522 -0
  78. package/node_modules/@agnos-ui/core/drawer-BbFAHV07.cjs +328 -0
  79. package/node_modules/@agnos-ui/core/drawer-C6Qa0xEu.js +329 -0
  80. package/node_modules/@agnos-ui/core/index.cjs +134 -0
  81. package/node_modules/@agnos-ui/core/index.d.ts +29 -0
  82. package/node_modules/@agnos-ui/core/index.js +134 -0
  83. package/node_modules/@agnos-ui/core/isFocusable-Ckwus82R.js +32 -0
  84. package/node_modules/@agnos-ui/core/isFocusable-DfzDLeAN.cjs +31 -0
  85. package/node_modules/@agnos-ui/core/modal-BsNuHhT7.cjs +252 -0
  86. package/node_modules/@agnos-ui/core/modal-CgzY8ezz.js +253 -0
  87. package/node_modules/@agnos-ui/core/package.json +57 -0
  88. package/node_modules/@agnos-ui/core/pagination-ZxGaNWZz.js +255 -0
  89. package/node_modules/@agnos-ui/core/pagination-xbcOHnhd.cjs +254 -0
  90. package/node_modules/@agnos-ui/core/progressbar-CRbMKp4b.cjs +86 -0
  91. package/node_modules/@agnos-ui/core/progressbar-CSEIFnlD.js +87 -0
  92. package/node_modules/@agnos-ui/core/promise-CxCD3NYv.cjs +118 -0
  93. package/node_modules/@agnos-ui/core/promise-D-RZVPuv.js +119 -0
  94. package/node_modules/@agnos-ui/core/rating-BIdiiPUo.js +184 -0
  95. package/node_modules/@agnos-ui/core/rating-qx1xaBmz.cjs +183 -0
  96. package/node_modules/@agnos-ui/core/scrollbars-CT87iv_6.cjs +30 -0
  97. package/node_modules/@agnos-ui/core/scrollbars-CcxSrnCx.js +31 -0
  98. package/node_modules/@agnos-ui/core/services/extendWidget.cjs +41 -0
  99. package/node_modules/@agnos-ui/core/services/extendWidget.d.ts +31 -0
  100. package/node_modules/@agnos-ui/core/services/extendWidget.js +41 -0
  101. package/node_modules/@agnos-ui/core/services/floatingUI.cjs +111 -0
  102. package/node_modules/@agnos-ui/core/services/floatingUI.d.ts +76 -0
  103. package/node_modules/@agnos-ui/core/services/floatingUI.js +111 -0
  104. package/node_modules/@agnos-ui/core/services/focusElement.cjs +46 -0
  105. package/node_modules/@agnos-ui/core/services/focusElement.d.ts +9 -0
  106. package/node_modules/@agnos-ui/core/services/focusElement.js +46 -0
  107. package/node_modules/@agnos-ui/core/services/focustrack.cjs +47 -0
  108. package/node_modules/@agnos-ui/core/services/focustrack.d.ts +40 -0
  109. package/node_modules/@agnos-ui/core/services/focustrack.js +47 -0
  110. package/node_modules/@agnos-ui/core/services/hash.cjs +15 -0
  111. package/node_modules/@agnos-ui/core/services/hash.d.ts +3 -0
  112. package/node_modules/@agnos-ui/core/services/hash.js +15 -0
  113. package/node_modules/@agnos-ui/core/services/intersection.cjs +53 -0
  114. package/node_modules/@agnos-ui/core/services/intersection.d.ts +30 -0
  115. package/node_modules/@agnos-ui/core/services/intersection.js +53 -0
  116. package/node_modules/@agnos-ui/core/services/matchMedia.cjs +14 -0
  117. package/node_modules/@agnos-ui/core/services/matchMedia.d.ts +8 -0
  118. package/node_modules/@agnos-ui/core/services/matchMedia.js +14 -0
  119. package/node_modules/@agnos-ui/core/services/navManager.cjs +166 -0
  120. package/node_modules/@agnos-ui/core/services/navManager.d.ts +144 -0
  121. package/node_modules/@agnos-ui/core/services/navManager.js +166 -0
  122. package/node_modules/@agnos-ui/core/services/pointerdownPosition.cjs +60 -0
  123. package/node_modules/@agnos-ui/core/services/pointerdownPosition.d.ts +42 -0
  124. package/node_modules/@agnos-ui/core/services/pointerdownPosition.js +60 -0
  125. package/node_modules/@agnos-ui/core/services/portal.cjs +42 -0
  126. package/node_modules/@agnos-ui/core/services/portal.d.ts +16 -0
  127. package/node_modules/@agnos-ui/core/services/portal.js +42 -0
  128. package/node_modules/@agnos-ui/core/services/resizeObserver.cjs +54 -0
  129. package/node_modules/@agnos-ui/core/services/resizeObserver.d.ts +18 -0
  130. package/node_modules/@agnos-ui/core/services/resizeObserver.js +54 -0
  131. package/node_modules/@agnos-ui/core/services/siblingsInert.cjs +44 -0
  132. package/node_modules/@agnos-ui/core/services/siblingsInert.d.ts +16 -0
  133. package/node_modules/@agnos-ui/core/services/siblingsInert.js +44 -0
  134. package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.cjs +186 -0
  135. package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.d.ts +166 -0
  136. package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.js +186 -0
  137. package/node_modules/@agnos-ui/core/services/transitions/collapse.cjs +40 -0
  138. package/node_modules/@agnos-ui/core/services/transitions/collapse.d.ts +49 -0
  139. package/node_modules/@agnos-ui/core/services/transitions/collapse.js +40 -0
  140. package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.cjs +32 -0
  141. package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.d.ts +25 -0
  142. package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.js +32 -0
  143. package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.cjs +37 -0
  144. package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.d.ts +47 -0
  145. package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.js +37 -0
  146. package/node_modules/@agnos-ui/core/slider-B93hE0ag.cjs +807 -0
  147. package/node_modules/@agnos-ui/core/slider-Cjiq9FgI.js +808 -0
  148. package/node_modules/@agnos-ui/core/textDirection-cNgt24LJ.js +4 -0
  149. package/node_modules/@agnos-ui/core/textDirection-zqcZ5-eK.cjs +3 -0
  150. package/node_modules/@agnos-ui/core/toaster-BQWqxYv-.cjs +190 -0
  151. package/node_modules/@agnos-ui/core/toaster-BzEkshT2.js +191 -0
  152. package/node_modules/@agnos-ui/core/tree-DY04XPPg.cjs +228 -0
  153. package/node_modules/@agnos-ui/core/tree-HwcvZ0_p.js +229 -0
  154. package/node_modules/@agnos-ui/core/types.cjs +6 -0
  155. package/node_modules/@agnos-ui/core/types.d.ts +246 -0
  156. package/node_modules/@agnos-ui/core/types.js +6 -0
  157. package/node_modules/@agnos-ui/core/utils/directive.cjs +28 -0
  158. package/node_modules/@agnos-ui/core/utils/directive.d.ts +352 -0
  159. package/node_modules/@agnos-ui/core/utils/directive.js +28 -0
  160. package/node_modules/@agnos-ui/core/utils/func.cjs +7 -0
  161. package/node_modules/@agnos-ui/core/utils/func.d.ts +11 -0
  162. package/node_modules/@agnos-ui/core/utils/func.js +7 -0
  163. package/node_modules/@agnos-ui/core/utils/id.cjs +5 -0
  164. package/node_modules/@agnos-ui/core/utils/id.d.ts +6 -0
  165. package/node_modules/@agnos-ui/core/utils/id.js +5 -0
  166. package/node_modules/@agnos-ui/core/utils/internal/assign.d.ts +10 -0
  167. package/node_modules/@agnos-ui/core/utils/internal/checks.d.ts +57 -0
  168. package/node_modules/@agnos-ui/core/utils/internal/dom.d.ts +75 -0
  169. package/node_modules/@agnos-ui/core/utils/internal/isFocusable.d.ts +9 -0
  170. package/node_modules/@agnos-ui/core/utils/internal/math.d.ts +5 -0
  171. package/node_modules/@agnos-ui/core/utils/internal/promise.d.ts +98 -0
  172. package/node_modules/@agnos-ui/core/utils/internal/scrollbars.d.ts +8 -0
  173. package/node_modules/@agnos-ui/core/utils/internal/sort.d.ts +16 -0
  174. package/node_modules/@agnos-ui/core/utils/internal/ssrHTMLElement.d.ts +17 -0
  175. package/node_modules/@agnos-ui/core/utils/internal/textDirection.d.ts +7 -0
  176. package/node_modules/@agnos-ui/core/utils/internal/traversal.d.ts +54 -0
  177. package/node_modules/@agnos-ui/core/utils/stores.cjs +172 -0
  178. package/node_modules/@agnos-ui/core/utils/stores.d.ts +224 -0
  179. package/node_modules/@agnos-ui/core/utils/stores.js +172 -0
  180. package/node_modules/@agnos-ui/core/utils/widget.cjs +8 -0
  181. package/node_modules/@agnos-ui/core/utils/widget.d.ts +11 -0
  182. package/node_modules/@agnos-ui/core/utils/widget.js +8 -0
  183. package/node_modules/@agnos-ui/core/utils/writables.cjs +16 -0
  184. package/node_modules/@agnos-ui/core/utils/writables.d.ts +95 -0
  185. package/node_modules/@agnos-ui/core/utils/writables.js +16 -0
  186. package/node_modules/@agnos-ui/core/writables-DYGjj5T3.js +103 -0
  187. package/node_modules/@agnos-ui/core/writables-Dt68gADJ.cjs +102 -0
  188. package/package.json +25 -6
  189. package/schematics/collection.json +1 -1
  190. package/types/design-factory-angular-drawer.d.ts +71 -13
  191. package/types/design-factory-angular-internals.d.ts +220 -31
  192. package/types/design-factory-angular-sidenav.d.ts +15 -7
  193. package/types/design-factory-angular-theme.d.ts +122 -0
  194. package/types/design-factory-angular-topnav.d.ts +435 -0
@@ -0,0 +1,184 @@
1
+ import { computed, writable, readable } from "@amadeus-it-group/tansu";
2
+ import { INVALID_VALUE } from "./types.js";
3
+ import { g as createAttributesDirective } from "./directive-Bsreu2z1.js";
4
+ import { j as typeString, e as typeFunction, b as typeBoolean, g as typeNumber, l as clamp, m as isNumber } from "./writables-DYGjj5T3.js";
5
+ import { noop } from "./utils/func.js";
6
+ import { writablesForProps, bindableProp, stateStores, true$ } from "./utils/stores.js";
7
+ import { createWidgetFactory } from "./utils/widget.js";
8
+ const defaultConfig = {
9
+ rating: 0,
10
+ tabindex: 0,
11
+ maxRating: 10,
12
+ disabled: false,
13
+ readonly: false,
14
+ resettable: true,
15
+ ariaValueTextFn: (rating, maxRating) => `${rating} out of ${maxRating}`,
16
+ onHover: noop,
17
+ onLeave: noop,
18
+ onRatingChange: noop,
19
+ className: "",
20
+ ariaLabel: "Rating",
21
+ ariaLabelledBy: ""
22
+ };
23
+ function getRatingDefaultConfig() {
24
+ return { ...defaultConfig };
25
+ }
26
+ const configValidator = {
27
+ rating: typeNumber,
28
+ tabindex: typeNumber,
29
+ maxRating: { normalizeValue: (value) => isNumber(value) ? Math.max(0, value) : INVALID_VALUE },
30
+ disabled: typeBoolean,
31
+ readonly: typeBoolean,
32
+ resettable: typeBoolean,
33
+ ariaValueTextFn: typeFunction,
34
+ onHover: typeFunction,
35
+ onLeave: typeFunction,
36
+ onRatingChange: typeFunction,
37
+ className: typeString,
38
+ ariaLabel: typeString,
39
+ ariaLabelledBy: typeString
40
+ };
41
+ const createRating = createWidgetFactory(
42
+ "rating",
43
+ (config) => {
44
+ const [
45
+ {
46
+ // dirty inputs that need adjustment:
47
+ rating$: _dirtyRating$,
48
+ tabindex$: _dirtyTabindex$,
49
+ ariaValueTextFn$,
50
+ onHover$,
51
+ onLeave$,
52
+ onRatingChange$,
53
+ ...stateProps
54
+ },
55
+ patch
56
+ ] = writablesForProps(defaultConfig, config, configValidator);
57
+ const { ariaLabel$, ariaLabelledBy$, className$, disabled$, maxRating$, readonly$, resettable$ } = stateProps;
58
+ const tabindex$ = computed(() => disabled$() ? -1 : _dirtyTabindex$());
59
+ const rating$ = bindableProp(_dirtyRating$, onRatingChange$, (dirtyRating) => clamp(dirtyRating, maxRating$(), 0));
60
+ const _hoveredRating$ = writable(0);
61
+ const interactive$ = computed(() => !disabled$() && !readonly$());
62
+ const visibleRating$ = computed(() => {
63
+ const hoveredRating = _hoveredRating$();
64
+ return hoveredRating !== 0 ? hoveredRating : rating$();
65
+ });
66
+ const ariaValueText$ = computed(() => ariaValueTextFn$()(visibleRating$(), maxRating$()));
67
+ const stars$ = computed(() => {
68
+ const visibleRating = visibleRating$();
69
+ return Array.from({ length: maxRating$() }, (_v, i) => ({
70
+ fill: Math.round(Math.max(Math.min(visibleRating - i, 1), 0) * 100),
71
+ index: i
72
+ }));
73
+ });
74
+ const widget = {
75
+ ...stateStores({
76
+ ariaValueText$,
77
+ interactive$,
78
+ rating$,
79
+ stars$,
80
+ tabindex$,
81
+ visibleRating$,
82
+ ...stateProps
83
+ }),
84
+ patch,
85
+ directives: {
86
+ containerDirective: createAttributesDirective(() => ({
87
+ events: {
88
+ keydown: (event) => {
89
+ if (interactive$()) {
90
+ const { key } = event;
91
+ switch (key) {
92
+ case "ArrowLeft":
93
+ case "ArrowDown":
94
+ rating$.update((rating) => rating - 1);
95
+ break;
96
+ case "ArrowRight":
97
+ case "ArrowUp":
98
+ rating$.update((rating) => rating + 1);
99
+ break;
100
+ case "Home":
101
+ case "PageDown":
102
+ rating$.set(0);
103
+ break;
104
+ case "End":
105
+ case "PageUp":
106
+ rating$.set(maxRating$());
107
+ break;
108
+ default:
109
+ return;
110
+ }
111
+ event.preventDefault();
112
+ event.stopPropagation();
113
+ }
114
+ },
115
+ mouseleave: () => {
116
+ if (interactive$()) {
117
+ widget.api.leave();
118
+ }
119
+ }
120
+ },
121
+ attributes: {
122
+ role: readable("slider"),
123
+ class: className$,
124
+ "aria-valuemin": readable(0),
125
+ tabindex: tabindex$,
126
+ "aria-valuemax": maxRating$,
127
+ "aria-valuenow": visibleRating$,
128
+ "aria-valuetext": ariaValueText$,
129
+ "aria-readonly": computed(() => readonly$() ? "true" : void 0),
130
+ "aria-disabled": computed(() => disabled$() ? "true" : void 0),
131
+ "aria-label": ariaLabel$,
132
+ "aria-labelledby": computed(() => ariaLabelledBy$() || void 0)
133
+ },
134
+ classNames: {
135
+ "au-rating": true$
136
+ }
137
+ })),
138
+ starDirective: createAttributesDirective((starContext$) => {
139
+ return {
140
+ events: {
141
+ mouseenter: () => {
142
+ const index = starContext$().index + 1;
143
+ if (interactive$() && index > 0 && index <= maxRating$()) {
144
+ _hoveredRating$.set(index);
145
+ onHover$()(index);
146
+ }
147
+ },
148
+ click: () => {
149
+ const index = starContext$().index + 1;
150
+ if (interactive$() && index > 0 && index <= maxRating$()) {
151
+ rating$.update((rating) => rating === index && resettable$() ? 0 : index);
152
+ }
153
+ }
154
+ },
155
+ styles: {
156
+ cursor: computed(() => interactive$() ? "pointer" : "default")
157
+ },
158
+ classNames: {
159
+ "au-rating-star": true$
160
+ }
161
+ };
162
+ })
163
+ },
164
+ api: {
165
+ setRating(index) {
166
+ rating$.set(index);
167
+ },
168
+ setHoveredRating(index) {
169
+ onHover$()(index);
170
+ _hoveredRating$.set(index);
171
+ },
172
+ leave() {
173
+ onLeave$()(visibleRating$());
174
+ _hoveredRating$.set(0);
175
+ }
176
+ }
177
+ };
178
+ return widget;
179
+ }
180
+ );
181
+ export {
182
+ createRating as c,
183
+ getRatingDefaultConfig as g
184
+ };
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ const tansu = require("@amadeus-it-group/tansu");
3
+ const types = require("./types.cjs");
4
+ const utils_directive = require("./directive-DCaXmRe_.cjs");
5
+ const utils_writables = require("./writables-Dt68gADJ.cjs");
6
+ const utils_func = require("./utils/func.cjs");
7
+ const utils_stores = require("./utils/stores.cjs");
8
+ const utils_widget = require("./utils/widget.cjs");
9
+ const defaultConfig = {
10
+ rating: 0,
11
+ tabindex: 0,
12
+ maxRating: 10,
13
+ disabled: false,
14
+ readonly: false,
15
+ resettable: true,
16
+ ariaValueTextFn: (rating, maxRating) => `${rating} out of ${maxRating}`,
17
+ onHover: utils_func.noop,
18
+ onLeave: utils_func.noop,
19
+ onRatingChange: utils_func.noop,
20
+ className: "",
21
+ ariaLabel: "Rating",
22
+ ariaLabelledBy: ""
23
+ };
24
+ function getRatingDefaultConfig() {
25
+ return { ...defaultConfig };
26
+ }
27
+ const configValidator = {
28
+ rating: utils_writables.typeNumber,
29
+ tabindex: utils_writables.typeNumber,
30
+ maxRating: { normalizeValue: (value) => utils_writables.isNumber(value) ? Math.max(0, value) : types.INVALID_VALUE },
31
+ disabled: utils_writables.typeBoolean,
32
+ readonly: utils_writables.typeBoolean,
33
+ resettable: utils_writables.typeBoolean,
34
+ ariaValueTextFn: utils_writables.typeFunction,
35
+ onHover: utils_writables.typeFunction,
36
+ onLeave: utils_writables.typeFunction,
37
+ onRatingChange: utils_writables.typeFunction,
38
+ className: utils_writables.typeString,
39
+ ariaLabel: utils_writables.typeString,
40
+ ariaLabelledBy: utils_writables.typeString
41
+ };
42
+ const createRating = utils_widget.createWidgetFactory(
43
+ "rating",
44
+ (config) => {
45
+ const [
46
+ {
47
+ // dirty inputs that need adjustment:
48
+ rating$: _dirtyRating$,
49
+ tabindex$: _dirtyTabindex$,
50
+ ariaValueTextFn$,
51
+ onHover$,
52
+ onLeave$,
53
+ onRatingChange$,
54
+ ...stateProps
55
+ },
56
+ patch
57
+ ] = utils_stores.writablesForProps(defaultConfig, config, configValidator);
58
+ const { ariaLabel$, ariaLabelledBy$, className$, disabled$, maxRating$, readonly$, resettable$ } = stateProps;
59
+ const tabindex$ = tansu.computed(() => disabled$() ? -1 : _dirtyTabindex$());
60
+ const rating$ = utils_stores.bindableProp(_dirtyRating$, onRatingChange$, (dirtyRating) => utils_writables.clamp(dirtyRating, maxRating$(), 0));
61
+ const _hoveredRating$ = tansu.writable(0);
62
+ const interactive$ = tansu.computed(() => !disabled$() && !readonly$());
63
+ const visibleRating$ = tansu.computed(() => {
64
+ const hoveredRating = _hoveredRating$();
65
+ return hoveredRating !== 0 ? hoveredRating : rating$();
66
+ });
67
+ const ariaValueText$ = tansu.computed(() => ariaValueTextFn$()(visibleRating$(), maxRating$()));
68
+ const stars$ = tansu.computed(() => {
69
+ const visibleRating = visibleRating$();
70
+ return Array.from({ length: maxRating$() }, (_v, i) => ({
71
+ fill: Math.round(Math.max(Math.min(visibleRating - i, 1), 0) * 100),
72
+ index: i
73
+ }));
74
+ });
75
+ const widget = {
76
+ ...utils_stores.stateStores({
77
+ ariaValueText$,
78
+ interactive$,
79
+ rating$,
80
+ stars$,
81
+ tabindex$,
82
+ visibleRating$,
83
+ ...stateProps
84
+ }),
85
+ patch,
86
+ directives: {
87
+ containerDirective: utils_directive.createAttributesDirective(() => ({
88
+ events: {
89
+ keydown: (event) => {
90
+ if (interactive$()) {
91
+ const { key } = event;
92
+ switch (key) {
93
+ case "ArrowLeft":
94
+ case "ArrowDown":
95
+ rating$.update((rating) => rating - 1);
96
+ break;
97
+ case "ArrowRight":
98
+ case "ArrowUp":
99
+ rating$.update((rating) => rating + 1);
100
+ break;
101
+ case "Home":
102
+ case "PageDown":
103
+ rating$.set(0);
104
+ break;
105
+ case "End":
106
+ case "PageUp":
107
+ rating$.set(maxRating$());
108
+ break;
109
+ default:
110
+ return;
111
+ }
112
+ event.preventDefault();
113
+ event.stopPropagation();
114
+ }
115
+ },
116
+ mouseleave: () => {
117
+ if (interactive$()) {
118
+ widget.api.leave();
119
+ }
120
+ }
121
+ },
122
+ attributes: {
123
+ role: tansu.readable("slider"),
124
+ class: className$,
125
+ "aria-valuemin": tansu.readable(0),
126
+ tabindex: tabindex$,
127
+ "aria-valuemax": maxRating$,
128
+ "aria-valuenow": visibleRating$,
129
+ "aria-valuetext": ariaValueText$,
130
+ "aria-readonly": tansu.computed(() => readonly$() ? "true" : void 0),
131
+ "aria-disabled": tansu.computed(() => disabled$() ? "true" : void 0),
132
+ "aria-label": ariaLabel$,
133
+ "aria-labelledby": tansu.computed(() => ariaLabelledBy$() || void 0)
134
+ },
135
+ classNames: {
136
+ "au-rating": utils_stores.true$
137
+ }
138
+ })),
139
+ starDirective: utils_directive.createAttributesDirective((starContext$) => {
140
+ return {
141
+ events: {
142
+ mouseenter: () => {
143
+ const index = starContext$().index + 1;
144
+ if (interactive$() && index > 0 && index <= maxRating$()) {
145
+ _hoveredRating$.set(index);
146
+ onHover$()(index);
147
+ }
148
+ },
149
+ click: () => {
150
+ const index = starContext$().index + 1;
151
+ if (interactive$() && index > 0 && index <= maxRating$()) {
152
+ rating$.update((rating) => rating === index && resettable$() ? 0 : index);
153
+ }
154
+ }
155
+ },
156
+ styles: {
157
+ cursor: tansu.computed(() => interactive$() ? "pointer" : "default")
158
+ },
159
+ classNames: {
160
+ "au-rating-star": utils_stores.true$
161
+ }
162
+ };
163
+ })
164
+ },
165
+ api: {
166
+ setRating(index) {
167
+ rating$.set(index);
168
+ },
169
+ setHoveredRating(index) {
170
+ onHover$()(index);
171
+ _hoveredRating$.set(index);
172
+ },
173
+ leave() {
174
+ onLeave$()(visibleRating$());
175
+ _hoveredRating$.set(0);
176
+ }
177
+ }
178
+ };
179
+ return widget;
180
+ }
181
+ );
182
+ exports.createRating = createRating;
183
+ exports.getRatingDefaultConfig = getRatingDefaultConfig;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ const utils_func = require("./utils/func.cjs");
3
+ const internalRemoveScrollbars = () => {
4
+ const scrollbarWidth = Math.abs(window.innerWidth - document.documentElement.clientWidth);
5
+ const body = document.body;
6
+ const bodyStyle = body.style;
7
+ const { overflow, paddingRight } = bodyStyle;
8
+ if (scrollbarWidth > 0) {
9
+ const actualPadding = parseFloat(window.getComputedStyle(body).paddingRight);
10
+ bodyStyle.paddingRight = `${actualPadding + scrollbarWidth}px`;
11
+ }
12
+ bodyStyle.overflow = "hidden";
13
+ return () => {
14
+ if (scrollbarWidth > 0) {
15
+ bodyStyle.paddingRight = paddingRight;
16
+ }
17
+ bodyStyle.overflow = overflow;
18
+ };
19
+ };
20
+ let internalRevert = utils_func.noop;
21
+ const removeScrollbars = () => {
22
+ internalRevert();
23
+ internalRevert = internalRemoveScrollbars();
24
+ };
25
+ const revertScrollbars = () => {
26
+ internalRevert();
27
+ internalRevert = utils_func.noop;
28
+ };
29
+ exports.removeScrollbars = removeScrollbars;
30
+ exports.revertScrollbars = revertScrollbars;
@@ -0,0 +1,31 @@
1
+ import { noop } from "./utils/func.js";
2
+ const internalRemoveScrollbars = () => {
3
+ const scrollbarWidth = Math.abs(window.innerWidth - document.documentElement.clientWidth);
4
+ const body = document.body;
5
+ const bodyStyle = body.style;
6
+ const { overflow, paddingRight } = bodyStyle;
7
+ if (scrollbarWidth > 0) {
8
+ const actualPadding = parseFloat(window.getComputedStyle(body).paddingRight);
9
+ bodyStyle.paddingRight = `${actualPadding + scrollbarWidth}px`;
10
+ }
11
+ bodyStyle.overflow = "hidden";
12
+ return () => {
13
+ if (scrollbarWidth > 0) {
14
+ bodyStyle.paddingRight = paddingRight;
15
+ }
16
+ bodyStyle.overflow = overflow;
17
+ };
18
+ };
19
+ let internalRevert = noop;
20
+ const removeScrollbars = () => {
21
+ internalRevert();
22
+ internalRevert = internalRemoveScrollbars();
23
+ };
24
+ const revertScrollbars = () => {
25
+ internalRevert();
26
+ internalRevert = noop;
27
+ };
28
+ export {
29
+ revertScrollbars as a,
30
+ removeScrollbars as r
31
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const tansu = require("@amadeus-it-group/tansu");
4
+ const utils_stores = require("../utils/stores.cjs");
5
+ const types = require("../types.cjs");
6
+ const extendWidgetProps = (factory, extraPropsDefaults, extraPropsConfig, overrideDefaults) => {
7
+ const extendedFactory = (propsConfig) => {
8
+ const extraPropsWritables = utils_stores.writablesWithDefault(
9
+ extraPropsDefaults,
10
+ propsConfig,
11
+ extraPropsConfig
12
+ );
13
+ const propsConfigConfig = propsConfig?.config;
14
+ const config = utils_stores.isStore(propsConfigConfig) ? tansu.computed(() => ({ ...overrideDefaults, ...propsConfigConfig() })) : { ...overrideDefaults, ...propsConfigConfig ?? {} };
15
+ const widget = factory({ props: propsConfig?.props, config });
16
+ return {
17
+ ...widget,
18
+ ...utils_stores.stateStores({ ...widget.stores, ...extraPropsWritables }),
19
+ patch: (storesValues) => tansu.batch(() => {
20
+ let widgetProps;
21
+ for (const [name, value] of Object.entries(storesValues ?? {})) {
22
+ const extraPropsStore = extraPropsWritables[`${name}$`];
23
+ if (extraPropsStore) {
24
+ extraPropsStore.set(value);
25
+ } else {
26
+ if (!widgetProps) {
27
+ widgetProps = {};
28
+ }
29
+ widgetProps[name] = value;
30
+ }
31
+ }
32
+ if (widgetProps) {
33
+ widget.patch(widgetProps);
34
+ }
35
+ })
36
+ };
37
+ };
38
+ extendedFactory[types.FACTORY_WIDGET_NAME] = factory[types.FACTORY_WIDGET_NAME];
39
+ return extendedFactory;
40
+ };
41
+ exports.extendWidgetProps = extendWidgetProps;
@@ -0,0 +1,31 @@
1
+ import type { ConfigValidator, Widget, WidgetFactory, WidgetProps, WidgetState } from '../types';
2
+ /**
3
+ * Type extending the original Widget props and state with ExtraProps
4
+ *
5
+ * @template W - The base widget type to be extended.
6
+ * @template ExtraProps - Additional properties to be added to the widget.
7
+ * @template ExtraDirectives - Additional directives to be added to the widget. Defaults to an empty object.
8
+ */
9
+ export type ExtendWidgetProps<W extends Widget, ExtraProps extends object, ExtraDirectives extends object = object> = Widget<WidgetProps<W> & ExtraProps, WidgetState<W> & ExtraProps, W['api'], ExtendWidgetInterfaces<W['directives'], ExtraDirectives>>;
10
+ /**
11
+ * Combines two interface types into a single type.
12
+ *
13
+ * @template Interfaces - The base interface type.
14
+ * @template ExtraInterfaces - The additional interface type to extend the base interface.
15
+ * @typedef {Interfaces & ExtraInterfaces} ExtendWidgetInterfaces - The resulting type that includes properties from both Interfaces and ExtraInterfaces.
16
+ */
17
+ export type ExtendWidgetInterfaces<Interfaces, ExtraInterfaces> = Interfaces & ExtraInterfaces;
18
+ /**
19
+ * Method to extend the original widget with extra props with validator
20
+ *
21
+ * @template W - The type of the widget.
22
+ * @template ExtraProps - The type of the additional properties.
23
+ * @template ExtraDirectives - The type of the additional directives (default is an empty object).
24
+ *
25
+ * @param factory - original widget factory
26
+ * @param extraPropsDefaults - object containing default value for each extra prop
27
+ * @param extraPropsConfig - object verifying the type of each extra prop
28
+ * @param overrideDefaults - object overriding some default props of the widget to extend
29
+ * @returns widget factory with the extra props
30
+ */
31
+ export declare const extendWidgetProps: <W extends Widget, ExtraProps extends object, ExtraDirectives extends object = object>(factory: WidgetFactory<W>, extraPropsDefaults: ExtraProps, extraPropsConfig?: ConfigValidator<ExtraProps>, overrideDefaults?: Partial<WidgetState<W>>) => WidgetFactory<ExtendWidgetProps<W, ExtraProps, ExtraDirectives>>;
@@ -0,0 +1,41 @@
1
+ import { computed, batch } from "@amadeus-it-group/tansu";
2
+ import { writablesWithDefault, isStore, stateStores } from "../utils/stores.js";
3
+ import { FACTORY_WIDGET_NAME } from "../types.js";
4
+ const extendWidgetProps = (factory, extraPropsDefaults, extraPropsConfig, overrideDefaults) => {
5
+ const extendedFactory = (propsConfig) => {
6
+ const extraPropsWritables = writablesWithDefault(
7
+ extraPropsDefaults,
8
+ propsConfig,
9
+ extraPropsConfig
10
+ );
11
+ const propsConfigConfig = propsConfig?.config;
12
+ const config = isStore(propsConfigConfig) ? computed(() => ({ ...overrideDefaults, ...propsConfigConfig() })) : { ...overrideDefaults, ...propsConfigConfig ?? {} };
13
+ const widget = factory({ props: propsConfig?.props, config });
14
+ return {
15
+ ...widget,
16
+ ...stateStores({ ...widget.stores, ...extraPropsWritables }),
17
+ patch: (storesValues) => batch(() => {
18
+ let widgetProps;
19
+ for (const [name, value] of Object.entries(storesValues ?? {})) {
20
+ const extraPropsStore = extraPropsWritables[`${name}$`];
21
+ if (extraPropsStore) {
22
+ extraPropsStore.set(value);
23
+ } else {
24
+ if (!widgetProps) {
25
+ widgetProps = {};
26
+ }
27
+ widgetProps[name] = value;
28
+ }
29
+ }
30
+ if (widgetProps) {
31
+ widget.patch(widgetProps);
32
+ }
33
+ })
34
+ };
35
+ };
36
+ extendedFactory[FACTORY_WIDGET_NAME] = factory[FACTORY_WIDGET_NAME];
37
+ return extendedFactory;
38
+ };
39
+ export {
40
+ extendWidgetProps
41
+ };
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const tansu = require("@amadeus-it-group/tansu");
4
+ const dom = require("@floating-ui/dom");
5
+ const utils_directive = require("../directive-DCaXmRe_.cjs");
6
+ const promise = require("../promise-CxCD3NYv.cjs");
7
+ const utils_stores = require("../utils/stores.cjs");
8
+ const defaultConfig = {
9
+ computePositionOptions: {},
10
+ autoUpdateOptions: {},
11
+ arrowOptions: {}
12
+ };
13
+ const createFloatingUI = (propsConfig) => {
14
+ const [
15
+ { autoUpdateOptions$, computePositionOptions$: computePositionInputOptions$, arrowOptions$: arrowInputOptions$ },
16
+ patch
17
+ ] = utils_stores.writablesForProps(defaultConfig, propsConfig);
18
+ const { directive: floatingDirective, element$: floatingElement$ } = utils_directive.createBrowserStoreDirective();
19
+ const { directive: referenceDirective, element$: referenceElement$ } = utils_directive.createBrowserStoreDirective();
20
+ const { directive: arrowDirective, element$: arrowElement$ } = utils_directive.createBrowserStoreDirective();
21
+ const arrowOptions$ = tansu.computed(() => {
22
+ const arrowElement = arrowElement$();
23
+ if (!arrowElement) {
24
+ return null;
25
+ }
26
+ const arrowInputOptions = arrowInputOptions$();
27
+ return typeof arrowInputOptions === "function" ? (state) => ({ ...arrowInputOptions(state), element: arrowElement }) : { ...arrowInputOptions, element: arrowElement };
28
+ });
29
+ const computePositionOptions$ = tansu.computed(() => {
30
+ let options = computePositionInputOptions$();
31
+ const arrowOptions = arrowOptions$();
32
+ if (arrowOptions) {
33
+ options = {
34
+ ...options,
35
+ middleware: [...options.middleware ?? [], dom.arrow(arrowOptions)]
36
+ };
37
+ }
38
+ return options;
39
+ });
40
+ const promisePosition$ = tansu.derived(
41
+ [floatingElement$, referenceElement$, computePositionOptions$, autoUpdateOptions$],
42
+ ([floatingElement, referenceElement, computePositionOptions, autoUpdateOptions], set) => {
43
+ if (floatingElement && referenceElement) {
44
+ const clean = dom.autoUpdate(
45
+ referenceElement,
46
+ floatingElement,
47
+ () => {
48
+ set(dom.computePosition(referenceElement, floatingElement, computePositionOptions));
49
+ },
50
+ autoUpdateOptions
51
+ );
52
+ return () => {
53
+ set(null);
54
+ clean();
55
+ };
56
+ }
57
+ return void 0;
58
+ },
59
+ null
60
+ );
61
+ const position$ = promise.promiseStoreToValueStore(promisePosition$, null);
62
+ const placement$ = tansu.computed(() => position$()?.placement);
63
+ const middlewareData$ = tansu.computed(() => position$()?.middlewareData);
64
+ const x$ = tansu.computed(() => position$()?.x);
65
+ const y$ = tansu.computed(() => position$()?.y);
66
+ const strategy$ = tansu.computed(() => position$()?.strategy);
67
+ const arrowX$ = tansu.computed(() => middlewareData$()?.arrow?.x);
68
+ const arrowY$ = tansu.computed(() => middlewareData$()?.arrow?.y);
69
+ const floatingStyleApplyAction$ = tansu.computed(() => {
70
+ const floatingElement = floatingElement$();
71
+ if (floatingElement) {
72
+ floatingElement.style.left = `${x$() ?? 0}px`;
73
+ floatingElement.style.top = `${y$() ?? 0}px`;
74
+ }
75
+ });
76
+ const arrowStyleApplyAction$ = tansu.computed(() => {
77
+ const arrowElement = arrowElement$();
78
+ if (arrowElement) {
79
+ const arrowX = arrowX$();
80
+ const arrowY = arrowY$();
81
+ arrowElement.style.left = arrowX != null ? `${arrowX}px` : "";
82
+ arrowElement.style.top = arrowY != null ? `${arrowY}px` : "";
83
+ }
84
+ });
85
+ return {
86
+ patch,
87
+ ...utils_stores.stateStores({
88
+ x$,
89
+ y$,
90
+ strategy$,
91
+ placement$,
92
+ middlewareData$
93
+ }),
94
+ directives: {
95
+ /**
96
+ * Directive to be used on the reference element from where the floating element will be positioned
97
+ */
98
+ referenceDirective,
99
+ /**
100
+ * Directive to be used on the floating element
101
+ */
102
+ floatingDirective: utils_directive.mergeDirectives(floatingDirective, utils_directive.directiveSubscribe(floatingStyleApplyAction$)),
103
+ /**
104
+ * Directive to be used on the arrow element, if any
105
+ */
106
+ arrowDirective: utils_directive.mergeDirectives(arrowDirective, utils_directive.directiveSubscribe(arrowStyleApplyAction$))
107
+ },
108
+ api: {}
109
+ };
110
+ };
111
+ exports.createFloatingUI = createFloatingUI;