@sprawlify/primitives 0.1.6 → 0.1.8
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/dist/core-Bw_czdwX.cjs +383 -0
- package/dist/core-CTtbW9qh.mjs +288 -0
- package/dist/core.cjs +9 -1
- package/dist/core.d.cts +25 -2
- package/dist/core.d.mts +25 -2
- package/dist/core.mjs +2 -2
- package/dist/machines/accordion/index.cjs +1 -1
- package/dist/machines/accordion/index.d.cts +2 -2
- package/dist/machines/accordion/index.d.mts +2 -2
- package/dist/machines/accordion/index.mjs +1 -1
- package/dist/machines/angle-slider/index.cjs +1 -1
- package/dist/machines/angle-slider/index.d.cts +2 -2
- package/dist/machines/angle-slider/index.d.mts +2 -2
- package/dist/machines/angle-slider/index.mjs +1 -1
- package/dist/machines/aspect-ratio/index.cjs +1 -1
- package/dist/machines/aspect-ratio/index.d.cts +1 -1
- package/dist/machines/aspect-ratio/index.d.mts +1 -1
- package/dist/machines/aspect-ratio/index.mjs +1 -1
- package/dist/machines/async-list/index.cjs +1 -1
- package/dist/machines/async-list/index.d.cts +1 -1
- package/dist/machines/async-list/index.d.mts +1 -1
- package/dist/machines/async-list/index.mjs +1 -1
- package/dist/machines/avatar/index.cjs +1 -1
- package/dist/machines/avatar/index.d.cts +1 -1
- package/dist/machines/avatar/index.d.mts +1 -1
- package/dist/machines/avatar/index.mjs +1 -1
- package/dist/machines/carousel/index.cjs +69 -18
- package/dist/machines/carousel/index.d.cts +3 -3
- package/dist/machines/carousel/index.d.mts +3 -3
- package/dist/machines/carousel/index.mjs +69 -18
- package/dist/machines/cascade-select/index.cjs +1 -1
- package/dist/machines/cascade-select/index.d.cts +3 -3
- package/dist/machines/cascade-select/index.d.mts +3 -3
- package/dist/machines/cascade-select/index.mjs +1 -1
- package/dist/machines/checkbox/index.cjs +1 -1
- package/dist/machines/checkbox/index.d.cts +2 -2
- package/dist/machines/checkbox/index.d.mts +2 -2
- package/dist/machines/checkbox/index.mjs +1 -1
- package/dist/machines/clipboard/index.cjs +1 -1
- package/dist/machines/clipboard/index.d.cts +2 -2
- package/dist/machines/clipboard/index.d.mts +2 -2
- package/dist/machines/clipboard/index.mjs +1 -1
- package/dist/machines/collapsible/index.cjs +1 -1
- package/dist/machines/collapsible/index.d.cts +1 -1
- package/dist/machines/collapsible/index.d.mts +1 -1
- package/dist/machines/collapsible/index.mjs +1 -1
- package/dist/machines/color-picker/index.cjs +76 -102
- package/dist/machines/color-picker/index.d.cts +3 -3
- package/dist/machines/color-picker/index.d.mts +3 -3
- package/dist/machines/color-picker/index.mjs +76 -102
- package/dist/machines/combobox/index.cjs +1 -1
- package/dist/machines/combobox/index.d.cts +2 -2
- package/dist/machines/combobox/index.d.mts +2 -2
- package/dist/machines/combobox/index.mjs +1 -1
- package/dist/machines/date-picker/index.cjs +1 -1
- package/dist/machines/date-picker/index.d.cts +2 -2
- package/dist/machines/date-picker/index.d.mts +2 -2
- package/dist/machines/date-picker/index.mjs +1 -1
- package/dist/machines/dialog/index.cjs +1 -1
- package/dist/machines/dialog/index.d.cts +2 -2
- package/dist/machines/dialog/index.d.mts +2 -2
- package/dist/machines/dialog/index.mjs +1 -1
- package/dist/machines/drawer/index.cjs +1 -1
- package/dist/machines/drawer/index.d.cts +2 -2
- package/dist/machines/drawer/index.d.mts +2 -2
- package/dist/machines/drawer/index.mjs +1 -1
- package/dist/machines/dropdown-menu/index.cjs +1 -1
- package/dist/machines/dropdown-menu/index.d.cts +2 -2
- package/dist/machines/dropdown-menu/index.d.mts +2 -2
- package/dist/machines/dropdown-menu/index.mjs +1 -1
- package/dist/machines/editable/index.cjs +1 -1
- package/dist/machines/editable/index.d.cts +2 -2
- package/dist/machines/editable/index.d.mts +2 -2
- package/dist/machines/editable/index.mjs +1 -1
- package/dist/machines/file-upload/index.cjs +1 -1
- package/dist/machines/file-upload/index.d.cts +2 -2
- package/dist/machines/file-upload/index.d.mts +2 -2
- package/dist/machines/file-upload/index.mjs +1 -1
- package/dist/machines/floating-panel/index.cjs +96 -93
- package/dist/machines/floating-panel/index.d.cts +3 -3
- package/dist/machines/floating-panel/index.d.mts +3 -3
- package/dist/machines/floating-panel/index.mjs +96 -93
- package/dist/machines/hover-card/index.cjs +1 -1
- package/dist/machines/hover-card/index.d.cts +2 -2
- package/dist/machines/hover-card/index.d.mts +2 -2
- package/dist/machines/hover-card/index.mjs +1 -1
- package/dist/machines/image-cropper/index.cjs +1 -1
- package/dist/machines/image-cropper/index.d.cts +1 -1
- package/dist/machines/image-cropper/index.d.mts +1 -1
- package/dist/machines/image-cropper/index.mjs +1 -1
- package/dist/machines/listbox/index.cjs +1 -1
- package/dist/machines/listbox/index.d.cts +2 -2
- package/dist/machines/listbox/index.d.mts +2 -2
- package/dist/machines/listbox/index.mjs +1 -1
- package/dist/machines/marquee/index.cjs +1 -1
- package/dist/machines/marquee/index.d.cts +3 -3
- package/dist/machines/marquee/index.d.mts +3 -3
- package/dist/machines/marquee/index.mjs +1 -1
- package/dist/machines/navigation-menu/index.cjs +1 -1
- package/dist/machines/navigation-menu/index.d.cts +2 -2
- package/dist/machines/navigation-menu/index.d.mts +2 -2
- package/dist/machines/navigation-menu/index.mjs +1 -1
- package/dist/machines/number-input/index.cjs +1 -1
- package/dist/machines/number-input/index.d.cts +2 -2
- package/dist/machines/number-input/index.d.mts +2 -2
- package/dist/machines/number-input/index.mjs +1 -1
- package/dist/machines/pagination/index.cjs +1 -1
- package/dist/machines/pagination/index.d.cts +1 -1
- package/dist/machines/pagination/index.d.mts +1 -1
- package/dist/machines/pagination/index.mjs +1 -1
- package/dist/machines/password-input/index.cjs +1 -1
- package/dist/machines/password-input/index.d.cts +2 -2
- package/dist/machines/password-input/index.d.mts +2 -2
- package/dist/machines/password-input/index.mjs +1 -1
- package/dist/machines/pin-input/index.cjs +1 -1
- package/dist/machines/pin-input/index.d.cts +2 -2
- package/dist/machines/pin-input/index.d.mts +2 -2
- package/dist/machines/pin-input/index.mjs +1 -1
- package/dist/machines/popover/index.cjs +1 -1
- package/dist/machines/popover/index.d.cts +2 -2
- package/dist/machines/popover/index.d.mts +2 -2
- package/dist/machines/popover/index.mjs +1 -1
- package/dist/machines/presence/index.cjs +1 -1
- package/dist/machines/presence/index.d.cts +1 -1
- package/dist/machines/presence/index.d.mts +1 -1
- package/dist/machines/presence/index.mjs +1 -1
- package/dist/machines/progress/index.cjs +1 -1
- package/dist/machines/progress/index.d.cts +2 -2
- package/dist/machines/progress/index.d.mts +2 -2
- package/dist/machines/progress/index.mjs +1 -1
- package/dist/machines/qr-code/index.cjs +1 -1
- package/dist/machines/qr-code/index.d.cts +1 -1
- package/dist/machines/qr-code/index.d.mts +1 -1
- package/dist/machines/qr-code/index.mjs +1 -1
- package/dist/machines/radio-group/index.cjs +1 -1
- package/dist/machines/radio-group/index.d.cts +1 -1
- package/dist/machines/radio-group/index.d.mts +1 -1
- package/dist/machines/radio-group/index.mjs +1 -1
- package/dist/machines/rating-group/index.cjs +1 -1
- package/dist/machines/rating-group/index.d.cts +2 -2
- package/dist/machines/rating-group/index.d.mts +2 -2
- package/dist/machines/rating-group/index.mjs +1 -1
- package/dist/machines/scroll-area/index.cjs +1 -1
- package/dist/machines/scroll-area/index.d.cts +1 -1
- package/dist/machines/scroll-area/index.d.mts +1 -1
- package/dist/machines/scroll-area/index.mjs +1 -1
- package/dist/machines/select/index.cjs +1 -1
- package/dist/machines/select/index.d.cts +2 -2
- package/dist/machines/select/index.d.mts +2 -2
- package/dist/machines/select/index.mjs +1 -1
- package/dist/machines/separator/index.cjs +1 -1
- package/dist/machines/separator/index.d.cts +1 -1
- package/dist/machines/separator/index.d.mts +1 -1
- package/dist/machines/separator/index.mjs +1 -1
- package/dist/machines/signature-pad/index.cjs +1 -1
- package/dist/machines/signature-pad/index.d.cts +2 -2
- package/dist/machines/signature-pad/index.d.mts +2 -2
- package/dist/machines/signature-pad/index.mjs +1 -1
- package/dist/machines/slider/index.cjs +1 -1
- package/dist/machines/slider/index.d.cts +2 -2
- package/dist/machines/slider/index.d.mts +2 -2
- package/dist/machines/slider/index.mjs +1 -1
- package/dist/machines/splitter/index.cjs +1 -1
- package/dist/machines/splitter/index.d.cts +1 -1
- package/dist/machines/splitter/index.d.mts +1 -1
- package/dist/machines/splitter/index.mjs +1 -1
- package/dist/machines/steps/index.cjs +1 -1
- package/dist/machines/steps/index.d.cts +2 -2
- package/dist/machines/steps/index.d.mts +2 -2
- package/dist/machines/steps/index.mjs +1 -1
- package/dist/machines/switch/index.cjs +1 -1
- package/dist/machines/switch/index.d.cts +2 -2
- package/dist/machines/switch/index.d.mts +2 -2
- package/dist/machines/switch/index.mjs +1 -1
- package/dist/machines/tabs/index.cjs +1 -1
- package/dist/machines/tabs/index.d.cts +2 -2
- package/dist/machines/tabs/index.d.mts +2 -2
- package/dist/machines/tabs/index.mjs +1 -1
- package/dist/machines/tags-input/index.cjs +1 -1
- package/dist/machines/tags-input/index.d.cts +2 -2
- package/dist/machines/tags-input/index.d.mts +2 -2
- package/dist/machines/tags-input/index.mjs +1 -1
- package/dist/machines/timer/index.cjs +1 -1
- package/dist/machines/timer/index.d.cts +2 -2
- package/dist/machines/timer/index.d.mts +2 -2
- package/dist/machines/timer/index.mjs +1 -1
- package/dist/machines/toast/index.cjs +1 -1
- package/dist/machines/toast/index.d.cts +2 -2
- package/dist/machines/toast/index.d.mts +2 -2
- package/dist/machines/toast/index.mjs +1 -1
- package/dist/machines/toggle/index.cjs +1 -1
- package/dist/machines/toggle/index.d.cts +1 -1
- package/dist/machines/toggle/index.d.mts +1 -1
- package/dist/machines/toggle/index.mjs +1 -1
- package/dist/machines/toggle-group/index.cjs +1 -1
- package/dist/machines/toggle-group/index.d.cts +1 -1
- package/dist/machines/toggle-group/index.d.mts +1 -1
- package/dist/machines/toggle-group/index.mjs +1 -1
- package/dist/machines/tooltip/index.cjs +1 -1
- package/dist/machines/tooltip/index.d.cts +2 -2
- package/dist/machines/tooltip/index.d.mts +2 -2
- package/dist/machines/tooltip/index.mjs +1 -1
- package/dist/machines/tour/index.cjs +48 -46
- package/dist/machines/tour/index.d.cts +3 -3
- package/dist/machines/tour/index.d.mts +3 -3
- package/dist/machines/tour/index.mjs +48 -46
- package/dist/machines/tree-view/index.cjs +1 -1
- package/dist/machines/tree-view/index.d.cts +2 -2
- package/dist/machines/tree-view/index.d.mts +2 -2
- package/dist/machines/tree-view/index.mjs +1 -1
- package/dist/{types-B24gMTKq.d.cts → types-DvUmCWsb.d.mts} +28 -12
- package/dist/{types-DUM9rzfD.d.mts → types-u-LWCSDE.d.cts} +28 -12
- package/package.json +1 -1
- package/dist/core-Ci9Yu6QI.mjs +0 -123
- package/dist/core-DwdPztGA.cjs +0 -170
|
@@ -105,14 +105,26 @@ interface Params<T extends Dict> {
|
|
|
105
105
|
guard: (key: T["guard"] | GuardFn<T>) => boolean | undefined;
|
|
106
106
|
}
|
|
107
107
|
type GuardFn<T extends Dict> = (params: Params<T>) => boolean;
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
type TopLevelState<S extends string> = S extends `${infer Top}.${string}` ? Top : S;
|
|
109
|
+
type ChildStateKey<S extends string, Parent extends string> = S extends `${Parent}.${infer Rest}` ? Rest extends `${infer Child}.${string}` ? Child : Rest : never;
|
|
110
|
+
type ParentPath<S extends string> = S extends `${infer Parent}.${string}` ? Parent : never;
|
|
111
|
+
type AncestorPaths<S extends string> = S | (ParentPath<S> extends never ? never : AncestorPaths<ParentPath<S>>);
|
|
112
|
+
type RelativeStateTarget<S extends string, Source extends string> = ChildStateKey<S, AncestorPaths<Source>>;
|
|
113
|
+
type StateIdTarget = `#${string}`;
|
|
114
|
+
interface Transition<T extends Dict, Source extends string | undefined = string | undefined> {
|
|
115
|
+
target?: T["state"] | StateIdTarget | (Source extends string ? RelativeStateTarget<T["state"], Source> : never) | undefined;
|
|
110
116
|
actions?: T["action"][] | undefined;
|
|
111
117
|
guard?: T["guard"] | GuardFn<T> | undefined;
|
|
112
118
|
reenter?: boolean | undefined;
|
|
113
119
|
}
|
|
120
|
+
type TransitionSet<T extends Dict> = Transition<T> | Transition<T>[] | undefined;
|
|
121
|
+
type TransitionMap<T extends Dict> = Record<string, TransitionSet<T>>;
|
|
122
|
+
type TransitionMatch<T extends Dict> = {
|
|
123
|
+
transitions: TransitionSet<T>;
|
|
124
|
+
source: string | undefined;
|
|
125
|
+
};
|
|
114
126
|
type MaybeArray<T> = T | T[];
|
|
115
|
-
type ChooseFn<T extends Dict> = (transitions: MaybeArray<Omit<Transition<T>, "target">>) => Transition<T> | undefined;
|
|
127
|
+
type ChooseFn<T extends Dict> = (transitions: MaybeArray<Omit<Transition<T, string>, "target">> | null | undefined) => Transition<T> | undefined;
|
|
116
128
|
interface PropsParams<T extends Dict> {
|
|
117
129
|
props: Partial<T["props"]>;
|
|
118
130
|
scope: Scope;
|
|
@@ -123,6 +135,16 @@ interface RefsParams<T extends Dict> {
|
|
|
123
135
|
}
|
|
124
136
|
type ActionsOrFn<T extends Dict> = T["action"][] | ((params: Params<T>) => T["action"][] | undefined);
|
|
125
137
|
type EffectsOrFn<T extends Dict> = T["effect"][] | ((params: Params<T>) => T["effect"][] | undefined);
|
|
138
|
+
interface MachineState<T extends Dict, Parent extends string = string> {
|
|
139
|
+
id?: string | undefined;
|
|
140
|
+
tags?: T["tag"][] | undefined;
|
|
141
|
+
entry?: ActionsOrFn<T> | undefined;
|
|
142
|
+
exit?: ActionsOrFn<T> | undefined;
|
|
143
|
+
effects?: EffectsOrFn<T> | undefined;
|
|
144
|
+
initial?: ChildStateKey<T["state"], Parent> | undefined;
|
|
145
|
+
states?: { [K in ChildStateKey<T["state"], Parent>]?: MachineState<T, `${Parent}.${K}`> } | undefined;
|
|
146
|
+
on?: { [E in T["event"]["type"]]?: Transition<T, Parent> | Array<Transition<T, Parent>> } | undefined;
|
|
147
|
+
}
|
|
126
148
|
interface Machine<T extends Dict> {
|
|
127
149
|
debug?: boolean | undefined;
|
|
128
150
|
props?: ((params: PropsParams<T>) => T["props"]) | undefined;
|
|
@@ -136,14 +158,8 @@ interface Machine<T extends Dict> {
|
|
|
136
158
|
effects?: EffectsOrFn<T> | undefined;
|
|
137
159
|
refs?: ((params: RefsParams<T>) => T["refs"]) | undefined;
|
|
138
160
|
watch?: ((params: Params<T>) => void) | undefined;
|
|
139
|
-
on?: { [E in T["event"]["type"]]?: Transition<T> | Array<Transition<T>> } | undefined;
|
|
140
|
-
states: { [K in T["state"]]:
|
|
141
|
-
tags?: T["tag"][] | undefined;
|
|
142
|
-
entry?: ActionsOrFn<T> | undefined;
|
|
143
|
-
exit?: ActionsOrFn<T> | undefined;
|
|
144
|
-
effects?: EffectsOrFn<T> | undefined;
|
|
145
|
-
on?: { [E in T["event"]["type"]]?: Transition<T> | Array<Transition<T>> } | undefined;
|
|
146
|
-
} };
|
|
161
|
+
on?: { [E in T["event"]["type"]]?: Transition<T, undefined> | Array<Transition<T, undefined>> } | undefined;
|
|
162
|
+
states: { [K in TopLevelState<T["state"]>]: MachineState<T, K> };
|
|
147
163
|
implementations?: {
|
|
148
164
|
guards?: { [K in T["guard"]]: (params: Params<T>) => boolean } | undefined;
|
|
149
165
|
actions?: { [K in T["action"]]: (params: Params<T>) => void } | undefined;
|
|
@@ -198,4 +214,4 @@ declare enum MachineStatus {
|
|
|
198
214
|
}
|
|
199
215
|
declare const INIT_STATE = "__init__";
|
|
200
216
|
//#endregion
|
|
201
|
-
export {
|
|
217
|
+
export { TransitionMatch as C, TransitionMap as S, ValueOrFn as T, Params as _, BindableParams as a, Service as b, ComputedFn as c, GuardFn as d, INIT_STATE as f, MachineStatus as g, MachineState as h, BindableFn as i, EffectsOrFn as l, MachineSchema as m, Bindable as n, BindableRefs as o, Machine as p, BindableContext as r, ChooseFn as s, ActionsOrFn as t, EventObject as u, PropFn as v, TransitionSet as w, Transition as x, Scope as y };
|
package/package.json
CHANGED
package/dist/core-Ci9Yu6QI.mjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { en as getActiveElement, sn as isActiveElement, tn as getDocument } from "./dom-query-BFuRs3l4.mjs";
|
|
2
|
-
import { W as callAll, dt as isString, ft as isEqual } from "./utils-VVoZ_v29.mjs";
|
|
3
|
-
//#region src/shared/core/merge-props.ts
|
|
4
|
-
const clsx = (...args) => args.map((str) => str?.trim?.()).filter(Boolean).join(" ");
|
|
5
|
-
const CSS_REGEX = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;
|
|
6
|
-
const serialize = (style) => {
|
|
7
|
-
const res = {};
|
|
8
|
-
let match;
|
|
9
|
-
while (match = CSS_REGEX.exec(style)) res[match[1]] = match[2];
|
|
10
|
-
return res;
|
|
11
|
-
};
|
|
12
|
-
const css = (a, b) => {
|
|
13
|
-
if (isString(a)) {
|
|
14
|
-
if (isString(b)) return `${a};${b}`;
|
|
15
|
-
a = serialize(a);
|
|
16
|
-
} else if (isString(b)) b = serialize(b);
|
|
17
|
-
return Object.assign({}, a ?? {}, b ?? {});
|
|
18
|
-
};
|
|
19
|
-
function mergeProps(...args) {
|
|
20
|
-
let result = {};
|
|
21
|
-
for (let props of args) {
|
|
22
|
-
if (!props) continue;
|
|
23
|
-
for (let key in result) {
|
|
24
|
-
if (key.startsWith("on") && typeof result[key] === "function" && typeof props[key] === "function") {
|
|
25
|
-
result[key] = callAll(props[key], result[key]);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (key === "className" || key === "class") {
|
|
29
|
-
result[key] = clsx(result[key], props[key]);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (key === "style") {
|
|
33
|
-
result[key] = css(result[key], props[key]);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
result[key] = props[key] !== void 0 ? props[key] : result[key];
|
|
37
|
-
}
|
|
38
|
-
for (let key in props) if (result[key] === void 0) result[key] = props[key];
|
|
39
|
-
const symbols = Object.getOwnPropertySymbols(props);
|
|
40
|
-
for (let symbol of symbols) result[symbol] = props[symbol];
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/shared/core/memo.ts
|
|
46
|
-
function memo(getDeps, fn, opts) {
|
|
47
|
-
let deps = [];
|
|
48
|
-
let result;
|
|
49
|
-
return (depArgs) => {
|
|
50
|
-
const newDeps = getDeps(depArgs);
|
|
51
|
-
if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => !isEqual(deps[index], dep)))) return result;
|
|
52
|
-
deps = newDeps;
|
|
53
|
-
result = fn(newDeps, depArgs);
|
|
54
|
-
opts?.onChange?.(result);
|
|
55
|
-
return result;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/shared/core/create-machine.ts
|
|
60
|
-
function createGuards() {
|
|
61
|
-
return {
|
|
62
|
-
and: (...guards) => {
|
|
63
|
-
return function andGuard(params) {
|
|
64
|
-
return guards.every((str) => params.guard(str));
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
or: (...guards) => {
|
|
68
|
-
return function orGuard(params) {
|
|
69
|
-
return guards.some((str) => params.guard(str));
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
not: (guard) => {
|
|
73
|
-
return function notGuard(params) {
|
|
74
|
-
return !params.guard(guard);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function createMachine(config) {
|
|
80
|
-
return config;
|
|
81
|
-
}
|
|
82
|
-
function setup() {
|
|
83
|
-
return {
|
|
84
|
-
guards: createGuards(),
|
|
85
|
-
createMachine: (config) => {
|
|
86
|
-
return createMachine(config);
|
|
87
|
-
},
|
|
88
|
-
choose: (transitions) => {
|
|
89
|
-
return function chooseFn({ choose }) {
|
|
90
|
-
return choose(transitions)?.actions;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/shared/core/types.ts
|
|
97
|
-
let MachineStatus = /* @__PURE__ */ function(MachineStatus) {
|
|
98
|
-
MachineStatus["NotStarted"] = "Not Started";
|
|
99
|
-
MachineStatus["Started"] = "Started";
|
|
100
|
-
MachineStatus["Stopped"] = "Stopped";
|
|
101
|
-
return MachineStatus;
|
|
102
|
-
}({});
|
|
103
|
-
const INIT_STATE = "__init__";
|
|
104
|
-
//#endregion
|
|
105
|
-
//#region src/shared/core/scope.ts
|
|
106
|
-
function createScope(props) {
|
|
107
|
-
const getRootNode = () => props.getRootNode?.() ?? document;
|
|
108
|
-
const getDoc = () => getDocument(getRootNode());
|
|
109
|
-
const getWin = () => getDoc().defaultView ?? window;
|
|
110
|
-
const getActiveElementFn = () => getActiveElement(getRootNode());
|
|
111
|
-
const getById = (id) => getRootNode().getElementById(id);
|
|
112
|
-
return {
|
|
113
|
-
...props,
|
|
114
|
-
getRootNode,
|
|
115
|
-
getDoc,
|
|
116
|
-
getWin,
|
|
117
|
-
getActiveElement: getActiveElementFn,
|
|
118
|
-
isActiveElement,
|
|
119
|
-
getById
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
export { createMachine as a, mergeProps as c, createGuards as i, INIT_STATE as n, setup as o, MachineStatus as r, memo as s, createScope as t };
|
package/dist/core-DwdPztGA.cjs
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
const require_dom_query = require("./dom-query-BUO7rGsg.cjs");
|
|
2
|
-
const require_utils = require("./utils-ByNiZU8f.cjs");
|
|
3
|
-
//#region src/shared/core/merge-props.ts
|
|
4
|
-
const clsx = (...args) => args.map((str) => str?.trim?.()).filter(Boolean).join(" ");
|
|
5
|
-
const CSS_REGEX = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;
|
|
6
|
-
const serialize = (style) => {
|
|
7
|
-
const res = {};
|
|
8
|
-
let match;
|
|
9
|
-
while (match = CSS_REGEX.exec(style)) res[match[1]] = match[2];
|
|
10
|
-
return res;
|
|
11
|
-
};
|
|
12
|
-
const css = (a, b) => {
|
|
13
|
-
if (require_utils.isString(a)) {
|
|
14
|
-
if (require_utils.isString(b)) return `${a};${b}`;
|
|
15
|
-
a = serialize(a);
|
|
16
|
-
} else if (require_utils.isString(b)) b = serialize(b);
|
|
17
|
-
return Object.assign({}, a ?? {}, b ?? {});
|
|
18
|
-
};
|
|
19
|
-
function mergeProps(...args) {
|
|
20
|
-
let result = {};
|
|
21
|
-
for (let props of args) {
|
|
22
|
-
if (!props) continue;
|
|
23
|
-
for (let key in result) {
|
|
24
|
-
if (key.startsWith("on") && typeof result[key] === "function" && typeof props[key] === "function") {
|
|
25
|
-
result[key] = require_utils.callAll(props[key], result[key]);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (key === "className" || key === "class") {
|
|
29
|
-
result[key] = clsx(result[key], props[key]);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (key === "style") {
|
|
33
|
-
result[key] = css(result[key], props[key]);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
result[key] = props[key] !== void 0 ? props[key] : result[key];
|
|
37
|
-
}
|
|
38
|
-
for (let key in props) if (result[key] === void 0) result[key] = props[key];
|
|
39
|
-
const symbols = Object.getOwnPropertySymbols(props);
|
|
40
|
-
for (let symbol of symbols) result[symbol] = props[symbol];
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/shared/core/memo.ts
|
|
46
|
-
function memo(getDeps, fn, opts) {
|
|
47
|
-
let deps = [];
|
|
48
|
-
let result;
|
|
49
|
-
return (depArgs) => {
|
|
50
|
-
const newDeps = getDeps(depArgs);
|
|
51
|
-
if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => !require_utils.isEqual(deps[index], dep)))) return result;
|
|
52
|
-
deps = newDeps;
|
|
53
|
-
result = fn(newDeps, depArgs);
|
|
54
|
-
opts?.onChange?.(result);
|
|
55
|
-
return result;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/shared/core/create-machine.ts
|
|
60
|
-
function createGuards() {
|
|
61
|
-
return {
|
|
62
|
-
and: (...guards) => {
|
|
63
|
-
return function andGuard(params) {
|
|
64
|
-
return guards.every((str) => params.guard(str));
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
or: (...guards) => {
|
|
68
|
-
return function orGuard(params) {
|
|
69
|
-
return guards.some((str) => params.guard(str));
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
not: (guard) => {
|
|
73
|
-
return function notGuard(params) {
|
|
74
|
-
return !params.guard(guard);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function createMachine(config) {
|
|
80
|
-
return config;
|
|
81
|
-
}
|
|
82
|
-
function setup() {
|
|
83
|
-
return {
|
|
84
|
-
guards: createGuards(),
|
|
85
|
-
createMachine: (config) => {
|
|
86
|
-
return createMachine(config);
|
|
87
|
-
},
|
|
88
|
-
choose: (transitions) => {
|
|
89
|
-
return function chooseFn({ choose }) {
|
|
90
|
-
return choose(transitions)?.actions;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/shared/core/types.ts
|
|
97
|
-
let MachineStatus = /* @__PURE__ */ function(MachineStatus) {
|
|
98
|
-
MachineStatus["NotStarted"] = "Not Started";
|
|
99
|
-
MachineStatus["Started"] = "Started";
|
|
100
|
-
MachineStatus["Stopped"] = "Stopped";
|
|
101
|
-
return MachineStatus;
|
|
102
|
-
}({});
|
|
103
|
-
const INIT_STATE = "__init__";
|
|
104
|
-
//#endregion
|
|
105
|
-
//#region src/shared/core/scope.ts
|
|
106
|
-
function createScope(props) {
|
|
107
|
-
const getRootNode = () => props.getRootNode?.() ?? document;
|
|
108
|
-
const getDoc = () => require_dom_query.getDocument(getRootNode());
|
|
109
|
-
const getWin = () => getDoc().defaultView ?? window;
|
|
110
|
-
const getActiveElementFn = () => require_dom_query.getActiveElement(getRootNode());
|
|
111
|
-
const getById = (id) => getRootNode().getElementById(id);
|
|
112
|
-
return {
|
|
113
|
-
...props,
|
|
114
|
-
getRootNode,
|
|
115
|
-
getDoc,
|
|
116
|
-
getWin,
|
|
117
|
-
getActiveElement: getActiveElementFn,
|
|
118
|
-
isActiveElement: require_dom_query.isActiveElement,
|
|
119
|
-
getById
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
Object.defineProperty(exports, "INIT_STATE", {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
get: function() {
|
|
126
|
-
return INIT_STATE;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
Object.defineProperty(exports, "MachineStatus", {
|
|
130
|
-
enumerable: true,
|
|
131
|
-
get: function() {
|
|
132
|
-
return MachineStatus;
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(exports, "createGuards", {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
get: function() {
|
|
138
|
-
return createGuards;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
Object.defineProperty(exports, "createMachine", {
|
|
142
|
-
enumerable: true,
|
|
143
|
-
get: function() {
|
|
144
|
-
return createMachine;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
Object.defineProperty(exports, "createScope", {
|
|
148
|
-
enumerable: true,
|
|
149
|
-
get: function() {
|
|
150
|
-
return createScope;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
Object.defineProperty(exports, "memo", {
|
|
154
|
-
enumerable: true,
|
|
155
|
-
get: function() {
|
|
156
|
-
return memo;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
160
|
-
enumerable: true,
|
|
161
|
-
get: function() {
|
|
162
|
-
return mergeProps;
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
Object.defineProperty(exports, "setup", {
|
|
166
|
-
enumerable: true,
|
|
167
|
-
get: function() {
|
|
168
|
-
return setup;
|
|
169
|
-
}
|
|
170
|
-
});
|