@agnos-ui/core-bootstrap 0.4.4 → 0.5.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/README.md +1 -1
- package/{alert-CKtd0QdX.cjs → alert-C-GktcuR.cjs} +4 -1
- package/{alert-BgtRL35m.js → alert-DXTwYKjx.js} +5 -2
- package/collapse-BBklAEOu.js +666 -0
- package/collapse-Ci0mVprH.cjs +665 -0
- package/components/accordion/accordion.d.ts +26 -4
- package/components/alert/alert.d.ts +16 -3
- package/components/alert/index.cjs +1 -1
- package/components/alert/index.js +1 -1
- package/components/collapse/collapse.d.ts +131 -0
- package/components/collapse/index.cjs +5 -0
- package/components/collapse/index.d.ts +1 -0
- package/components/collapse/index.js +5 -0
- package/components/modal/index.cjs +1 -1
- package/components/modal/index.js +1 -1
- package/components/modal/modal.d.ts +29 -3
- package/components/pagination/index.cjs +1 -1
- package/components/pagination/index.js +1 -1
- package/components/pagination/pagination.d.ts +26 -5
- package/components/progressbar/index.cjs +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/progressbar/progressbar.d.ts +20 -4
- package/components/rating/index.cjs +1 -1
- package/components/rating/index.js +1 -1
- package/components/rating/rating.d.ts +11 -2
- package/components/select/index.cjs +1 -1
- package/components/select/index.js +1 -1
- package/components/select/select.d.ts +29 -6
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.js +1 -1
- package/components/slider/slider.d.ts +35 -7
- package/components/toast/index.cjs +1 -1
- package/components/toast/index.js +1 -1
- package/components/toast/toast.d.ts +19 -2
- package/config.d.ts +8 -0
- package/css/agnosui.css +2 -0
- package/css/agnosui.css.map +1 -1
- package/css/select.css +2 -0
- package/css/select.css.map +1 -1
- package/index.cjs +16 -11
- package/index.d.ts +1 -0
- package/index.js +15 -10
- package/{modal-CvEa8ExQ.js → modal-CHqGXdvt.js} +7 -1
- package/{modal-B3BJCG4T.cjs → modal-DFEAGpCe.cjs} +7 -1
- package/package.json +8 -4
- package/{pageFactory-BMdGxeJT.js → pageFactory-CZZJDqOh.js} +15 -2
- package/{pageFactory-ClmOTwC3.cjs → pageFactory-vEBrUBB-.cjs} +15 -2
- package/{progressbar-B-Ne074g.js → progressbar-D9S5NLpS.js} +5 -2
- package/{progressbar-BSwy_XPW.cjs → progressbar-FwnctYWo.cjs} +4 -1
- package/{rating-Bf8cRtHn.cjs → rating-C5NZjIRx.cjs} +1 -1
- package/{rating-C1UqlpFs.js → rating-hovacUx0.js} +1 -1
- package/scss/select.scss +2 -0
- package/{select-9qmK2r6f.cjs → select-AtIM2x7x.cjs} +1 -2
- package/{select-DMeOSbKZ.js → select-CLjBDJ3a.js} +1 -2
- package/services/transitions/collapse.d.ts +13 -0
- package/services/transitions/fade.d.ts +6 -0
- package/{slider-BOtu3bQi.js → slider-CLWQS0Ke.js} +1 -1
- package/{slider-DA7_i-am.cjs → slider-UHwPs1vO.cjs} +1 -1
- package/{toast-CnSdkWfG.cjs → toast-BYDfN1cI.cjs} +10 -1
- package/{toast-aPzxFEq9.js → toast-D-by8Hwt.js} +10 -1
- package/types.cjs +12 -0
- package/types.d.ts +19 -0
- package/types.js +13 -1
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
6
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
7
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
8
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
11
|
+
set _(value) {
|
|
12
|
+
__privateSet(obj, member, value, setter);
|
|
13
|
+
},
|
|
14
|
+
get _() {
|
|
15
|
+
return __privateGet(obj, member, getter);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _subscribers, _cleanupFn, _subscribersPaused, _valueIndex, _value, _equalCache, _oldSubscriptions, _Store_instances, start_fn, stop_fn, notifySubscriber_fn, _computing, _skipCallCompute, _versionIndex, _subscriptions, _reactiveContext, _ComputedStore_instances, createSubscription_fn, getSubscriptionValue_fn, callCompute_fn, isPending_fn, hasChange_fn;
|
|
19
|
+
const baseTransitions = require("@agnos-ui/core/services/transitions/baseTransitions");
|
|
20
|
+
const stores = require("@agnos-ui/core/utils/stores");
|
|
21
|
+
const directive = require("@agnos-ui/core/utils/directive");
|
|
22
|
+
const writables = require("@agnos-ui/core/utils/writables");
|
|
23
|
+
const collapse = require("./collapse-sUYbZqEx.cjs");
|
|
24
|
+
var _a;
|
|
25
|
+
const symbolObservable = typeof Symbol === "function" && Symbol.observable || "@@observable";
|
|
26
|
+
const oldSubscription = Symbol();
|
|
27
|
+
const noop = () => {
|
|
28
|
+
};
|
|
29
|
+
const noopUnsubscribe = () => {
|
|
30
|
+
};
|
|
31
|
+
noopUnsubscribe.unsubscribe = noopUnsubscribe;
|
|
32
|
+
const bind = (object, fnName) => {
|
|
33
|
+
const fn = object ? object[fnName] : null;
|
|
34
|
+
return typeof fn === "function" ? fn.bind(object) : noop;
|
|
35
|
+
};
|
|
36
|
+
const toSubscriberObject = (subscriber) => ({
|
|
37
|
+
next: typeof subscriber === "function" ? subscriber.bind(null) : bind(subscriber, "next"),
|
|
38
|
+
pause: bind(subscriber, "pause"),
|
|
39
|
+
resume: bind(subscriber, "resume"),
|
|
40
|
+
_value: void 0,
|
|
41
|
+
_valueIndex: 0,
|
|
42
|
+
_paused: false
|
|
43
|
+
});
|
|
44
|
+
const returnThis = function() {
|
|
45
|
+
return this;
|
|
46
|
+
};
|
|
47
|
+
const normalizeUnsubscribe = (unsubscribe) => {
|
|
48
|
+
if (!unsubscribe) {
|
|
49
|
+
return noopUnsubscribe;
|
|
50
|
+
}
|
|
51
|
+
if (unsubscribe.unsubscribe === unsubscribe) {
|
|
52
|
+
return unsubscribe;
|
|
53
|
+
}
|
|
54
|
+
const res = typeof unsubscribe === "function" ? () => unsubscribe() : () => unsubscribe.unsubscribe();
|
|
55
|
+
res.unsubscribe = res;
|
|
56
|
+
return res;
|
|
57
|
+
};
|
|
58
|
+
const normalizedSubscribe = /* @__PURE__ */ new WeakSet();
|
|
59
|
+
const normalizeSubscribe = (store) => {
|
|
60
|
+
let res = store.subscribe;
|
|
61
|
+
if (!normalizedSubscribe.has(res)) {
|
|
62
|
+
res = (...args) => normalizeUnsubscribe(store.subscribe(...args));
|
|
63
|
+
normalizedSubscribe.add(res);
|
|
64
|
+
}
|
|
65
|
+
return res;
|
|
66
|
+
};
|
|
67
|
+
const getNormalizedSubscribe = (input) => {
|
|
68
|
+
const store = "subscribe" in input ? input : input[symbolObservable]();
|
|
69
|
+
return normalizeSubscribe(store);
|
|
70
|
+
};
|
|
71
|
+
const getValue = (subscribe) => {
|
|
72
|
+
let value;
|
|
73
|
+
subscribe((v) => value = v)();
|
|
74
|
+
return value;
|
|
75
|
+
};
|
|
76
|
+
function asReadable(store, extraProp) {
|
|
77
|
+
const subscribe = getNormalizedSubscribe(store);
|
|
78
|
+
const res = Object.assign(() => get(res), extraProp, {
|
|
79
|
+
subscribe,
|
|
80
|
+
[symbolObservable]: returnThis
|
|
81
|
+
});
|
|
82
|
+
return res;
|
|
83
|
+
}
|
|
84
|
+
function asWritable(store, setOrExtraProps) {
|
|
85
|
+
return asReadable(store, {
|
|
86
|
+
...setOrExtraProps,
|
|
87
|
+
set: noop,
|
|
88
|
+
update: noop
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const triggerUpdate = Symbol();
|
|
92
|
+
const queueProcess = Symbol();
|
|
93
|
+
let willProcessQueue = false;
|
|
94
|
+
const queue = /* @__PURE__ */ new Set();
|
|
95
|
+
const MAX_STORE_PROCESSING_IN_QUEUE = 1e3;
|
|
96
|
+
const checkIterations = (iterations) => {
|
|
97
|
+
if (iterations > MAX_STORE_PROCESSING_IN_QUEUE) {
|
|
98
|
+
throw new Error("reached maximum number of store changes in one shot");
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const batch = (fn) => {
|
|
102
|
+
const needsProcessQueue = !willProcessQueue;
|
|
103
|
+
if (needsProcessQueue) {
|
|
104
|
+
willProcessQueue = true;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
return fn();
|
|
108
|
+
} finally {
|
|
109
|
+
if (needsProcessQueue) {
|
|
110
|
+
try {
|
|
111
|
+
const storePasses = /* @__PURE__ */ new Map();
|
|
112
|
+
for (const store of queue) {
|
|
113
|
+
const storeCount = storePasses.get(store) ?? 0;
|
|
114
|
+
checkIterations(storeCount);
|
|
115
|
+
storePasses.set(store, storeCount + 1);
|
|
116
|
+
queue.delete(store);
|
|
117
|
+
store[queueProcess]();
|
|
118
|
+
}
|
|
119
|
+
} finally {
|
|
120
|
+
queue.clear();
|
|
121
|
+
willProcessQueue = false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const defaultReactiveContext = (store) => getValue(getNormalizedSubscribe(store));
|
|
127
|
+
let reactiveContext = defaultReactiveContext;
|
|
128
|
+
const get = (store) => reactiveContext(store);
|
|
129
|
+
const createEqualCache = (valueIndex) => ({
|
|
130
|
+
[valueIndex]: true,
|
|
131
|
+
// the subscriber already has the last value
|
|
132
|
+
[valueIndex - 1]: false,
|
|
133
|
+
// the subscriber had the previous value,
|
|
134
|
+
// which is known to be different because equal is called in the set method
|
|
135
|
+
0: false
|
|
136
|
+
// the subscriber never received any value
|
|
137
|
+
});
|
|
138
|
+
const skipEqualInSet = Symbol();
|
|
139
|
+
const equal = (a, b) => Object.is(a, b) && (!a || typeof a !== "object") && typeof a !== "function";
|
|
140
|
+
class Store {
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @param value - Initial value of the store
|
|
144
|
+
*/
|
|
145
|
+
constructor(value) {
|
|
146
|
+
__privateAdd(this, _Store_instances);
|
|
147
|
+
__privateAdd(this, _subscribers);
|
|
148
|
+
__privateAdd(this, _cleanupFn);
|
|
149
|
+
__privateAdd(this, _subscribersPaused);
|
|
150
|
+
__privateAdd(this, _valueIndex);
|
|
151
|
+
__privateAdd(this, _value);
|
|
152
|
+
__privateAdd(this, _equalCache);
|
|
153
|
+
__privateAdd(this, _oldSubscriptions);
|
|
154
|
+
__privateSet(this, _subscribers, /* @__PURE__ */ new Set());
|
|
155
|
+
__privateSet(this, _cleanupFn, null);
|
|
156
|
+
__privateSet(this, _subscribersPaused, false);
|
|
157
|
+
__privateSet(this, _valueIndex, 1);
|
|
158
|
+
__privateSet(this, _equalCache, createEqualCache(1));
|
|
159
|
+
__privateSet(this, _oldSubscriptions, /* @__PURE__ */ new WeakMap());
|
|
160
|
+
this[_a] = false;
|
|
161
|
+
__privateSet(this, _value, value);
|
|
162
|
+
}
|
|
163
|
+
[(_a = skipEqualInSet, queueProcess)]() {
|
|
164
|
+
const valueIndex = __privateGet(this, _valueIndex);
|
|
165
|
+
for (const subscriber of [...__privateGet(this, _subscribers)]) {
|
|
166
|
+
if (__privateGet(this, _subscribersPaused) || __privateGet(this, _valueIndex) !== valueIndex) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (subscriber._valueIndex === 0) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
__privateMethod(this, _Store_instances, notifySubscriber_fn).call(this, subscriber);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** @internal */
|
|
176
|
+
[triggerUpdate]() {
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Compares two values and returns true if they are equal.
|
|
180
|
+
* It is called when setting a new value to avoid doing anything
|
|
181
|
+
* (such as notifying subscribers) if the value did not change.
|
|
182
|
+
* The default logic is to return false if `a` is a function or an object,
|
|
183
|
+
* or if `a` and `b` are different according to `Object.is`.
|
|
184
|
+
* This method can be overridden by subclasses to change the logic.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* For backward compatibility, the default implementation calls the
|
|
188
|
+
* deprecated {@link Store.notEqual} method and returns the negation
|
|
189
|
+
* of its return value.
|
|
190
|
+
*
|
|
191
|
+
* @param a - First value to compare.
|
|
192
|
+
* @param b - Second value to compare.
|
|
193
|
+
* @returns true if a and b are considered equal.
|
|
194
|
+
*/
|
|
195
|
+
equal(a, b) {
|
|
196
|
+
return !this.notEqual(a, b);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Compares two values and returns true if they are different.
|
|
200
|
+
* It is called when setting a new value to avoid doing anything
|
|
201
|
+
* (such as notifying subscribers) if the value did not change.
|
|
202
|
+
* The default logic is to return true if `a` is a function or an object,
|
|
203
|
+
* or if `a` and `b` are different according to `Object.is`.
|
|
204
|
+
* This method can be overridden by subclasses to change the logic.
|
|
205
|
+
*
|
|
206
|
+
* @remarks
|
|
207
|
+
* This method is only called by the default implementation of
|
|
208
|
+
* {@link Store.equal}, so overriding {@link Store.equal} takes
|
|
209
|
+
* precedence over overriding notEqual.
|
|
210
|
+
*
|
|
211
|
+
* @deprecated Use {@link Store.equal} instead
|
|
212
|
+
* @param a - First value to compare.
|
|
213
|
+
* @param b - Second value to compare.
|
|
214
|
+
* @returns true if a and b are considered different.
|
|
215
|
+
*/
|
|
216
|
+
notEqual(a, b) {
|
|
217
|
+
return !equal(a, b);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Puts the store in the paused state, which means it will soon update its value.
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
*
|
|
224
|
+
* The paused state prevents derived or computed stores (both direct and transitive) from recomputing their value
|
|
225
|
+
* using the current value of this store.
|
|
226
|
+
*
|
|
227
|
+
* There are two ways to put a store back into its normal state: calling {@link Store.set | set} to set a new
|
|
228
|
+
* value or calling {@link Store.resumeSubscribers | resumeSubscribers} to declare that finally the value does not need to be
|
|
229
|
+
* changed.
|
|
230
|
+
*
|
|
231
|
+
* Note that a store should not stay in the paused state for a long time, and most of the time
|
|
232
|
+
* it is not needed to call pauseSubscribers or resumeSubscribers manually.
|
|
233
|
+
*
|
|
234
|
+
*/
|
|
235
|
+
pauseSubscribers() {
|
|
236
|
+
if (!__privateGet(this, _subscribersPaused)) {
|
|
237
|
+
__privateSet(this, _subscribersPaused, true);
|
|
238
|
+
queue.delete(this);
|
|
239
|
+
for (const subscriber of [...__privateGet(this, _subscribers)]) {
|
|
240
|
+
if (subscriber._valueIndex === 0 || subscriber._paused) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
subscriber._paused = true;
|
|
244
|
+
subscriber.pause();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Puts the store back to the normal state without changing its value, if it was in the paused state
|
|
250
|
+
* (cf {@link Store.pauseSubscribers | pauseSubscribers}).
|
|
251
|
+
*
|
|
252
|
+
* @remarks
|
|
253
|
+
*
|
|
254
|
+
* Does nothing if the store was not in the paused state.
|
|
255
|
+
*/
|
|
256
|
+
resumeSubscribers() {
|
|
257
|
+
if (__privateGet(this, _subscribersPaused)) {
|
|
258
|
+
__privateSet(this, _subscribersPaused, false);
|
|
259
|
+
batch(() => {
|
|
260
|
+
queue.add(this);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Replaces store's state with the provided value.
|
|
266
|
+
* Equivalent of {@link Writable.set}, but internal to the store.
|
|
267
|
+
*
|
|
268
|
+
* @param value - value to be used as the new state of a store.
|
|
269
|
+
*/
|
|
270
|
+
set(value) {
|
|
271
|
+
const skipEqual = this[skipEqualInSet];
|
|
272
|
+
if (skipEqual || !this.equal(__privateGet(this, _value), value)) {
|
|
273
|
+
const valueIndex = __privateGet(this, _valueIndex) + 1;
|
|
274
|
+
__privateSet(this, _valueIndex, valueIndex);
|
|
275
|
+
__privateSet(this, _value, value);
|
|
276
|
+
__privateSet(this, _equalCache, createEqualCache(valueIndex));
|
|
277
|
+
if (skipEqual) {
|
|
278
|
+
delete __privateGet(this, _equalCache)[valueIndex - 1];
|
|
279
|
+
}
|
|
280
|
+
this.pauseSubscribers();
|
|
281
|
+
}
|
|
282
|
+
this.resumeSubscribers();
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Updates store's state by using an {@link Updater} function.
|
|
286
|
+
* Equivalent of {@link Writable.update}, but internal to the store.
|
|
287
|
+
*
|
|
288
|
+
* @param updater - a function that takes the current state as an argument and returns the new state.
|
|
289
|
+
*/
|
|
290
|
+
update(updater) {
|
|
291
|
+
this.set(updater(__privateGet(this, _value)));
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Function called when the number of subscribers changes from 0 to 1
|
|
295
|
+
* (but not called when the number of subscribers changes from 1 to 2, ...).
|
|
296
|
+
* If a function is returned, it will be called when the number of subscribers changes from 1 to 0.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
*
|
|
300
|
+
* ```typescript
|
|
301
|
+
* class CustomStore extends Store {
|
|
302
|
+
* onUse() {
|
|
303
|
+
* console.log('Got the fist subscriber!');
|
|
304
|
+
* return () => {
|
|
305
|
+
* console.log('All subscribers are gone...');
|
|
306
|
+
* };
|
|
307
|
+
* }
|
|
308
|
+
* }
|
|
309
|
+
*
|
|
310
|
+
* const store = new CustomStore();
|
|
311
|
+
* const unsubscribe1 = store.subscribe(() => {}); // logs 'Got the fist subscriber!'
|
|
312
|
+
* const unsubscribe2 = store.subscribe(() => {}); // nothing is logged as we've got one subscriber already
|
|
313
|
+
* unsubscribe1(); // nothing is logged as we still have one subscriber
|
|
314
|
+
* unsubscribe2(); // logs 'All subscribers are gone...'
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
onUse() {
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Default Implementation of the {@link SubscribableStore.subscribe}, not meant to be overridden.
|
|
321
|
+
* @param subscriber - see {@link SubscribableStore.subscribe}
|
|
322
|
+
*/
|
|
323
|
+
subscribe(subscriber) {
|
|
324
|
+
const subscriberObject = toSubscriberObject(subscriber);
|
|
325
|
+
const oldSubscriptionParam = subscriber == null ? void 0 : subscriber[oldSubscription];
|
|
326
|
+
if (oldSubscriptionParam) {
|
|
327
|
+
const oldSubscriberObject = __privateGet(this, _oldSubscriptions).get(oldSubscriptionParam);
|
|
328
|
+
if (oldSubscriberObject) {
|
|
329
|
+
subscriberObject._value = oldSubscriberObject._value;
|
|
330
|
+
subscriberObject._valueIndex = oldSubscriberObject._valueIndex;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
__privateGet(this, _subscribers).add(subscriberObject);
|
|
334
|
+
batch(() => {
|
|
335
|
+
if (__privateGet(this, _subscribers).size == 1) {
|
|
336
|
+
__privateMethod(this, _Store_instances, start_fn).call(this);
|
|
337
|
+
} else {
|
|
338
|
+
this[triggerUpdate]();
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
__privateMethod(this, _Store_instances, notifySubscriber_fn).call(this, subscriberObject);
|
|
342
|
+
const unsubscribe = () => {
|
|
343
|
+
const removed = __privateGet(this, _subscribers).delete(subscriberObject);
|
|
344
|
+
subscriberObject.next = noop;
|
|
345
|
+
subscriberObject.pause = noop;
|
|
346
|
+
subscriberObject.resume = noop;
|
|
347
|
+
if (removed) {
|
|
348
|
+
__privateGet(this, _oldSubscriptions).set(unsubscribe, subscriberObject);
|
|
349
|
+
if (__privateGet(this, _subscribers).size === 0) {
|
|
350
|
+
__privateMethod(this, _Store_instances, stop_fn).call(this);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
unsubscribe[triggerUpdate] = () => {
|
|
355
|
+
this[triggerUpdate]();
|
|
356
|
+
__privateMethod(this, _Store_instances, notifySubscriber_fn).call(this, subscriberObject);
|
|
357
|
+
};
|
|
358
|
+
unsubscribe.unsubscribe = unsubscribe;
|
|
359
|
+
return unsubscribe;
|
|
360
|
+
}
|
|
361
|
+
[symbolObservable]() {
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
_subscribers = new WeakMap();
|
|
366
|
+
_cleanupFn = new WeakMap();
|
|
367
|
+
_subscribersPaused = new WeakMap();
|
|
368
|
+
_valueIndex = new WeakMap();
|
|
369
|
+
_value = new WeakMap();
|
|
370
|
+
_equalCache = new WeakMap();
|
|
371
|
+
_oldSubscriptions = new WeakMap();
|
|
372
|
+
_Store_instances = new WeakSet();
|
|
373
|
+
start_fn = function() {
|
|
374
|
+
__privateSet(this, _cleanupFn, normalizeUnsubscribe(this.onUse()));
|
|
375
|
+
};
|
|
376
|
+
stop_fn = function() {
|
|
377
|
+
const cleanupFn = __privateGet(this, _cleanupFn);
|
|
378
|
+
if (cleanupFn) {
|
|
379
|
+
__privateSet(this, _cleanupFn, null);
|
|
380
|
+
cleanupFn();
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
notifySubscriber_fn = function(subscriber) {
|
|
384
|
+
const equalCache = __privateGet(this, _equalCache);
|
|
385
|
+
const valueIndex = __privateGet(this, _valueIndex);
|
|
386
|
+
const value = __privateGet(this, _value);
|
|
387
|
+
let equal2 = equalCache[subscriber._valueIndex];
|
|
388
|
+
if (equal2 == null) {
|
|
389
|
+
equal2 = !!this.equal(subscriber._value, value);
|
|
390
|
+
equalCache[subscriber._valueIndex] = equal2;
|
|
391
|
+
}
|
|
392
|
+
subscriber._valueIndex = valueIndex;
|
|
393
|
+
if (!equal2) {
|
|
394
|
+
subscriber._value = value;
|
|
395
|
+
subscriber._paused = false;
|
|
396
|
+
subscriber.next(value);
|
|
397
|
+
} else if (!__privateGet(this, _subscribersPaused) && subscriber._paused) {
|
|
398
|
+
subscriber._paused = false;
|
|
399
|
+
subscriber.resume();
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const applyStoreOptions = (store, options) => {
|
|
403
|
+
const { onUse, equal: equal2, notEqual } = options;
|
|
404
|
+
if (onUse) {
|
|
405
|
+
store.onUse = function() {
|
|
406
|
+
const setFn = (v) => this.set(v);
|
|
407
|
+
setFn.set = setFn;
|
|
408
|
+
setFn.update = (updater) => this.update(updater);
|
|
409
|
+
return onUse(setFn);
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
if (equal2) {
|
|
413
|
+
store.equal = function(a, b) {
|
|
414
|
+
return equal2(a, b);
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
if (notEqual) {
|
|
418
|
+
store.notEqual = function(a, b) {
|
|
419
|
+
return notEqual(a, b);
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return store;
|
|
423
|
+
};
|
|
424
|
+
const untrack = (fn) => {
|
|
425
|
+
const previousReactiveContext = reactiveContext;
|
|
426
|
+
try {
|
|
427
|
+
reactiveContext = defaultReactiveContext;
|
|
428
|
+
return fn();
|
|
429
|
+
} finally {
|
|
430
|
+
reactiveContext = previousReactiveContext;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
const callUnsubscribe = ({ unsubscribe }) => unsubscribe();
|
|
434
|
+
const callResubscribe = ({ resubscribe }) => resubscribe();
|
|
435
|
+
class ComputedStore extends Store {
|
|
436
|
+
constructor() {
|
|
437
|
+
super(void 0);
|
|
438
|
+
__privateAdd(this, _ComputedStore_instances);
|
|
439
|
+
__privateAdd(this, _computing, false);
|
|
440
|
+
__privateAdd(this, _skipCallCompute, false);
|
|
441
|
+
__privateAdd(this, _versionIndex, 0);
|
|
442
|
+
__privateAdd(this, _subscriptions, /* @__PURE__ */ new Map());
|
|
443
|
+
__privateAdd(this, _reactiveContext, (storeInput) => untrack(() => __privateMethod(this, _ComputedStore_instances, getSubscriptionValue_fn).call(this, storeInput)));
|
|
444
|
+
this[skipEqualInSet] = true;
|
|
445
|
+
}
|
|
446
|
+
resumeSubscribers() {
|
|
447
|
+
if (!__privateMethod(this, _ComputedStore_instances, isPending_fn).call(this)) {
|
|
448
|
+
super.resumeSubscribers();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/** @internal */
|
|
452
|
+
[triggerUpdate]() {
|
|
453
|
+
var _a2;
|
|
454
|
+
if (__privateGet(this, _computing)) {
|
|
455
|
+
throw new Error("recursive computed");
|
|
456
|
+
}
|
|
457
|
+
let iterations = 0;
|
|
458
|
+
while (__privateMethod(this, _ComputedStore_instances, isPending_fn).call(this)) {
|
|
459
|
+
checkIterations(++iterations);
|
|
460
|
+
__privateSet(this, _skipCallCompute, true);
|
|
461
|
+
try {
|
|
462
|
+
for (const [, { pending, unsubscribe }] of __privateGet(this, _subscriptions)) {
|
|
463
|
+
if (pending) {
|
|
464
|
+
(_a2 = unsubscribe[triggerUpdate]) == null ? void 0 : _a2.call(unsubscribe);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
} finally {
|
|
468
|
+
__privateSet(this, _skipCallCompute, false);
|
|
469
|
+
}
|
|
470
|
+
if (__privateMethod(this, _ComputedStore_instances, isPending_fn).call(this)) {
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
__privateMethod(this, _ComputedStore_instances, callCompute_fn).call(this);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
onUse() {
|
|
477
|
+
__privateMethod(this, _ComputedStore_instances, callCompute_fn).call(this, true);
|
|
478
|
+
this[triggerUpdate]();
|
|
479
|
+
return () => __privateGet(this, _subscriptions).forEach(callUnsubscribe);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
_computing = new WeakMap();
|
|
483
|
+
_skipCallCompute = new WeakMap();
|
|
484
|
+
_versionIndex = new WeakMap();
|
|
485
|
+
_subscriptions = new WeakMap();
|
|
486
|
+
_reactiveContext = new WeakMap();
|
|
487
|
+
_ComputedStore_instances = new WeakSet();
|
|
488
|
+
createSubscription_fn = function(subscribe) {
|
|
489
|
+
const res = {
|
|
490
|
+
versionIndex: __privateGet(this, _versionIndex),
|
|
491
|
+
unsubscribe: noop,
|
|
492
|
+
resubscribe: noop,
|
|
493
|
+
pending: false,
|
|
494
|
+
usedValueIndex: 0,
|
|
495
|
+
value: void 0,
|
|
496
|
+
valueIndex: 0
|
|
497
|
+
};
|
|
498
|
+
const subscriber = (value) => {
|
|
499
|
+
res.value = value;
|
|
500
|
+
res.valueIndex++;
|
|
501
|
+
res.pending = false;
|
|
502
|
+
if (!__privateGet(this, _skipCallCompute) && !__privateMethod(this, _ComputedStore_instances, isPending_fn).call(this)) {
|
|
503
|
+
batch(() => __privateMethod(this, _ComputedStore_instances, callCompute_fn).call(this));
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
subscriber.next = subscriber;
|
|
507
|
+
subscriber.pause = () => {
|
|
508
|
+
res.pending = true;
|
|
509
|
+
this.pauseSubscribers();
|
|
510
|
+
};
|
|
511
|
+
subscriber.resume = () => {
|
|
512
|
+
res.pending = false;
|
|
513
|
+
if (!__privateGet(this, _skipCallCompute) && !__privateMethod(this, _ComputedStore_instances, isPending_fn).call(this)) {
|
|
514
|
+
batch(() => __privateMethod(this, _ComputedStore_instances, callCompute_fn).call(this));
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
res.resubscribe = () => {
|
|
518
|
+
res.unsubscribe = subscribe(subscriber);
|
|
519
|
+
subscriber[oldSubscription] = res.unsubscribe;
|
|
520
|
+
};
|
|
521
|
+
res.resubscribe();
|
|
522
|
+
return res;
|
|
523
|
+
};
|
|
524
|
+
getSubscriptionValue_fn = function(storeInput) {
|
|
525
|
+
var _a2, _b;
|
|
526
|
+
let res = __privateGet(this, _subscriptions).get(storeInput);
|
|
527
|
+
if (res) {
|
|
528
|
+
res.versionIndex = __privateGet(this, _versionIndex);
|
|
529
|
+
(_b = (_a2 = res.unsubscribe)[triggerUpdate]) == null ? void 0 : _b.call(_a2);
|
|
530
|
+
} else {
|
|
531
|
+
res = __privateMethod(this, _ComputedStore_instances, createSubscription_fn).call(this, getNormalizedSubscribe(storeInput));
|
|
532
|
+
__privateGet(this, _subscriptions).set(storeInput, res);
|
|
533
|
+
}
|
|
534
|
+
res.usedValueIndex = res.valueIndex;
|
|
535
|
+
return res.value;
|
|
536
|
+
};
|
|
537
|
+
callCompute_fn = function(resubscribe = false) {
|
|
538
|
+
__privateSet(this, _computing, true);
|
|
539
|
+
__privateSet(this, _skipCallCompute, true);
|
|
540
|
+
try {
|
|
541
|
+
if (__privateGet(this, _versionIndex) > 0) {
|
|
542
|
+
if (resubscribe) {
|
|
543
|
+
__privateGet(this, _subscriptions).forEach(callResubscribe);
|
|
544
|
+
}
|
|
545
|
+
if (!__privateMethod(this, _ComputedStore_instances, hasChange_fn).call(this)) {
|
|
546
|
+
this.resumeSubscribers();
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
__privateWrapper(this, _versionIndex)._++;
|
|
551
|
+
const versionIndex = __privateGet(this, _versionIndex);
|
|
552
|
+
const previousReactiveContext = reactiveContext;
|
|
553
|
+
let value;
|
|
554
|
+
try {
|
|
555
|
+
reactiveContext = __privateGet(this, _reactiveContext);
|
|
556
|
+
value = this.compute();
|
|
557
|
+
} finally {
|
|
558
|
+
reactiveContext = previousReactiveContext;
|
|
559
|
+
}
|
|
560
|
+
this.set(value);
|
|
561
|
+
this[skipEqualInSet] = false;
|
|
562
|
+
for (const [store, info] of __privateGet(this, _subscriptions)) {
|
|
563
|
+
if (info.versionIndex !== versionIndex) {
|
|
564
|
+
__privateGet(this, _subscriptions).delete(store);
|
|
565
|
+
info.unsubscribe();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
} finally {
|
|
569
|
+
__privateSet(this, _skipCallCompute, false);
|
|
570
|
+
__privateSet(this, _computing, false);
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
isPending_fn = function() {
|
|
574
|
+
for (const [, { pending }] of __privateGet(this, _subscriptions)) {
|
|
575
|
+
if (pending) {
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return false;
|
|
580
|
+
};
|
|
581
|
+
hasChange_fn = function() {
|
|
582
|
+
for (const [, { valueIndex, usedValueIndex }] of __privateGet(this, _subscriptions)) {
|
|
583
|
+
if (valueIndex != usedValueIndex) {
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return false;
|
|
588
|
+
};
|
|
589
|
+
function computed(fn, options = {}) {
|
|
590
|
+
const Computed = class extends ComputedStore {
|
|
591
|
+
compute() {
|
|
592
|
+
return fn();
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
return asReadable(applyStoreOptions(new Computed(), {
|
|
596
|
+
...options,
|
|
597
|
+
onUse: void 0
|
|
598
|
+
}));
|
|
599
|
+
}
|
|
600
|
+
const defaultCollapseConfig = {
|
|
601
|
+
visible: true,
|
|
602
|
+
horizontal: false,
|
|
603
|
+
onVisibleChange: () => {
|
|
604
|
+
},
|
|
605
|
+
onShown: () => {
|
|
606
|
+
},
|
|
607
|
+
onHidden: () => {
|
|
608
|
+
},
|
|
609
|
+
animated: true,
|
|
610
|
+
animatedOnInit: false,
|
|
611
|
+
className: "",
|
|
612
|
+
id: ""
|
|
613
|
+
};
|
|
614
|
+
function getCollapseDefaultConfig() {
|
|
615
|
+
return { ...defaultCollapseConfig };
|
|
616
|
+
}
|
|
617
|
+
const commonCollapseConfigValidator = {
|
|
618
|
+
horizontal: writables.typeBoolean,
|
|
619
|
+
onVisibleChange: writables.typeFunction,
|
|
620
|
+
onHidden: writables.typeFunction,
|
|
621
|
+
onShown: writables.typeFunction,
|
|
622
|
+
animatedOnInit: writables.typeBoolean,
|
|
623
|
+
animated: writables.typeBoolean,
|
|
624
|
+
className: writables.typeString,
|
|
625
|
+
visible: writables.typeBoolean,
|
|
626
|
+
id: writables.typeString
|
|
627
|
+
};
|
|
628
|
+
function createCollapse(config) {
|
|
629
|
+
const [{ animatedOnInit$, animated$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, horizontal$, id$, ...stateProps }, patch] = stores.writablesForProps(defaultCollapseConfig, config, commonCollapseConfigValidator);
|
|
630
|
+
const currentTransitionFn$ = asWritable(computed(() => horizontal$() ? collapse.collapseHorizontalTransition : collapse.collapseVerticalTransition));
|
|
631
|
+
const transition = baseTransitions.createTransition({
|
|
632
|
+
props: {
|
|
633
|
+
transition: currentTransitionFn$,
|
|
634
|
+
visible: requestedVisible$,
|
|
635
|
+
animated: animated$,
|
|
636
|
+
animatedOnInit: animatedOnInit$,
|
|
637
|
+
onVisibleChange: onVisibleChange$,
|
|
638
|
+
onHidden: onHidden$,
|
|
639
|
+
onShown: onShown$
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
const visible$ = transition.stores.visible$;
|
|
643
|
+
const hidden$ = transition.stores.hidden$;
|
|
644
|
+
return {
|
|
645
|
+
...stores.stateStores({ ...stateProps, visible$, hidden$, horizontal$ }),
|
|
646
|
+
patch,
|
|
647
|
+
api: {
|
|
648
|
+
open: transition.api.show,
|
|
649
|
+
close: transition.api.hide,
|
|
650
|
+
toggle: transition.api.toggle
|
|
651
|
+
},
|
|
652
|
+
directives: {
|
|
653
|
+
collapseDirective: directive.mergeDirectives(
|
|
654
|
+
transition.directives.directive,
|
|
655
|
+
directive.createAttributesDirective(() => ({
|
|
656
|
+
attributes: {
|
|
657
|
+
id: computed(() => id$() || void 0)
|
|
658
|
+
}
|
|
659
|
+
}))
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
exports.createCollapse = createCollapse;
|
|
665
|
+
exports.getCollapseDefaultConfig = getCollapseDefaultConfig;
|