@agnos-ui/core 0.1.1 → 0.3.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.
- package/README.md +3 -3
- package/accordion-BaWN0_n-.js +330 -0
- package/accordion-BuIgxZ0S.cjs +329 -0
- package/alert-C4jCg9Pl.cjs +8 -0
- package/alert-Dlf-BV98.js +9 -0
- package/common-DRdsw5m8.js +76 -0
- package/common-nJRMXbwj.cjs +75 -0
- package/components/accordion/accordion.d.ts +57 -64
- package/components/accordion/index.cjs +7 -0
- package/components/accordion/index.js +7 -1
- package/components/alert/alert.d.ts +3 -12
- package/components/alert/common.d.ts +4 -13
- package/components/alert/index.cjs +10 -0
- package/components/alert/index.js +10 -2
- package/components/modal/index.cjs +7 -0
- package/components/modal/index.js +7 -1
- package/components/modal/modal.d.ts +7 -49
- package/components/pagination/index.cjs +5 -0
- package/components/pagination/index.d.ts +0 -1
- package/components/pagination/index.js +5 -2
- package/components/pagination/pagination.d.ts +107 -128
- package/components/progressbar/index.cjs +5 -0
- package/components/progressbar/index.js +5 -1
- package/components/progressbar/progressbar.d.ts +6 -22
- package/components/rating/index.cjs +5 -0
- package/components/rating/index.js +5 -1
- package/components/rating/rating.d.ts +16 -11
- package/components/select/index.cjs +6 -0
- package/components/select/index.js +6 -1
- package/components/select/select.d.ts +45 -57
- package/components/slider/index.cjs +5 -0
- package/components/slider/index.js +5 -1
- package/components/slider/slider.d.ts +63 -5
- package/components/toast/index.cjs +5 -0
- package/components/toast/index.d.ts +1 -0
- package/components/toast/index.js +5 -0
- package/components/toast/toast.d.ts +47 -0
- package/config.cjs +38 -0
- package/config.d.ts +6 -1
- package/config.js +35 -50
- package/directive-BTSEYLF3.cjs +404 -0
- package/directive-DCYlDznf.js +405 -0
- package/func-DR0n-ShK.js +7 -0
- package/func-Qd3cD9a3.cjs +6 -0
- package/index.cjs +119 -0
- package/index.d.ts +3 -1
- package/index.js +119 -31
- package/modal-BI2qUu1M.js +251 -0
- package/modal-rzMpATf5.cjs +250 -0
- package/package.json +30 -22
- package/pagination--GkwduJn.js +263 -0
- package/pagination-EWSWQT1I.cjs +262 -0
- package/progressbar-DH7DHYMp.cjs +83 -0
- package/progressbar-DuRX7_my.js +84 -0
- package/promise-BMJ8qhA8.cjs +118 -0
- package/promise-CY2U8bTP.js +119 -0
- package/rating-BR5wD7y2.js +173 -0
- package/rating-CmuYUSxy.cjs +172 -0
- package/select-BCs6HQWn.js +358 -0
- package/select-CCIKn8WR.cjs +357 -0
- package/services/extendWidget.cjs +32 -0
- package/services/extendWidget.d.ts +10 -5
- package/services/extendWidget.js +31 -34
- package/services/floatingUI.cjs +131 -0
- package/services/floatingUI.d.ts +30 -14
- package/services/floatingUI.js +128 -102
- package/services/focustrack.cjs +47 -0
- package/services/focustrack.js +45 -44
- package/services/hash.cjs +15 -0
- package/services/hash.d.ts +2 -0
- package/services/hash.js +15 -0
- package/services/intersection.cjs +53 -0
- package/services/intersection.js +48 -50
- package/services/matchMedia.cjs +13 -0
- package/services/matchMedia.d.ts +7 -0
- package/services/matchMedia.js +13 -0
- package/services/navManager.cjs +196 -0
- package/services/navManager.d.ts +24 -17
- package/services/navManager.js +186 -162
- package/services/portal.cjs +43 -0
- package/services/portal.js +41 -42
- package/services/resizeObserver.cjs +32 -0
- package/services/resizeObserver.d.ts +14 -0
- package/services/resizeObserver.js +32 -0
- package/services/siblingsInert.cjs +40 -0
- package/services/siblingsInert.js +31 -31
- package/services/transitions/baseTransitions.cjs +171 -0
- package/services/transitions/baseTransitions.d.ts +16 -16
- package/services/transitions/baseTransitions.js +159 -170
- package/services/transitions/collapse.cjs +44 -0
- package/services/transitions/collapse.js +41 -49
- package/services/transitions/cssTransitions.cjs +32 -0
- package/services/transitions/cssTransitions.d.ts +2 -1
- package/services/transitions/cssTransitions.js +29 -39
- package/services/transitions/simpleClassTransition.cjs +31 -0
- package/services/transitions/simpleClassTransition.js +30 -41
- package/slider-CA_fszn7.js +536 -0
- package/slider-DsLvT87U.cjs +535 -0
- package/toast-8tWp6x89.js +63 -0
- package/toast-Aw8o0Iwe.cjs +62 -0
- package/types.cjs +12 -0
- package/types.d.ts +21 -1
- package/types.js +11 -13
- package/utils/directive.cjs +26 -0
- package/utils/directive.d.ts +155 -4
- package/utils/directive.js +25 -189
- package/utils/internal/dom.d.ts +57 -3
- package/utils/internal/promise.d.ts +2 -2
- package/utils/internal/ssrHTMLElement.d.ts +7 -0
- package/utils/internal/textDirection.d.ts +1 -1
- package/utils/stores.cjs +163 -0
- package/utils/stores.d.ts +23 -20
- package/utils/stores.js +151 -269
- package/utils/writables.cjs +13 -0
- package/utils/writables.js +12 -71
- package/writables-D46sFgGK.cjs +85 -0
- package/writables-DoU_XYTX.js +86 -0
- package/components/accordion/accordion.js +0 -267
- package/components/alert/alert.js +0 -22
- package/components/alert/common.js +0 -69
- package/components/commonProps.js +0 -1
- package/components/modal/modal.js +0 -186
- package/components/pagination/bootstrap.d.ts +0 -8
- package/components/pagination/bootstrap.js +0 -110
- package/components/pagination/pagination.js +0 -149
- package/components/progressbar/progressbar.js +0 -78
- package/components/rating/rating.js +0 -138
- package/components/select/select.js +0 -266
- package/components/slider/slider.js +0 -415
- package/services/transitions/bootstrap/collapse.d.ts +0 -2
- package/services/transitions/bootstrap/collapse.js +0 -15
- package/services/transitions/bootstrap/fade.d.ts +0 -1
- package/services/transitions/bootstrap/fade.js +0 -7
- package/services/transitions/bootstrap.d.ts +0 -2
- package/services/transitions/bootstrap.js +0 -2
- package/utils/internal/checks.js +0 -60
- package/utils/internal/dom.js +0 -61
- package/utils/internal/func.js +0 -11
- package/utils/internal/isFocusable.js +0 -35
- package/utils/internal/math.js +0 -13
- package/utils/internal/promise.js +0 -169
- package/utils/internal/scrollbars.js +0 -33
- package/utils/internal/sort.js +0 -28
- package/utils/internal/textDirection.js +0 -7
- package/utils/internal/traversal.js +0 -105
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
3
|
+
const esmEnv = require("esm-env");
|
|
4
|
+
const func = require("./func-Qd3cD9a3.cjs");
|
|
5
|
+
const utils_stores = require("./utils/stores.cjs");
|
|
6
|
+
const computeCommonAncestor = (elements) => {
|
|
7
|
+
const length = elements.length;
|
|
8
|
+
if (length === 0)
|
|
9
|
+
return null;
|
|
10
|
+
let ancestor = elements[0];
|
|
11
|
+
for (let i = 1; i < length && ancestor; i++) {
|
|
12
|
+
const element = elements[i];
|
|
13
|
+
while (ancestor) {
|
|
14
|
+
if (ancestor === element) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
const comparison = ancestor.compareDocumentPosition(element);
|
|
18
|
+
if (comparison & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
19
|
+
break;
|
|
20
|
+
} else if (comparison & Node.DOCUMENT_POSITION_CONTAINS) {
|
|
21
|
+
ancestor = element;
|
|
22
|
+
break;
|
|
23
|
+
} else if (comparison & Node.DOCUMENT_POSITION_DISCONNECTED) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
ancestor = ancestor.parentElement;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return ancestor;
|
|
30
|
+
};
|
|
31
|
+
const reflow = esmEnv.BROWSER ? (element = document.body) => {
|
|
32
|
+
if (isBrowserHTMLElement(element)) {
|
|
33
|
+
element.getBoundingClientRect();
|
|
34
|
+
}
|
|
35
|
+
} : func.noop;
|
|
36
|
+
const addClasses = (element, classes) => {
|
|
37
|
+
if (classes && classes.length > 0) {
|
|
38
|
+
element.classList.add(...classes);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const removeClasses = (element, classes) => {
|
|
42
|
+
if (classes && classes.length > 0) {
|
|
43
|
+
element.classList.remove(...classes);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
function addEvent(element, type, fn, options) {
|
|
47
|
+
element.addEventListener(type, fn, options);
|
|
48
|
+
return function() {
|
|
49
|
+
element.removeEventListener(type, fn, options);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
let idCount = 0;
|
|
53
|
+
const generateId = () => `auId-${idCount++}`;
|
|
54
|
+
const notEmpty = (value) => value != null && value !== false;
|
|
55
|
+
function classNamesSubscribe(node, classNames$) {
|
|
56
|
+
let currentClassNames = /* @__PURE__ */ new Set();
|
|
57
|
+
return classNames$.subscribe((newClassName) => {
|
|
58
|
+
const classNames = new Set(`${newClassName ?? ""}`.split(" "));
|
|
59
|
+
classNames.delete("");
|
|
60
|
+
const classList = node.classList;
|
|
61
|
+
for (const className of currentClassNames) {
|
|
62
|
+
if (!classNames.has(className)) {
|
|
63
|
+
classList.remove(className);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (classNames.size > 0) {
|
|
67
|
+
classList.add(...classNames);
|
|
68
|
+
}
|
|
69
|
+
currentClassNames = classNames;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function attributeSubscribe(node, attributeName, value$) {
|
|
73
|
+
return value$.subscribe((value) => {
|
|
74
|
+
if (notEmpty(value)) {
|
|
75
|
+
node.setAttribute(attributeName, "" + (value === true ? attributeName : value));
|
|
76
|
+
} else {
|
|
77
|
+
node.removeAttribute(attributeName);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function bindAttribute(node, attributeName, value$) {
|
|
82
|
+
const isClass = attributeName === "class";
|
|
83
|
+
return isClass ? classNamesSubscribe(node, value$) : attributeSubscribe(node, attributeName, value$);
|
|
84
|
+
}
|
|
85
|
+
function bindStyle(node, styleName, value$) {
|
|
86
|
+
return value$.subscribe((value) => {
|
|
87
|
+
const style = node.style;
|
|
88
|
+
style[styleName] = "" + (notEmpty(value) ? value : "");
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function bindClassName(node, className, value$) {
|
|
92
|
+
const unsubscribe = value$.subscribe((isPresent) => {
|
|
93
|
+
node.classList.toggle(className, isPresent);
|
|
94
|
+
});
|
|
95
|
+
return () => {
|
|
96
|
+
unsubscribe();
|
|
97
|
+
node.classList.remove(className);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const ssrHTMLElementAttributesAndStyle = Symbol("attributesAndStyle");
|
|
101
|
+
const spaceRegExp = /\s+/;
|
|
102
|
+
const ssrHTMLElement = () => {
|
|
103
|
+
const attributes = {};
|
|
104
|
+
const style = {};
|
|
105
|
+
let classNames = /* @__PURE__ */ new Set();
|
|
106
|
+
const toggleClass = (className, force = !classNames.has(className)) => {
|
|
107
|
+
if (force) {
|
|
108
|
+
classNames.add(className);
|
|
109
|
+
} else {
|
|
110
|
+
classNames.delete(className);
|
|
111
|
+
}
|
|
112
|
+
return !!force;
|
|
113
|
+
};
|
|
114
|
+
const toggleAll = (force) => (...classNames2) => classNames2.forEach((className) => toggleClass(className, force));
|
|
115
|
+
return {
|
|
116
|
+
style,
|
|
117
|
+
classList: {
|
|
118
|
+
add: toggleAll(true),
|
|
119
|
+
remove: toggleAll(false),
|
|
120
|
+
toggle: toggleClass
|
|
121
|
+
},
|
|
122
|
+
setAttribute(name, value) {
|
|
123
|
+
if (name === "class") {
|
|
124
|
+
classNames = new Set(value.trim().split(spaceRegExp));
|
|
125
|
+
} else if (name === "style") {
|
|
126
|
+
throw new Error('setAttribute("style",...) is not implemented in ssrHTMLElement. Use the style property instead.');
|
|
127
|
+
} else {
|
|
128
|
+
attributes[name] = value;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
removeAttribute(name) {
|
|
132
|
+
if (name === "class") {
|
|
133
|
+
classNames = /* @__PURE__ */ new Set();
|
|
134
|
+
} else {
|
|
135
|
+
delete attributes[name];
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[ssrHTMLElementAttributesAndStyle]() {
|
|
139
|
+
return { attributes: { ...attributes }, classNames: [...classNames], style: { ...style } };
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const isBrowserHTMLElement = esmEnv.BROWSER ? (element) => {
|
|
144
|
+
var _a;
|
|
145
|
+
const contentWindow = ((_a = element == null ? void 0 : element.ownerDocument) == null ? void 0 : _a.defaultView) ?? window;
|
|
146
|
+
return element instanceof contentWindow.HTMLElement;
|
|
147
|
+
} : (element) => false;
|
|
148
|
+
const browserDirective = esmEnv.BROWSER ? (directive) => (node, args) => {
|
|
149
|
+
if (isBrowserHTMLElement(node)) {
|
|
150
|
+
return directive(node, args);
|
|
151
|
+
}
|
|
152
|
+
} : (directive) => () => {
|
|
153
|
+
};
|
|
154
|
+
const bindDirective = (directive, directiveArg$) => (element) => {
|
|
155
|
+
let firstTime = true;
|
|
156
|
+
let instance;
|
|
157
|
+
const unsubscribe = directiveArg$.subscribe((value) => {
|
|
158
|
+
var _a;
|
|
159
|
+
if (firstTime) {
|
|
160
|
+
firstTime = false;
|
|
161
|
+
instance = directive(element, value);
|
|
162
|
+
} else {
|
|
163
|
+
(_a = instance == null ? void 0 : instance.update) == null ? void 0 : _a.call(instance, value);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
destroy() {
|
|
168
|
+
var _a;
|
|
169
|
+
(_a = instance == null ? void 0 : instance.destroy) == null ? void 0 : _a.call(instance);
|
|
170
|
+
unsubscribe();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
const noArg = tansu.readable(void 0);
|
|
175
|
+
const bindDirectiveNoArg = (directive) => bindDirective(directive, noArg);
|
|
176
|
+
const mapDirectiveArg = (directive, fn) => (node, arg) => {
|
|
177
|
+
const instance = directive(node, fn(arg));
|
|
178
|
+
return {
|
|
179
|
+
update: (arg2) => {
|
|
180
|
+
var _a;
|
|
181
|
+
(_a = instance == null ? void 0 : instance.update) == null ? void 0 : _a.call(instance, fn(arg2));
|
|
182
|
+
},
|
|
183
|
+
destroy: () => {
|
|
184
|
+
var _a;
|
|
185
|
+
return (_a = instance == null ? void 0 : instance.destroy) == null ? void 0 : _a.call(instance);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
const directiveSubscribe = (store, asyncUnsubscribe = true) => () => {
|
|
190
|
+
const unsubscribe = store.subscribe(func.noop);
|
|
191
|
+
return {
|
|
192
|
+
destroy: async () => {
|
|
193
|
+
if (asyncUnsubscribe) {
|
|
194
|
+
await 0;
|
|
195
|
+
}
|
|
196
|
+
unsubscribe();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
const directiveUpdate = (update) => (element, arg) => {
|
|
201
|
+
update(arg);
|
|
202
|
+
return {
|
|
203
|
+
update
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
const equalOption = { equal: Object.is };
|
|
207
|
+
const registrationArray = () => {
|
|
208
|
+
const elements$ = tansu.writable([], equalOption);
|
|
209
|
+
return tansu.asReadable(elements$, {
|
|
210
|
+
/**
|
|
211
|
+
* Add the given element to the array.
|
|
212
|
+
* @param element - Element to be added to the array.
|
|
213
|
+
* @returns A function to remove the element from the array.
|
|
214
|
+
*/
|
|
215
|
+
register: (element) => {
|
|
216
|
+
let removed = false;
|
|
217
|
+
elements$.update((currentElements) => [...currentElements, element]);
|
|
218
|
+
return () => {
|
|
219
|
+
if (!removed) {
|
|
220
|
+
removed = true;
|
|
221
|
+
elements$.update((currentElements) => {
|
|
222
|
+
const index = currentElements.indexOf(element);
|
|
223
|
+
if (index > -1) {
|
|
224
|
+
const copy = [...currentElements];
|
|
225
|
+
copy.splice(index, 1);
|
|
226
|
+
return copy;
|
|
227
|
+
}
|
|
228
|
+
return currentElements;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
const createStoreArrayDirective = () => {
|
|
236
|
+
const elements$ = registrationArray();
|
|
237
|
+
return {
|
|
238
|
+
elements$: tansu.asReadable(elements$),
|
|
239
|
+
directive: (element) => ({ destroy: elements$.register(element) })
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
const createBrowserStoreArrayDirective = () => {
|
|
243
|
+
const { directive, elements$ } = createStoreArrayDirective();
|
|
244
|
+
return { directive: browserDirective(directive), elements$ };
|
|
245
|
+
};
|
|
246
|
+
const createStoreDirective = () => {
|
|
247
|
+
const element$ = tansu.writable(null, equalOption);
|
|
248
|
+
return {
|
|
249
|
+
element$: tansu.asReadable(element$),
|
|
250
|
+
directive: (element) => {
|
|
251
|
+
let valid = false;
|
|
252
|
+
element$.update((currentElement) => {
|
|
253
|
+
if (currentElement) {
|
|
254
|
+
console.error("The directive cannot be used on multiple elements.", currentElement, element);
|
|
255
|
+
return currentElement;
|
|
256
|
+
}
|
|
257
|
+
valid = true;
|
|
258
|
+
return element;
|
|
259
|
+
});
|
|
260
|
+
return valid ? {
|
|
261
|
+
destroy() {
|
|
262
|
+
element$.update((currentElement) => element === currentElement ? null : currentElement);
|
|
263
|
+
}
|
|
264
|
+
} : void 0;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
const createBrowserStoreDirective = () => {
|
|
269
|
+
const { directive, element$ } = createStoreDirective();
|
|
270
|
+
return { directive: browserDirective(directive), element$ };
|
|
271
|
+
};
|
|
272
|
+
const mergeDirectives = (...args) => (element, arg) => {
|
|
273
|
+
const instances = tansu.batch(() => args.map((directive) => directive(element, arg)));
|
|
274
|
+
return {
|
|
275
|
+
update(arg2) {
|
|
276
|
+
tansu.batch(() => instances.forEach((instance) => {
|
|
277
|
+
var _a;
|
|
278
|
+
return (_a = instance == null ? void 0 : instance.update) == null ? void 0 : _a.call(instance, arg2);
|
|
279
|
+
}));
|
|
280
|
+
},
|
|
281
|
+
destroy() {
|
|
282
|
+
tansu.batch(() => instances.reverse().forEach((instance) => {
|
|
283
|
+
var _a;
|
|
284
|
+
return (_a = instance == null ? void 0 : instance.destroy) == null ? void 0 : _a.call(instance);
|
|
285
|
+
}));
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
const multiDirective = (element, directives) => {
|
|
290
|
+
const instances = [];
|
|
291
|
+
const update = (directives2) => tansu.batch(() => {
|
|
292
|
+
directives2.forEach((directiveWithArg, index) => {
|
|
293
|
+
var _a, _b, _c, _d;
|
|
294
|
+
const [directive, arg] = Array.isArray(directiveWithArg) ? directiveWithArg : [directiveWithArg, void 0];
|
|
295
|
+
const oldInstance = instances[index];
|
|
296
|
+
if (oldInstance) {
|
|
297
|
+
if (oldInstance.directive === directive) {
|
|
298
|
+
if (oldInstance.arg !== arg) {
|
|
299
|
+
(_b = (_a = oldInstance.instance) == null ? void 0 : _a.update) == null ? void 0 : _b.call(_a, arg);
|
|
300
|
+
oldInstance.arg = arg;
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
(_d = (_c = oldInstance.instance) == null ? void 0 : _c.destroy) == null ? void 0 : _d.call(_c);
|
|
305
|
+
}
|
|
306
|
+
const instance = directive(element, arg);
|
|
307
|
+
instances[index] = { directive, instance, arg };
|
|
308
|
+
});
|
|
309
|
+
const extraInstances = instances.splice(directives2.length);
|
|
310
|
+
extraInstances.reverse().forEach(({ instance }) => {
|
|
311
|
+
var _a;
|
|
312
|
+
return (_a = instance == null ? void 0 : instance.destroy) == null ? void 0 : _a.call(instance);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
update(directives);
|
|
316
|
+
return {
|
|
317
|
+
update,
|
|
318
|
+
destroy: () => update([])
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
const createAttributesDirective = (propsFn) => (node, args) => {
|
|
322
|
+
const unsubscribers = [];
|
|
323
|
+
const args$ = tansu.writable(args);
|
|
324
|
+
const { events, attributes, styles, classNames } = propsFn(args$);
|
|
325
|
+
if (isBrowserHTMLElement(node)) {
|
|
326
|
+
for (const [type, event] of Object.entries(events ?? {})) {
|
|
327
|
+
if (typeof event === "function") {
|
|
328
|
+
unsubscribers.push(addEvent(node, type, event));
|
|
329
|
+
} else {
|
|
330
|
+
unsubscribers.push(addEvent(node, type, event.handler, event.options));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
for (const [attributeName, value] of Object.entries(attributes ?? {})) {
|
|
335
|
+
if (value != null) {
|
|
336
|
+
unsubscribers.push(bindAttribute(node, attributeName, utils_stores.toReadableStore(value)));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
for (const [styleName, value] of Object.entries(styles ?? {})) {
|
|
340
|
+
if (value) {
|
|
341
|
+
unsubscribers.push(bindStyle(node, styleName, utils_stores.toReadableStore(value)));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
for (const [className, value] of Object.entries(classNames ?? {})) {
|
|
345
|
+
unsubscribers.push(bindClassName(node, className, utils_stores.toReadableStore(value)));
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
update: (args2) => args$.set(args2),
|
|
349
|
+
destroy: () => unsubscribers.forEach((fn) => fn())
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
const attributesData = (...directives) => {
|
|
353
|
+
const instances = [];
|
|
354
|
+
try {
|
|
355
|
+
const element = ssrHTMLElement();
|
|
356
|
+
for (const directive of directives) {
|
|
357
|
+
instances.push(Array.isArray(directive) ? directive[0](element, directive[1]) : directive(element));
|
|
358
|
+
}
|
|
359
|
+
return element[ssrHTMLElementAttributesAndStyle]();
|
|
360
|
+
} finally {
|
|
361
|
+
instances.forEach((instance) => {
|
|
362
|
+
var _a;
|
|
363
|
+
return (_a = instance == null ? void 0 : instance.destroy) == null ? void 0 : _a.call(instance);
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
const classDirective = createAttributesDirective((className) => ({ attributes: { class: className } }));
|
|
368
|
+
function directiveAttributes(...directives) {
|
|
369
|
+
const { attributes, classNames, style } = attributesData(...directives);
|
|
370
|
+
if (classNames.length) {
|
|
371
|
+
attributes["class"] = classNames.join(" ");
|
|
372
|
+
}
|
|
373
|
+
const stringStyle = Object.entries(style).filter(([, value]) => !!value).map(([name, value]) => `${name}: ${value};`).join("");
|
|
374
|
+
if (stringStyle.length) {
|
|
375
|
+
attributes["style"] = stringStyle;
|
|
376
|
+
}
|
|
377
|
+
return attributes;
|
|
378
|
+
}
|
|
379
|
+
const ssrAttributes = esmEnv.BROWSER ? () => ({}) : directiveAttributes;
|
|
380
|
+
exports.addClasses = addClasses;
|
|
381
|
+
exports.addEvent = addEvent;
|
|
382
|
+
exports.attributesData = attributesData;
|
|
383
|
+
exports.bindDirective = bindDirective;
|
|
384
|
+
exports.bindDirectiveNoArg = bindDirectiveNoArg;
|
|
385
|
+
exports.browserDirective = browserDirective;
|
|
386
|
+
exports.classDirective = classDirective;
|
|
387
|
+
exports.computeCommonAncestor = computeCommonAncestor;
|
|
388
|
+
exports.createAttributesDirective = createAttributesDirective;
|
|
389
|
+
exports.createBrowserStoreArrayDirective = createBrowserStoreArrayDirective;
|
|
390
|
+
exports.createBrowserStoreDirective = createBrowserStoreDirective;
|
|
391
|
+
exports.createStoreArrayDirective = createStoreArrayDirective;
|
|
392
|
+
exports.createStoreDirective = createStoreDirective;
|
|
393
|
+
exports.directiveAttributes = directiveAttributes;
|
|
394
|
+
exports.directiveSubscribe = directiveSubscribe;
|
|
395
|
+
exports.directiveUpdate = directiveUpdate;
|
|
396
|
+
exports.generateId = generateId;
|
|
397
|
+
exports.isBrowserHTMLElement = isBrowserHTMLElement;
|
|
398
|
+
exports.mapDirectiveArg = mapDirectiveArg;
|
|
399
|
+
exports.mergeDirectives = mergeDirectives;
|
|
400
|
+
exports.multiDirective = multiDirective;
|
|
401
|
+
exports.reflow = reflow;
|
|
402
|
+
exports.registrationArray = registrationArray;
|
|
403
|
+
exports.removeClasses = removeClasses;
|
|
404
|
+
exports.ssrAttributes = ssrAttributes;
|