@design-factory/core 21.1.0-next.1 → 22.0.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.
- package/{accordion-D9ba0XYq.js → accordion-B5RqDwi3.js} +76 -15
- package/alert-Db6cG6JE.js +125 -0
- package/{collapse-Bn8iHKrd.js → collapse-D8Jo56k9.js} +2 -2
- package/{common-DFyZvkII.js → common-CP4amR0Z.js} +2 -2
- package/components/accordion/accordion.d.ts +73 -15
- package/components/accordion/index.js +1 -1
- package/components/alert/alert.d.ts +77 -8
- package/components/alert/common.d.ts +9 -9
- package/components/alert/index.js +2 -3
- package/components/carousel/index.js +2 -2
- package/components/collapse/index.js +1 -1
- package/components/drawer/drawer.d.ts +6 -0
- package/components/drawer/index.js +1 -1
- package/components/dropdown/dropdown.d.ts +110 -0
- package/components/dropdown/index.d.ts +1 -0
- package/components/dropdown/index.js +5 -0
- package/components/modal/index.js +1 -1
- package/components/pagination/index.js +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/rating/index.js +1 -1
- package/components/slider/index.js +1 -1
- package/components/slider/slider.d.ts +23 -4
- package/components/toast/index.js +1 -1
- package/components/tooltip/index.d.ts +1 -0
- package/components/tooltip/index.js +174 -0
- package/components/tooltip/tooltip.d.ts +63 -0
- package/components/tree/index.js +1 -1
- package/{directive-CNNSo5Yn.js → directive-CMT2vEDg.js} +7 -4
- package/{drawer-BIIfJa0F.js → drawer-CpGnS2ln.js} +12 -5
- package/dropdown-Bjj2ql6d.js +246 -0
- package/index.d.ts +3 -1
- package/index.js +44 -37
- package/isFocusable-C2iRr0zh.js +72 -0
- package/{modal-C13G13jV.js → modal-CQWh2Sm5.js} +4 -4
- package/package.json +1 -1
- package/{pagination-BQWusWXN.js → pagination-DIRcpdRE.js} +2 -2
- package/{progressbar-S1pNn5rM.js → progressbar-Bth8r3Qu.js} +2 -2
- package/{promise-D-RZVPuv.js → promise-CkIc0KKt.js} +3 -3
- package/{rating-DWgGgwk3.js → rating-DLsgFSyB.js} +2 -2
- package/{scrollbars-CcxSrnCx.js → scrollbars-ChGk75QR.js} +3 -0
- package/services/extendWidget.d.ts +1 -1
- package/services/focusElement.js +2 -2
- package/services/focustrack.js +2 -2
- package/services/matchMedia.js +1 -1
- package/services/mousetrack.d.ts +34 -0
- package/services/mousetrack.js +41 -0
- package/services/navManager.js +2 -2
- package/services/pointerdownPosition.js +1 -1
- package/services/portal.js +1 -1
- package/services/positioning.d.ts +101 -0
- package/services/positioning.js +104 -0
- package/services/resizeObserver.js +1 -1
- package/services/siblingsInert.js +1 -1
- package/services/transitions/baseTransitions.js +3 -3
- package/services/transitions/collapse.js +4 -7
- package/services/transitions/cssTransitions.js +2 -2
- package/services/transitions/simpleClassTransition.js +1 -1
- package/{slider-Br_Qiopx.js → slider-b9cVFNAL.js} +96 -58
- package/{toaster-BUBzFeJM.js → toaster-BS9qeRLF.js} +3 -3
- package/{tree-vD7ZkV8Z.js → tree-DW6iLxdw.js} +2 -2
- package/types.d.ts +8 -1
- package/utils/debounceSignal.d.ts +11 -0
- package/utils/debounceSignal.js +18 -0
- package/utils/directive.js +1 -1
- package/utils/edgeState.d.ts +23 -0
- package/utils/edgeState.js +43 -0
- package/utils/internal/isFocusable.d.ts +40 -0
- package/utils/stores.d.ts +1 -1
- package/utils/stores.js +4 -1
- package/utils/writables.d.ts +27 -13
- package/utils/writables.js +12 -11
- package/{writables-DYGjj5T3.js → writables-_7BriMb2.js} +37 -12
- package/accordion-B0vs8JWM.cjs +0 -314
- package/alert-AhaliJ17.cjs +0 -9
- package/alert-Cb9FhbFQ.js +0 -10
- package/collapse-BnWw4Hnc.cjs +0 -94
- package/common-B5jS-Ih_.cjs +0 -73
- package/components/accordion/index.cjs +0 -7
- package/components/alert/index.cjs +0 -5
- package/components/carousel/index.cjs +0 -292
- package/components/collapse/index.cjs +0 -5
- package/components/drawer/index.cjs +0 -5
- package/components/modal/index.cjs +0 -8
- package/components/pagination/index.cjs +0 -5
- package/components/progressbar/index.cjs +0 -5
- package/components/rating/index.cjs +0 -5
- package/components/slider/index.cjs +0 -5
- package/components/toast/index.cjs +0 -7
- package/components/tree/index.cjs +0 -5
- package/config.cjs +0 -36
- package/directive-DyTodNPd.cjs +0 -523
- package/drawer-C8ojtwIn.cjs +0 -328
- package/index.cjs +0 -134
- package/isFocusable-Ckwus82R.js +0 -32
- package/isFocusable-DfzDLeAN.cjs +0 -31
- package/modal-DWv0VqiG.cjs +0 -252
- package/pagination-BLVa1UsZ.cjs +0 -254
- package/progressbar-RopgvVeA.cjs +0 -86
- package/promise-CxCD3NYv.cjs +0 -118
- package/rating-DZ3OQgtt.cjs +0 -183
- package/scrollbars-CT87iv_6.cjs +0 -30
- package/services/extendWidget.cjs +0 -41
- package/services/floatingUI.cjs +0 -111
- package/services/floatingUI.d.ts +0 -76
- package/services/floatingUI.js +0 -111
- package/services/focusElement.cjs +0 -46
- package/services/focustrack.cjs +0 -47
- package/services/hash.cjs +0 -15
- package/services/intersection.cjs +0 -53
- package/services/matchMedia.cjs +0 -14
- package/services/navManager.cjs +0 -166
- package/services/pointerdownPosition.cjs +0 -60
- package/services/portal.cjs +0 -42
- package/services/resizeObserver.cjs +0 -54
- package/services/siblingsInert.cjs +0 -44
- package/services/transitions/baseTransitions.cjs +0 -186
- package/services/transitions/collapse.cjs +0 -40
- package/services/transitions/cssTransitions.cjs +0 -32
- package/services/transitions/simpleClassTransition.cjs +0 -37
- package/slider-pgDq1V5r.cjs +0 -807
- package/textDirection-zqcZ5-eK.cjs +0 -3
- package/toaster-Dlube4Ya.cjs +0 -161
- package/tree-Chcy4ulJ.cjs +0 -228
- package/types.cjs +0 -6
- package/utils/directive.cjs +0 -28
- package/utils/func.cjs +0 -7
- package/utils/id.cjs +0 -5
- package/utils/stores.cjs +0 -172
- package/utils/widget.cjs +0 -8
- package/utils/writables.cjs +0 -16
- package/writables-Dt68gADJ.cjs +0 -102
package/directive-DyTodNPd.cjs
DELETED
|
@@ -1,523 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const tansu = require("@amadeus-it-group/tansu");
|
|
3
|
-
const esmEnv = require("esm-env");
|
|
4
|
-
const utils_func = require("./utils/func.cjs");
|
|
5
|
-
const computeCommonAncestor = (elements) => {
|
|
6
|
-
const length = elements.length;
|
|
7
|
-
if (length === 0) return null;
|
|
8
|
-
let ancestor = elements[0];
|
|
9
|
-
for (let i = 1; i < length && ancestor; i++) {
|
|
10
|
-
const element = elements[i];
|
|
11
|
-
while (ancestor) {
|
|
12
|
-
if (ancestor === element) {
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
const comparison = ancestor.compareDocumentPosition(element);
|
|
16
|
-
if (comparison & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
17
|
-
break;
|
|
18
|
-
} else if (comparison & Node.DOCUMENT_POSITION_CONTAINS) {
|
|
19
|
-
ancestor = element;
|
|
20
|
-
break;
|
|
21
|
-
} else if (comparison & Node.DOCUMENT_POSITION_DISCONNECTED) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
ancestor = ancestor.parentElement;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return ancestor;
|
|
28
|
-
};
|
|
29
|
-
const reflow = esmEnv.BROWSER ? (element = document.body) => {
|
|
30
|
-
if (isBrowserHTMLElement(element)) {
|
|
31
|
-
element.getBoundingClientRect();
|
|
32
|
-
}
|
|
33
|
-
} : utils_func.noop;
|
|
34
|
-
const addClasses = (element, classes) => {
|
|
35
|
-
if (classes && classes.length > 0) {
|
|
36
|
-
element.classList.add(...classes);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const removeClasses = (element, classes) => {
|
|
40
|
-
if (classes && classes.length > 0) {
|
|
41
|
-
element.classList.remove(...classes);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
function addEvent(element, type, fn, options) {
|
|
45
|
-
element.addEventListener(type, fn, options);
|
|
46
|
-
return function() {
|
|
47
|
-
element.removeEventListener(type, fn, options);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const notEmpty = (value) => value != null && value !== false;
|
|
51
|
-
function classNamesSubscribe(node, classNames$) {
|
|
52
|
-
let currentClassNames = /* @__PURE__ */ new Set();
|
|
53
|
-
return classNames$.subscribe((newClassName) => {
|
|
54
|
-
const classNames = new Set(`${newClassName ?? ""}`.split(" "));
|
|
55
|
-
classNames.delete("");
|
|
56
|
-
const classList = node.classList;
|
|
57
|
-
for (const className of currentClassNames) {
|
|
58
|
-
if (!classNames.has(className)) {
|
|
59
|
-
classList.remove(className);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (classNames.size > 0) {
|
|
63
|
-
classList.add(...classNames);
|
|
64
|
-
}
|
|
65
|
-
currentClassNames = classNames;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function attributeSubscribe(node, attributeName, value$) {
|
|
69
|
-
return value$.subscribe((value) => {
|
|
70
|
-
if (notEmpty(value)) {
|
|
71
|
-
node.setAttribute(attributeName, "" + (value === true ? attributeName : value));
|
|
72
|
-
} else {
|
|
73
|
-
node.removeAttribute(attributeName);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function bindAttribute(node, attributeName, value$) {
|
|
78
|
-
const isClass = attributeName === "class";
|
|
79
|
-
return isClass ? classNamesSubscribe(node, value$) : attributeSubscribe(node, attributeName, value$);
|
|
80
|
-
}
|
|
81
|
-
const isCustomProperty = (styleName) => styleName.startsWith("--");
|
|
82
|
-
function bindStyle(node, styleName, value$) {
|
|
83
|
-
return value$.subscribe((value) => {
|
|
84
|
-
const style = node.style;
|
|
85
|
-
value = "" + (notEmpty(value) ? value : "");
|
|
86
|
-
if (isCustomProperty(styleName)) {
|
|
87
|
-
style.setProperty(styleName, value);
|
|
88
|
-
} else {
|
|
89
|
-
style[styleName] = value;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function bindClassName(node, className, value$) {
|
|
94
|
-
const unsubscribe = value$.subscribe((isPresent) => {
|
|
95
|
-
node.classList.toggle(className, isPresent);
|
|
96
|
-
});
|
|
97
|
-
return () => {
|
|
98
|
-
unsubscribe();
|
|
99
|
-
node.classList.remove(className);
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
var _a;
|
|
103
|
-
const importantSuffixRegExp = /\s*!important$/;
|
|
104
|
-
const withoutImportant = (value) => value?.replace(importantSuffixRegExp, "") ?? "";
|
|
105
|
-
const toKebabCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
106
|
-
const getStyleKeyFromDirectProp = (str) => {
|
|
107
|
-
if (typeof str !== "string" || str.startsWith("--")) {
|
|
108
|
-
return void 0;
|
|
109
|
-
}
|
|
110
|
-
return toKebabCase(str);
|
|
111
|
-
};
|
|
112
|
-
const getStyleKeyFromMethods = (str) => {
|
|
113
|
-
if (!str.startsWith("--") && str !== toKebabCase(str)) {
|
|
114
|
-
return void 0;
|
|
115
|
-
}
|
|
116
|
-
return str;
|
|
117
|
-
};
|
|
118
|
-
const ssrHTMLElementStyle = /* @__PURE__ */ Symbol("style");
|
|
119
|
-
_a = ssrHTMLElementStyle;
|
|
120
|
-
class SSRStyle {
|
|
121
|
-
constructor() {
|
|
122
|
-
this[_a] = {};
|
|
123
|
-
return new Proxy(this, {
|
|
124
|
-
get: (target, prop) => {
|
|
125
|
-
const styleKey = prop in target ? void 0 : getStyleKeyFromDirectProp(prop);
|
|
126
|
-
if (styleKey) {
|
|
127
|
-
return withoutImportant(target[ssrHTMLElementStyle][styleKey]);
|
|
128
|
-
} else {
|
|
129
|
-
return target[prop];
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
set: (target, prop, value) => {
|
|
133
|
-
const styleKey = prop in target ? void 0 : getStyleKeyFromDirectProp(prop);
|
|
134
|
-
if (styleKey) {
|
|
135
|
-
target.setProperty(styleKey, value);
|
|
136
|
-
} else {
|
|
137
|
-
target[prop] = value;
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
setProperty(property, value, priority) {
|
|
144
|
-
if (!value) {
|
|
145
|
-
this.removeProperty(property);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const key = getStyleKeyFromMethods(property);
|
|
149
|
-
if (!key || priority !== "important" && priority !== "" && priority != null || importantSuffixRegExp.test(value)) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
this[ssrHTMLElementStyle][key] = value + (priority ? " !important" : "");
|
|
153
|
-
}
|
|
154
|
-
removeProperty(property) {
|
|
155
|
-
const key = getStyleKeyFromMethods(property);
|
|
156
|
-
if (!key) {
|
|
157
|
-
return "";
|
|
158
|
-
}
|
|
159
|
-
const style = this[ssrHTMLElementStyle];
|
|
160
|
-
const value = style[key];
|
|
161
|
-
delete style[key];
|
|
162
|
-
return withoutImportant(value);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const ssrHTMLElementAttributesAndStyle = /* @__PURE__ */ Symbol("attributesAndStyle");
|
|
166
|
-
const spaceRegExp = /\s+/;
|
|
167
|
-
const ssrHTMLElement = () => {
|
|
168
|
-
const attributes = {};
|
|
169
|
-
const style = new SSRStyle();
|
|
170
|
-
let classNames = /* @__PURE__ */ new Set();
|
|
171
|
-
const toggleClass = (className, force = !classNames.has(className)) => {
|
|
172
|
-
if (force) {
|
|
173
|
-
classNames.add(className);
|
|
174
|
-
} else {
|
|
175
|
-
classNames.delete(className);
|
|
176
|
-
}
|
|
177
|
-
return !!force;
|
|
178
|
-
};
|
|
179
|
-
const toggleAll = (force) => (...classNames2) => classNames2.forEach((className) => toggleClass(className, force));
|
|
180
|
-
return {
|
|
181
|
-
style,
|
|
182
|
-
classList: {
|
|
183
|
-
add: toggleAll(true),
|
|
184
|
-
remove: toggleAll(false),
|
|
185
|
-
toggle: toggleClass
|
|
186
|
-
},
|
|
187
|
-
setAttribute(name, value) {
|
|
188
|
-
if (name === "class") {
|
|
189
|
-
classNames = new Set(value.trim().split(spaceRegExp));
|
|
190
|
-
} else if (name === "style") {
|
|
191
|
-
throw new Error(
|
|
192
|
-
'setAttribute("style",...) is not implemented in ssrHTMLElement. Use the style property instead.'
|
|
193
|
-
);
|
|
194
|
-
} else {
|
|
195
|
-
attributes[name] = value;
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
removeAttribute(name) {
|
|
199
|
-
if (name === "class") {
|
|
200
|
-
classNames = /* @__PURE__ */ new Set();
|
|
201
|
-
} else {
|
|
202
|
-
delete attributes[name];
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
[ssrHTMLElementAttributesAndStyle]() {
|
|
206
|
-
return { attributes: { ...attributes }, classNames: [...classNames], style: { ...style[ssrHTMLElementStyle] } };
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
const cssEscapeStyleName = (styleName) => styleName.replace(/([^\w-])/gi, "\\$1");
|
|
211
|
-
const cssTextFromObject = (style) => Object.entries(style).filter(([, value]) => !!value).map(([name, value]) => `${cssEscapeStyleName(name)}: ${value};`).join("");
|
|
212
|
-
function r(e) {
|
|
213
|
-
var t, f, n = "";
|
|
214
|
-
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
215
|
-
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
216
|
-
var o = e.length;
|
|
217
|
-
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
218
|
-
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
219
|
-
return n;
|
|
220
|
-
}
|
|
221
|
-
function clsx() {
|
|
222
|
-
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
223
|
-
return n;
|
|
224
|
-
}
|
|
225
|
-
const isBrowserHTMLElement = esmEnv.BROWSER ? ((element) => {
|
|
226
|
-
const contentWindow = element?.ownerDocument?.defaultView ?? window;
|
|
227
|
-
return element instanceof contentWindow.HTMLElement;
|
|
228
|
-
}) : (
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
230
|
-
((element) => false)
|
|
231
|
-
);
|
|
232
|
-
const browserDirective = esmEnv.BROWSER ? (directive) => (node, args) => {
|
|
233
|
-
if (isBrowserHTMLElement(node)) {
|
|
234
|
-
return directive(node, args);
|
|
235
|
-
}
|
|
236
|
-
} : (
|
|
237
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
238
|
-
((directive) => utils_func.noop)
|
|
239
|
-
);
|
|
240
|
-
const bindDirective = (directive, directiveArg$) => (element) => {
|
|
241
|
-
let firstTime = true;
|
|
242
|
-
let instance;
|
|
243
|
-
const unsubscribe = directiveArg$.subscribe((value) => {
|
|
244
|
-
if (firstTime) {
|
|
245
|
-
firstTime = false;
|
|
246
|
-
instance = directive(element, value);
|
|
247
|
-
} else {
|
|
248
|
-
instance?.update?.(value);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
return {
|
|
252
|
-
destroy() {
|
|
253
|
-
instance?.destroy?.();
|
|
254
|
-
unsubscribe();
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
const noArg = tansu.readable(void 0);
|
|
259
|
-
const bindDirectiveNoArg = (directive) => bindDirective(directive, noArg);
|
|
260
|
-
const mapDirectiveArg = (directive, fn) => (node, arg) => {
|
|
261
|
-
const instance = directive(node, fn(arg));
|
|
262
|
-
return {
|
|
263
|
-
update: (arg2) => {
|
|
264
|
-
instance?.update?.(fn(arg2));
|
|
265
|
-
},
|
|
266
|
-
destroy: () => instance?.destroy?.()
|
|
267
|
-
};
|
|
268
|
-
};
|
|
269
|
-
const directiveSubscribe = (store, asyncUnsubscribe = true) => () => {
|
|
270
|
-
const unsubscribe = store.subscribe(utils_func.noop);
|
|
271
|
-
return {
|
|
272
|
-
destroy: () => void (async () => {
|
|
273
|
-
if (asyncUnsubscribe) {
|
|
274
|
-
await Promise.resolve();
|
|
275
|
-
}
|
|
276
|
-
unsubscribe();
|
|
277
|
-
})()
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
const directiveUpdate = (update) => (_element, arg) => {
|
|
281
|
-
update(arg);
|
|
282
|
-
return {
|
|
283
|
-
update
|
|
284
|
-
};
|
|
285
|
-
};
|
|
286
|
-
const equalOption = { equal: Object.is };
|
|
287
|
-
const registrationArray = () => {
|
|
288
|
-
const elements$ = tansu.writable([], equalOption);
|
|
289
|
-
return tansu.asReadable(elements$, {
|
|
290
|
-
/**
|
|
291
|
-
* Add the given element to the array.
|
|
292
|
-
* @param element - Element to be added to the array.
|
|
293
|
-
* @returns A function to remove the element from the array.
|
|
294
|
-
*/
|
|
295
|
-
register: (element) => {
|
|
296
|
-
let removed = false;
|
|
297
|
-
elements$.update((currentElements) => [...currentElements, element]);
|
|
298
|
-
return () => {
|
|
299
|
-
if (!removed) {
|
|
300
|
-
removed = true;
|
|
301
|
-
elements$.update((currentElements) => {
|
|
302
|
-
const index = currentElements.indexOf(element);
|
|
303
|
-
if (index > -1) {
|
|
304
|
-
const copy = [...currentElements];
|
|
305
|
-
copy.splice(index, 1);
|
|
306
|
-
return copy;
|
|
307
|
-
}
|
|
308
|
-
return currentElements;
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
};
|
|
315
|
-
const createConditionalStoreArrayDirective = () => {
|
|
316
|
-
const elements$ = registrationArray();
|
|
317
|
-
return {
|
|
318
|
-
elements$: tansu.asReadable(elements$),
|
|
319
|
-
directive: (element, enabled = true) => {
|
|
320
|
-
let destroyElements;
|
|
321
|
-
const update = (newEnabled = true) => {
|
|
322
|
-
if (!!newEnabled != !!destroyElements) {
|
|
323
|
-
if (newEnabled) {
|
|
324
|
-
destroyElements = elements$.register(element);
|
|
325
|
-
} else {
|
|
326
|
-
destroyElements?.();
|
|
327
|
-
destroyElements = void 0;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
update(enabled);
|
|
332
|
-
return {
|
|
333
|
-
destroy: () => update(false),
|
|
334
|
-
update
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
};
|
|
339
|
-
const createStoreArrayDirective = () => {
|
|
340
|
-
const { directive, elements$ } = createConditionalStoreArrayDirective();
|
|
341
|
-
return {
|
|
342
|
-
directive: bindDirectiveNoArg(directive),
|
|
343
|
-
elements$
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
const createBrowserStoreArrayDirective = () => {
|
|
347
|
-
const { directive, elements$ } = createStoreArrayDirective();
|
|
348
|
-
return { directive: browserDirective(directive), elements$ };
|
|
349
|
-
};
|
|
350
|
-
const createConditionalBrowserStoreArrayDirective = () => {
|
|
351
|
-
const { directive, elements$ } = createConditionalStoreArrayDirective();
|
|
352
|
-
return { directive: browserDirective(directive), elements$ };
|
|
353
|
-
};
|
|
354
|
-
const createStoreDirective = () => {
|
|
355
|
-
const element$ = tansu.writable(null, equalOption);
|
|
356
|
-
return {
|
|
357
|
-
element$: tansu.asReadable(element$),
|
|
358
|
-
directive: (element) => {
|
|
359
|
-
let valid = false;
|
|
360
|
-
element$.update((currentElement) => {
|
|
361
|
-
if (currentElement) {
|
|
362
|
-
console.error("The directive cannot be used on multiple elements.", currentElement, element);
|
|
363
|
-
return currentElement;
|
|
364
|
-
}
|
|
365
|
-
valid = true;
|
|
366
|
-
return element;
|
|
367
|
-
});
|
|
368
|
-
return valid ? {
|
|
369
|
-
destroy() {
|
|
370
|
-
element$.update((currentElement) => element === currentElement ? null : currentElement);
|
|
371
|
-
}
|
|
372
|
-
} : void 0;
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
};
|
|
376
|
-
const createBrowserStoreDirective = () => {
|
|
377
|
-
const { directive, element$ } = createStoreDirective();
|
|
378
|
-
return { directive: browserDirective(directive), element$ };
|
|
379
|
-
};
|
|
380
|
-
const conditionalDirective = (directive, condition) => (element, arg) => {
|
|
381
|
-
const instance$ = tansu.derived(
|
|
382
|
-
condition,
|
|
383
|
-
(enabled, set) => {
|
|
384
|
-
const instance = enabled ? directive(element, arg) : void 0;
|
|
385
|
-
set(instance);
|
|
386
|
-
return () => instance?.destroy?.();
|
|
387
|
-
},
|
|
388
|
-
void 0
|
|
389
|
-
);
|
|
390
|
-
const destroy = instance$.subscribe(() => {
|
|
391
|
-
});
|
|
392
|
-
return {
|
|
393
|
-
update(newArg) {
|
|
394
|
-
arg = newArg;
|
|
395
|
-
instance$()?.update?.(newArg);
|
|
396
|
-
},
|
|
397
|
-
destroy
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
const mergeDirectives = (...args) => (element, arg) => {
|
|
401
|
-
const instances = tansu.batch(() => args.map((directive) => directive(element, arg)));
|
|
402
|
-
return {
|
|
403
|
-
update(arg2) {
|
|
404
|
-
tansu.batch(() => instances.forEach((instance) => instance?.update?.(arg2)));
|
|
405
|
-
},
|
|
406
|
-
destroy() {
|
|
407
|
-
tansu.batch(() => instances.reverse().forEach((instance) => instance?.destroy?.()));
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
};
|
|
411
|
-
const multiDirective = (element, directives) => {
|
|
412
|
-
const instances = [];
|
|
413
|
-
const update = (directives2) => tansu.batch(() => {
|
|
414
|
-
directives2.forEach((directiveWithArg, index) => {
|
|
415
|
-
const [directive, arg] = Array.isArray(directiveWithArg) ? directiveWithArg : [directiveWithArg, void 0];
|
|
416
|
-
const oldInstance = instances[index];
|
|
417
|
-
if (oldInstance) {
|
|
418
|
-
if (oldInstance.directive === directive) {
|
|
419
|
-
if (oldInstance.arg !== arg) {
|
|
420
|
-
oldInstance.instance?.update?.(arg);
|
|
421
|
-
oldInstance.arg = arg;
|
|
422
|
-
}
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
oldInstance.instance?.destroy?.();
|
|
426
|
-
}
|
|
427
|
-
const instance = directive(element, arg);
|
|
428
|
-
instances[index] = { directive, instance, arg };
|
|
429
|
-
});
|
|
430
|
-
const extraInstances = instances.splice(directives2.length);
|
|
431
|
-
extraInstances.reverse().forEach(({ instance }) => instance?.destroy?.());
|
|
432
|
-
});
|
|
433
|
-
update(directives);
|
|
434
|
-
return {
|
|
435
|
-
update,
|
|
436
|
-
destroy: () => update([])
|
|
437
|
-
};
|
|
438
|
-
};
|
|
439
|
-
const createAttributesDirective = (propsFn) => (node, args) => {
|
|
440
|
-
const unsubscribers = [];
|
|
441
|
-
const args$ = tansu.writable(args);
|
|
442
|
-
const { events, attributes, styles, classNames } = propsFn(args$);
|
|
443
|
-
if (isBrowserHTMLElement(node)) {
|
|
444
|
-
for (const [type, event] of Object.entries(events ?? {})) {
|
|
445
|
-
if (typeof event === "function") {
|
|
446
|
-
unsubscribers.push(addEvent(node, type, event));
|
|
447
|
-
} else {
|
|
448
|
-
unsubscribers.push(addEvent(node, type, event.handler, event.options));
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
for (const [attributeName, value] of Object.entries(attributes ?? {})) {
|
|
453
|
-
if (value != null) {
|
|
454
|
-
unsubscribers.push(bindAttribute(node, attributeName, value));
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
for (const [styleName, value] of Object.entries(styles ?? {})) {
|
|
458
|
-
if (value) {
|
|
459
|
-
unsubscribers.push(bindStyle(node, styleName, value));
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
for (const [className, value] of Object.entries(classNames ?? {})) {
|
|
463
|
-
unsubscribers.push(bindClassName(node, className, value));
|
|
464
|
-
}
|
|
465
|
-
return {
|
|
466
|
-
update: (args2) => args$.set(args2),
|
|
467
|
-
destroy: () => unsubscribers.forEach((fn) => fn())
|
|
468
|
-
};
|
|
469
|
-
};
|
|
470
|
-
const attributesData = (...directives) => {
|
|
471
|
-
const instances = [];
|
|
472
|
-
try {
|
|
473
|
-
const element = ssrHTMLElement();
|
|
474
|
-
for (const directive of directives) {
|
|
475
|
-
instances.push(Array.isArray(directive) ? directive[0](element, directive[1]) : directive(element));
|
|
476
|
-
}
|
|
477
|
-
return element[ssrHTMLElementAttributesAndStyle]();
|
|
478
|
-
} finally {
|
|
479
|
-
instances.forEach((instance) => instance?.destroy?.());
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
const classDirective = createAttributesDirective((className$) => ({
|
|
483
|
-
attributes: { class: tansu.computed(() => clsx(className$())) }
|
|
484
|
-
}));
|
|
485
|
-
function directiveAttributes(...directives) {
|
|
486
|
-
const { attributes, classNames, style } = attributesData(...directives);
|
|
487
|
-
if (classNames.length) {
|
|
488
|
-
attributes["class"] = classNames.join(" ");
|
|
489
|
-
}
|
|
490
|
-
const stringStyle = cssTextFromObject(style);
|
|
491
|
-
if (stringStyle.length) {
|
|
492
|
-
attributes["style"] = stringStyle;
|
|
493
|
-
}
|
|
494
|
-
return attributes;
|
|
495
|
-
}
|
|
496
|
-
const ssrAttributes = esmEnv.BROWSER ? () => ({}) : directiveAttributes;
|
|
497
|
-
exports.addClasses = addClasses;
|
|
498
|
-
exports.addEvent = addEvent;
|
|
499
|
-
exports.attributesData = attributesData;
|
|
500
|
-
exports.bindDirective = bindDirective;
|
|
501
|
-
exports.bindDirectiveNoArg = bindDirectiveNoArg;
|
|
502
|
-
exports.browserDirective = browserDirective;
|
|
503
|
-
exports.classDirective = classDirective;
|
|
504
|
-
exports.computeCommonAncestor = computeCommonAncestor;
|
|
505
|
-
exports.conditionalDirective = conditionalDirective;
|
|
506
|
-
exports.createAttributesDirective = createAttributesDirective;
|
|
507
|
-
exports.createBrowserStoreArrayDirective = createBrowserStoreArrayDirective;
|
|
508
|
-
exports.createBrowserStoreDirective = createBrowserStoreDirective;
|
|
509
|
-
exports.createConditionalBrowserStoreArrayDirective = createConditionalBrowserStoreArrayDirective;
|
|
510
|
-
exports.createConditionalStoreArrayDirective = createConditionalStoreArrayDirective;
|
|
511
|
-
exports.createStoreArrayDirective = createStoreArrayDirective;
|
|
512
|
-
exports.createStoreDirective = createStoreDirective;
|
|
513
|
-
exports.directiveAttributes = directiveAttributes;
|
|
514
|
-
exports.directiveSubscribe = directiveSubscribe;
|
|
515
|
-
exports.directiveUpdate = directiveUpdate;
|
|
516
|
-
exports.isBrowserHTMLElement = isBrowserHTMLElement;
|
|
517
|
-
exports.mapDirectiveArg = mapDirectiveArg;
|
|
518
|
-
exports.mergeDirectives = mergeDirectives;
|
|
519
|
-
exports.multiDirective = multiDirective;
|
|
520
|
-
exports.reflow = reflow;
|
|
521
|
-
exports.registrationArray = registrationArray;
|
|
522
|
-
exports.removeClasses = removeClasses;
|
|
523
|
-
exports.ssrAttributes = ssrAttributes;
|