sigmx 0.1.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/LICENSE +21 -0
- package/README.md +173 -0
- package/dist/auto.d.ts +1 -0
- package/dist/auto.js +7 -0
- package/dist/auto.js.map +7 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +7 -0
- package/dist/core/csp.d.ts +7 -0
- package/dist/core/csp.js +20 -0
- package/dist/core/csp.js.map +7 -0
- package/dist/core/engine.d.ts +10 -0
- package/dist/core/engine.js +200 -0
- package/dist/core/engine.js.map +7 -0
- package/dist/core/expr.d.ts +12 -0
- package/dist/core/expr.js +94 -0
- package/dist/core/expr.js.map +7 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +7 -0
- package/dist/core/signals.d.ts +42 -0
- package/dist/core/signals.js +195 -0
- package/dist/core/signals.js.map +7 -0
- package/dist/core/store.d.ts +32 -0
- package/dist/core/store.js +185 -0
- package/dist/core/store.js.map +7 -0
- package/dist/core/types.d.ts +101 -0
- package/dist/core/types.js +1 -0
- package/dist/core/types.js.map +7 -0
- package/dist/kernel/compile.d.ts +16 -0
- package/dist/kernel/compile.js +96 -0
- package/dist/kernel/compile.js.map +7 -0
- package/dist/kernel/contracts.d.ts +121 -0
- package/dist/kernel/contracts.js +1 -0
- package/dist/kernel/contracts.js.map +7 -0
- package/dist/kernel/index.d.ts +20 -0
- package/dist/kernel/index.js +54 -0
- package/dist/kernel/index.js.map +7 -0
- package/dist/kernel/precompile.d.ts +25 -0
- package/dist/kernel/precompile.js +111 -0
- package/dist/kernel/precompile.js.map +7 -0
- package/dist/kernel/precompiled.d.ts +11 -0
- package/dist/kernel/precompiled.js +13 -0
- package/dist/kernel/precompiled.js.map +7 -0
- package/dist/kernel/reactive.d.ts +42 -0
- package/dist/kernel/reactive.js +201 -0
- package/dist/kernel/reactive.js.map +7 -0
- package/dist/kernel/runtime.d.ts +11 -0
- package/dist/kernel/runtime.js +210 -0
- package/dist/kernel/runtime.js.map +7 -0
- package/dist/kernel/scan.d.ts +42 -0
- package/dist/kernel/scan.js +68 -0
- package/dist/kernel/scan.js.map +7 -0
- package/dist/kernel/state.d.ts +32 -0
- package/dist/kernel/state.js +186 -0
- package/dist/kernel/state.js.map +7 -0
- package/dist/kernel/strict-csp.d.ts +7 -0
- package/dist/kernel/strict-csp.js +20 -0
- package/dist/kernel/strict-csp.js.map +7 -0
- package/dist/lib/casing.d.ts +7 -0
- package/dist/lib/casing.js +16 -0
- package/dist/lib/casing.js.map +7 -0
- package/dist/lib/objects.d.ts +9 -0
- package/dist/lib/objects.js +26 -0
- package/dist/lib/objects.js.map +7 -0
- package/dist/lib/schedule.d.ts +14 -0
- package/dist/lib/schedule.js +51 -0
- package/dist/lib/schedule.js.map +7 -0
- package/dist/lib/sse.d.ts +10 -0
- package/dist/lib/sse.js +55 -0
- package/dist/lib/sse.js.map +7 -0
- package/dist/plugins/actions/clipboard.d.ts +2 -0
- package/dist/plugins/actions/clipboard.js +11 -0
- package/dist/plugins/actions/clipboard.js.map +7 -0
- package/dist/plugins/actions/fit.d.ts +2 -0
- package/dist/plugins/actions/fit.js +14 -0
- package/dist/plugins/actions/fit.js.map +7 -0
- package/dist/plugins/actions/intl.d.ts +2 -0
- package/dist/plugins/actions/intl.js +21 -0
- package/dist/plugins/actions/intl.js.map +7 -0
- package/dist/plugins/actions/peek.d.ts +2 -0
- package/dist/plugins/actions/peek.js +6 -0
- package/dist/plugins/actions/peek.js.map +7 -0
- package/dist/plugins/actions/setAll.d.ts +2 -0
- package/dist/plugins/actions/setAll.js +11 -0
- package/dist/plugins/actions/setAll.js.map +7 -0
- package/dist/plugins/actions/toggleAll.d.ts +2 -0
- package/dist/plugins/actions/toggleAll.js +11 -0
- package/dist/plugins/actions/toggleAll.js.map +7 -0
- package/dist/plugins/attributes/attr.d.ts +2 -0
- package/dist/plugins/attributes/attr.js +20 -0
- package/dist/plugins/attributes/attr.js.map +7 -0
- package/dist/plugins/attributes/bind.d.ts +6 -0
- package/dist/plugins/attributes/bind.js +81 -0
- package/dist/plugins/attributes/bind.js.map +7 -0
- package/dist/plugins/attributes/class.d.ts +2 -0
- package/dist/plugins/attributes/class.js +22 -0
- package/dist/plugins/attributes/class.js.map +7 -0
- package/dist/plugins/attributes/computed.d.ts +2 -0
- package/dist/plugins/attributes/computed.js +20 -0
- package/dist/plugins/attributes/computed.js.map +7 -0
- package/dist/plugins/attributes/customValidity.d.ts +2 -0
- package/dist/plugins/attributes/customValidity.js +14 -0
- package/dist/plugins/attributes/customValidity.js.map +7 -0
- package/dist/plugins/attributes/effect.d.ts +2 -0
- package/dist/plugins/attributes/effect.js +12 -0
- package/dist/plugins/attributes/effect.js.map +7 -0
- package/dist/plugins/attributes/indicator.d.ts +2 -0
- package/dist/plugins/attributes/indicator.js +20 -0
- package/dist/plugins/attributes/indicator.js.map +7 -0
- package/dist/plugins/attributes/init.d.ts +2 -0
- package/dist/plugins/attributes/init.js +14 -0
- package/dist/plugins/attributes/init.js.map +7 -0
- package/dist/plugins/attributes/jsonSignals.d.ts +2 -0
- package/dist/plugins/attributes/jsonSignals.js +15 -0
- package/dist/plugins/attributes/jsonSignals.js.map +7 -0
- package/dist/plugins/attributes/matchMedia.d.ts +2 -0
- package/dist/plugins/attributes/matchMedia.js +19 -0
- package/dist/plugins/attributes/matchMedia.js.map +7 -0
- package/dist/plugins/attributes/on.d.ts +5 -0
- package/dist/plugins/attributes/on.js +28 -0
- package/dist/plugins/attributes/on.js.map +7 -0
- package/dist/plugins/attributes/onIntersect.d.ts +2 -0
- package/dist/plugins/attributes/onIntersect.js +28 -0
- package/dist/plugins/attributes/onIntersect.js.map +7 -0
- package/dist/plugins/attributes/onInterval.d.ts +2 -0
- package/dist/plugins/attributes/onInterval.js +18 -0
- package/dist/plugins/attributes/onInterval.js.map +7 -0
- package/dist/plugins/attributes/onRaf.d.ts +1 -0
- package/dist/plugins/attributes/onRaf.js +19 -0
- package/dist/plugins/attributes/onRaf.js.map +7 -0
- package/dist/plugins/attributes/onResize.d.ts +1 -0
- package/dist/plugins/attributes/onResize.js +17 -0
- package/dist/plugins/attributes/onResize.js.map +7 -0
- package/dist/plugins/attributes/onSignalPatch.d.ts +5 -0
- package/dist/plugins/attributes/onSignalPatch.js +35 -0
- package/dist/plugins/attributes/onSignalPatch.js.map +7 -0
- package/dist/plugins/attributes/persist.d.ts +6 -0
- package/dist/plugins/attributes/persist.js +16 -0
- package/dist/plugins/attributes/persist.js.map +7 -0
- package/dist/plugins/attributes/queryString.d.ts +5 -0
- package/dist/plugins/attributes/queryString.js +54 -0
- package/dist/plugins/attributes/queryString.js.map +7 -0
- package/dist/plugins/attributes/ref.d.ts +2 -0
- package/dist/plugins/attributes/ref.js +13 -0
- package/dist/plugins/attributes/ref.js.map +7 -0
- package/dist/plugins/attributes/replaceUrl.d.ts +1 -0
- package/dist/plugins/attributes/replaceUrl.js +11 -0
- package/dist/plugins/attributes/replaceUrl.js.map +7 -0
- package/dist/plugins/attributes/scrollIntoView.d.ts +2 -0
- package/dist/plugins/attributes/scrollIntoView.js +19 -0
- package/dist/plugins/attributes/scrollIntoView.js.map +7 -0
- package/dist/plugins/attributes/show.d.ts +2 -0
- package/dist/plugins/attributes/show.js +19 -0
- package/dist/plugins/attributes/show.js.map +7 -0
- package/dist/plugins/attributes/signals.d.ts +2 -0
- package/dist/plugins/attributes/signals.js +13 -0
- package/dist/plugins/attributes/signals.js.map +7 -0
- package/dist/plugins/attributes/style.d.ts +2 -0
- package/dist/plugins/attributes/style.js +25 -0
- package/dist/plugins/attributes/style.js.map +7 -0
- package/dist/plugins/attributes/text.d.ts +1 -0
- package/dist/plugins/attributes/text.js +13 -0
- package/dist/plugins/attributes/text.js.map +7 -0
- package/dist/plugins/attributes/viewTransition.d.ts +1 -0
- package/dist/plugins/attributes/viewTransition.js +11 -0
- package/dist/plugins/attributes/viewTransition.js.map +7 -0
- package/dist/plugins/directives/attribute-sync.d.ts +2 -0
- package/dist/plugins/directives/attribute-sync.js +20 -0
- package/dist/plugins/directives/attribute-sync.js.map +7 -0
- package/dist/plugins/directives/boost.d.ts +6 -0
- package/dist/plugins/directives/boost.js +35 -0
- package/dist/plugins/directives/boost.js.map +7 -0
- package/dist/plugins/directives/busy-flag.d.ts +2 -0
- package/dist/plugins/directives/busy-flag.js +21 -0
- package/dist/plugins/directives/busy-flag.js.map +7 -0
- package/dist/plugins/directives/class-toggle.d.ts +2 -0
- package/dist/plugins/directives/class-toggle.js +22 -0
- package/dist/plugins/directives/class-toggle.js.map +7 -0
- package/dist/plugins/directives/cloak.d.ts +5 -0
- package/dist/plugins/directives/cloak.js +11 -0
- package/dist/plugins/directives/cloak.js.map +7 -0
- package/dist/plugins/directives/collapse.d.ts +5 -0
- package/dist/plugins/directives/collapse.js +42 -0
- package/dist/plugins/directives/collapse.js.map +7 -0
- package/dist/plugins/directives/declare.d.ts +2 -0
- package/dist/plugins/directives/declare.js +13 -0
- package/dist/plugins/directives/declare.js.map +7 -0
- package/dist/plugins/directives/derive.d.ts +2 -0
- package/dist/plugins/directives/derive.js +20 -0
- package/dist/plugins/directives/derive.js.map +7 -0
- package/dist/plugins/directives/element-ref.d.ts +2 -0
- package/dist/plugins/directives/element-ref.js +13 -0
- package/dist/plugins/directives/element-ref.js.map +7 -0
- package/dist/plugins/directives/event-listener.d.ts +5 -0
- package/dist/plugins/directives/event-listener.js +28 -0
- package/dist/plugins/directives/event-listener.js.map +7 -0
- package/dist/plugins/directives/frame-loop.d.ts +1 -0
- package/dist/plugins/directives/frame-loop.js +19 -0
- package/dist/plugins/directives/frame-loop.js.map +7 -0
- package/dist/plugins/directives/html.d.ts +2 -0
- package/dist/plugins/directives/html.js +13 -0
- package/dist/plugins/directives/html.js.map +7 -0
- package/dist/plugins/directives/inline-style.d.ts +2 -0
- package/dist/plugins/directives/inline-style.js +25 -0
- package/dist/plugins/directives/inline-style.js.map +7 -0
- package/dist/plugins/directives/mask.d.ts +7 -0
- package/dist/plugins/directives/mask.js +47 -0
- package/dist/plugins/directives/mask.js.map +7 -0
- package/dist/plugins/directives/media-query.d.ts +2 -0
- package/dist/plugins/directives/media-query.js +19 -0
- package/dist/plugins/directives/media-query.js.map +7 -0
- package/dist/plugins/directives/on-mount.d.ts +2 -0
- package/dist/plugins/directives/on-mount.js +14 -0
- package/dist/plugins/directives/on-mount.js.map +7 -0
- package/dist/plugins/directives/patch-listener.d.ts +5 -0
- package/dist/plugins/directives/patch-listener.js +35 -0
- package/dist/plugins/directives/patch-listener.js.map +7 -0
- package/dist/plugins/directives/remove-me.d.ts +2 -0
- package/dist/plugins/directives/remove-me.js +13 -0
- package/dist/plugins/directives/remove-me.js.map +7 -0
- package/dist/plugins/directives/scroll-to.d.ts +2 -0
- package/dist/plugins/directives/scroll-to.js +19 -0
- package/dist/plugins/directives/scroll-to.js.map +7 -0
- package/dist/plugins/directives/size-watch.d.ts +1 -0
- package/dist/plugins/directives/size-watch.js +17 -0
- package/dist/plugins/directives/size-watch.js.map +7 -0
- package/dist/plugins/directives/state-dump.d.ts +2 -0
- package/dist/plugins/directives/state-dump.js +15 -0
- package/dist/plugins/directives/state-dump.js.map +7 -0
- package/dist/plugins/directives/storage-sync.d.ts +6 -0
- package/dist/plugins/directives/storage-sync.js +16 -0
- package/dist/plugins/directives/storage-sync.js.map +7 -0
- package/dist/plugins/directives/teleport.d.ts +5 -0
- package/dist/plugins/directives/teleport.js +19 -0
- package/dist/plugins/directives/teleport.js.map +7 -0
- package/dist/plugins/directives/text-content.d.ts +1 -0
- package/dist/plugins/directives/text-content.js +13 -0
- package/dist/plugins/directives/text-content.js.map +7 -0
- package/dist/plugins/directives/timer.d.ts +2 -0
- package/dist/plugins/directives/timer.js +18 -0
- package/dist/plugins/directives/timer.js.map +7 -0
- package/dist/plugins/directives/transition-name.d.ts +1 -0
- package/dist/plugins/directives/transition-name.js +11 -0
- package/dist/plugins/directives/transition-name.js.map +7 -0
- package/dist/plugins/directives/transition.d.ts +5 -0
- package/dist/plugins/directives/transition.js +40 -0
- package/dist/plugins/directives/transition.js.map +7 -0
- package/dist/plugins/directives/trap.d.ts +5 -0
- package/dist/plugins/directives/trap.js +48 -0
- package/dist/plugins/directives/trap.js.map +7 -0
- package/dist/plugins/directives/tween.d.ts +6 -0
- package/dist/plugins/directives/tween.js +58 -0
- package/dist/plugins/directives/tween.js.map +7 -0
- package/dist/plugins/directives/two-way-bind.d.ts +6 -0
- package/dist/plugins/directives/two-way-bind.js +82 -0
- package/dist/plugins/directives/two-way-bind.js.map +7 -0
- package/dist/plugins/directives/url-params.d.ts +13 -0
- package/dist/plugins/directives/url-params.js +76 -0
- package/dist/plugins/directives/url-params.js.map +7 -0
- package/dist/plugins/directives/url-replace.d.ts +1 -0
- package/dist/plugins/directives/url-replace.js +11 -0
- package/dist/plugins/directives/url-replace.js.map +7 -0
- package/dist/plugins/directives/validity.d.ts +2 -0
- package/dist/plugins/directives/validity.js +14 -0
- package/dist/plugins/directives/validity.js.map +7 -0
- package/dist/plugins/directives/viewport.d.ts +2 -0
- package/dist/plugins/directives/viewport.js +28 -0
- package/dist/plugins/directives/viewport.js.map +7 -0
- package/dist/plugins/directives/visibility.d.ts +2 -0
- package/dist/plugins/directives/visibility.js +19 -0
- package/dist/plugins/directives/visibility.js.map +7 -0
- package/dist/plugins/directives/watch.d.ts +2 -0
- package/dist/plugins/directives/watch.js +12 -0
- package/dist/plugins/directives/watch.js.map +7 -0
- package/dist/plugins/functions/bulk-set.d.ts +2 -0
- package/dist/plugins/functions/bulk-set.js +11 -0
- package/dist/plugins/functions/bulk-set.js.map +7 -0
- package/dist/plugins/functions/bulk-toggle.d.ts +2 -0
- package/dist/plugins/functions/bulk-toggle.js +11 -0
- package/dist/plugins/functions/bulk-toggle.js.map +7 -0
- package/dist/plugins/functions/confirm.d.ts +2 -0
- package/dist/plugins/functions/confirm.js +6 -0
- package/dist/plugins/functions/confirm.js.map +7 -0
- package/dist/plugins/functions/copy-text.d.ts +2 -0
- package/dist/plugins/functions/copy-text.js +11 -0
- package/dist/plugins/functions/copy-text.js.map +7 -0
- package/dist/plugins/functions/dispatch.d.ts +2 -0
- package/dist/plugins/functions/dispatch.js +9 -0
- package/dist/plugins/functions/dispatch.js.map +7 -0
- package/dist/plugins/functions/locale-format.d.ts +2 -0
- package/dist/plugins/functions/locale-format.js +21 -0
- package/dist/plugins/functions/locale-format.js.map +7 -0
- package/dist/plugins/functions/range-map.d.ts +2 -0
- package/dist/plugins/functions/range-map.js +14 -0
- package/dist/plugins/functions/range-map.js.map +7 -0
- package/dist/plugins/functions/request.d.ts +30 -0
- package/dist/plugins/functions/request.js +152 -0
- package/dist/plugins/functions/request.js.map +7 -0
- package/dist/plugins/functions/untracked-read.d.ts +2 -0
- package/dist/plugins/functions/untracked-read.js +6 -0
- package/dist/plugins/functions/untracked-read.js.map +7 -0
- package/dist/plugins/functions/websocket.d.ts +11 -0
- package/dist/plugins/functions/websocket.js +35 -0
- package/dist/plugins/functions/websocket.js.map +7 -0
- package/dist/plugins/index.d.ts +52 -0
- package/dist/plugins/index.js +108 -0
- package/dist/plugins/index.js.map +7 -0
- package/dist/plugins/server-events/apply-elements.d.ts +2 -0
- package/dist/plugins/server-events/apply-elements.js +62 -0
- package/dist/plugins/server-events/apply-elements.js.map +7 -0
- package/dist/plugins/server-events/apply-state.d.ts +2 -0
- package/dist/plugins/server-events/apply-state.js +18 -0
- package/dist/plugins/server-events/apply-state.js.map +7 -0
- package/dist/plugins/server-events/morph.d.ts +12 -0
- package/dist/plugins/server-events/morph.js +124 -0
- package/dist/plugins/server-events/morph.js.map +7 -0
- package/dist/presets/all.d.ts +3 -0
- package/dist/presets/all.js +112 -0
- package/dist/presets/all.js.map +7 -0
- package/dist/presets/essentials.d.ts +3 -0
- package/dist/presets/essentials.js +18 -0
- package/dist/presets/essentials.js.map +7 -0
- package/dist/presets/minimal.d.ts +3 -0
- package/dist/presets/minimal.js +9 -0
- package/dist/presets/minimal.js.map +7 -0
- package/dist/sigmx.auto.js +5 -0
- package/dist/sigmx.standalone.js +1 -0
- package/dist/standalone.d.ts +1 -0
- package/dist/standalone.js +8 -0
- package/dist/standalone.js.map +7 -0
- package/dist/utils/object.d.ts +9 -0
- package/dist/utils/object.js +26 -0
- package/dist/utils/object.js.map +7 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.js +15 -0
- package/dist/utils/text.js.map +7 -0
- package/dist/utils/timing.d.ts +14 -0
- package/dist/utils/timing.js +58 -0
- package/dist/utils/timing.js.map +7 -0
- package/dist/vite.d.ts +42 -0
- package/dist/vite.js +79 -0
- package/dist/vite.js.map +7 -0
- package/package.json +111 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { action } from "../../core/index.js";
|
|
2
|
+
const formats = {
|
|
3
|
+
number: (l, v, o) => new Intl.NumberFormat(l, o).format(v),
|
|
4
|
+
datetime: (l, v, o) => new Intl.DateTimeFormat(l, o).format(v),
|
|
5
|
+
pluralRules: (l, v, o) => new Intl.PluralRules(l, o).select(v),
|
|
6
|
+
relativeTime: (l, v, o) => new Intl.RelativeTimeFormat(l, o).format(v[0], v[1]),
|
|
7
|
+
list: (l, v, o) => new Intl.ListFormat(l, o).format(v),
|
|
8
|
+
displayNames: (l, v, o) => new Intl.DisplayNames(l, o).of(v) ?? ""
|
|
9
|
+
};
|
|
10
|
+
const intl = action({
|
|
11
|
+
name: "intl",
|
|
12
|
+
call: ({ error }, type, value, options, locale) => {
|
|
13
|
+
const f = formats[type];
|
|
14
|
+
if (!f) throw error(`unknown @intl type "${type}"`);
|
|
15
|
+
return f(locale, value, options);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
intl
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=intl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/actions/intl.ts"],
|
|
4
|
+
"sourcesContent": ["import { action } from '../../core/index.js'\n\ntype Fmt = (locale: string | string[] | undefined, value: any, options: any) => string\nconst formats: Record<string, Fmt> = {\n number: (l, v, o) => new Intl.NumberFormat(l, o).format(v),\n datetime: (l, v, o) => new Intl.DateTimeFormat(l, o).format(v),\n pluralRules: (l, v, o) => new Intl.PluralRules(l, o).select(v),\n relativeTime: (l, v, o) => new Intl.RelativeTimeFormat(l, o).format(v[0], v[1]),\n list: (l, v, o) => new Intl.ListFormat(l, o).format(v),\n displayNames: (l, v, o) => new Intl.DisplayNames(l, o).of(v) ?? '',\n}\n\n/** `@intl('number', 1234.5, { style: 'currency', currency: 'USD' }, 'en-US')`. */\nexport const intl = action({\n name: 'intl',\n call: ({ error }, type: string, value: unknown, options?: Record<string, unknown>, locale?: string | string[]) => {\n const f = formats[type]\n if (!f) throw error(`unknown @intl type \"${type}\"`)\n return f(locale, value, options)\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAGvB,MAAM,UAA+B;AAAA,EACnC,QAAQ,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,aAAa,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EACzD,UAAU,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,eAAe,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EAC7D,aAAa,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,YAAY,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EAC7D,cAAc,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,mBAAmB,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAAA,EAC9E,MAAM,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,WAAW,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EACrD,cAAc,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,aAAa,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK;AAClE;AAGO,MAAM,OAAO,OAAO;AAAA,EACzB,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,MAAc,OAAgB,SAAmC,WAA+B;AAChH,UAAM,IAAI,QAAQ,IAAI;AACtB,QAAI,CAAC,EAAG,OAAM,MAAM,uBAAuB,IAAI,GAAG;AAClD,WAAO,EAAE,QAAQ,OAAO,OAAO;AAAA,EACjC;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/actions/peek.ts"],
|
|
4
|
+
"sourcesContent": ["import { action, untracked } from '../../core/index.js'\n\n/** `@peek(() => $x)` reads signals without subscribing the surrounding effect. */\nexport const peek = action({ name: 'peek', call: (_, fn: () => unknown) => untracked(fn) })\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAQ,iBAAiB;AAG3B,MAAM,OAAO,OAAO,EAAE,MAAM,QAAQ,MAAM,CAAC,GAAG,OAAsB,UAAU,EAAE,EAAE,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { action, batch, untracked } from "../../core/index.js";
|
|
2
|
+
const setAll = action({
|
|
3
|
+
name: "setAll",
|
|
4
|
+
call: ({ store }, value, filter) => batch(() => untracked(() => {
|
|
5
|
+
for (const p of store.paths(filter)) store.set(p, value);
|
|
6
|
+
}))
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
setAll
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=setAll.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/actions/setAll.ts"],
|
|
4
|
+
"sourcesContent": ["import { action, batch, untracked, type Filter } from '../../core/index.js'\n\n/** `@setAll(value, { include: /^form\\./ })` assigns every matching signal. */\nexport const setAll = action({\n name: 'setAll',\n call: ({ store }, value: unknown, filter?: Filter) =>\n batch(() => untracked(() => { for (const p of store.paths(filter)) store.set(p, value) })),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAQ,OAAO,iBAA8B;AAG/C,MAAM,SAAS,OAAO;AAAA,EAC3B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,OAAgB,WAChC,MAAM,MAAM,UAAU,MAAM;AAAE,eAAW,KAAK,MAAM,MAAM,MAAM,EAAG,OAAM,IAAI,GAAG,KAAK;AAAA,EAAE,CAAC,CAAC;AAC7F,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { action, batch, untracked } from "../../core/index.js";
|
|
2
|
+
const toggleAll = action({
|
|
3
|
+
name: "toggleAll",
|
|
4
|
+
call: ({ store }, filter) => batch(() => untracked(() => {
|
|
5
|
+
for (const p of store.paths(filter)) store.set(p, !store.get(p));
|
|
6
|
+
}))
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
toggleAll
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=toggleAll.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/actions/toggleAll.ts"],
|
|
4
|
+
"sourcesContent": ["import { action, batch, untracked, type Filter } from '../../core/index.js'\n\n/** `@toggleAll({ include: /^flags\\./ })` negates every matching boolean signal. */\nexport const toggleAll = action({\n name: 'toggleAll',\n call: ({ store }, filter?: Filter) =>\n batch(() => untracked(() => { for (const p of store.paths(filter)) store.set(p, !store.get(p)) })),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAQ,OAAO,iBAA8B;AAG/C,MAAM,YAAY,OAAO;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,WAChB,MAAM,MAAM,UAAU,MAAM;AAAE,eAAW,KAAK,MAAM,MAAM,MAAM,EAAG,OAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAAA,EAAE,CAAC,CAAC;AACrG,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const put = (el, name, v) => {
|
|
3
|
+
if (v === false || v == null) el.removeAttribute(name);
|
|
4
|
+
else el.setAttribute(name, v === true ? "" : typeof v === "object" ? JSON.stringify(v) : String(v));
|
|
5
|
+
};
|
|
6
|
+
const attr = attribute({
|
|
7
|
+
name: "attr",
|
|
8
|
+
value: "required",
|
|
9
|
+
mount({ el, key, cased, evaluate, effect }) {
|
|
10
|
+
effect(() => {
|
|
11
|
+
if (key) return put(el, cased("kebab"), evaluate());
|
|
12
|
+
const map = evaluate();
|
|
13
|
+
for (const k in map) put(el, k, map[k]);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
attr
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=attr.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/attr.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\nconst put = (el: Element, name: string, v: unknown) => {\n if (v === false || v == null) el.removeAttribute(name)\n else el.setAttribute(name, v === true ? '' : typeof v === 'object' ? JSON.stringify(v) : String(v))\n}\n\n/** `attr:title=\"expr\"` or `attr=\"{ title: expr }\"`. true \u2192 present, false/null \u2192 removed. */\nexport const attr = attribute({\n name: 'attr',\n value: 'required',\n mount({ el, key, cased, evaluate, effect }) {\n effect(() => {\n if (key) return put(el, cased('kebab'), evaluate())\n const map = evaluate()\n for (const k in map) put(el, k, map[k])\n })\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAE1B,MAAM,MAAM,CAAC,IAAa,MAAc,MAAe;AACrD,MAAI,MAAM,SAAS,KAAK,KAAM,IAAG,gBAAgB,IAAI;AAAA,MAChD,IAAG,aAAa,MAAM,MAAM,OAAO,KAAK,OAAO,MAAM,WAAW,KAAK,UAAU,CAAC,IAAI,OAAO,CAAC,CAAC;AACpG;AAGO,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,GAAG;AAC1C,WAAO,MAAM;AACX,UAAI,IAAK,QAAO,IAAI,IAAI,MAAM,OAAO,GAAG,SAAS,CAAC;AAClD,YAAM,MAAM,SAAS;AACrB,iBAAW,KAAK,IAAK,KAAI,IAAI,GAAG,IAAI,CAAC,CAAC;AAAA,IACxC,CAAC;AAAA,EACH;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two-way binding: `bind:name` or `bind="name"`. Creates the signal from the element when missing.
|
|
3
|
+
* Checkbox groups bind to arrays, radios to the checked value, `select multiple` to arrays.
|
|
4
|
+
* `__prop.value` binds a custom element property; `__event.change` picks the events to listen for.
|
|
5
|
+
*/
|
|
6
|
+
export declare const bind: import("../../core/types.js").AttributePlugin;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const readFiles = (input) => Promise.all(
|
|
3
|
+
[...input.files ?? []].map(
|
|
4
|
+
(f) => new Promise((resolve) => {
|
|
5
|
+
const r = new FileReader();
|
|
6
|
+
r.onloadend = () => resolve({ name: f.name, type: f.type, size: f.size, contents: String(r.result).split(",")[1] ?? "" });
|
|
7
|
+
r.readAsDataURL(f);
|
|
8
|
+
})
|
|
9
|
+
)
|
|
10
|
+
);
|
|
11
|
+
const bind = attribute({
|
|
12
|
+
name: "bind",
|
|
13
|
+
mount({ el, key, value, cased, mods, store, listen, effect }) {
|
|
14
|
+
const path = key ? cased() : value.trim();
|
|
15
|
+
const current = () => store.get(path);
|
|
16
|
+
const asNumber = (s) => typeof current() === "number" ? +s : s;
|
|
17
|
+
let a;
|
|
18
|
+
const prop = mods.get("prop")?.[0];
|
|
19
|
+
if (prop) {
|
|
20
|
+
a = { read: () => el[prop], write: (v) => el[prop] = v, events: ["input", "change"] };
|
|
21
|
+
} else if (el instanceof HTMLInputElement) {
|
|
22
|
+
const t = el.type;
|
|
23
|
+
if (t === "checkbox") {
|
|
24
|
+
const own = el.hasAttribute("value") && el.value !== "on";
|
|
25
|
+
a = {
|
|
26
|
+
read: () => {
|
|
27
|
+
const cur = current();
|
|
28
|
+
if (Array.isArray(cur)) {
|
|
29
|
+
const set = new Set(cur);
|
|
30
|
+
el.checked ? set.add(el.value) : set.delete(el.value);
|
|
31
|
+
return [...set];
|
|
32
|
+
}
|
|
33
|
+
return own ? el.checked ? el.value : "" : el.checked;
|
|
34
|
+
},
|
|
35
|
+
write: (v) => {
|
|
36
|
+
el.checked = Array.isArray(v) ? v.includes(el.value) : own ? v === el.value : !!v;
|
|
37
|
+
},
|
|
38
|
+
events: ["input"]
|
|
39
|
+
};
|
|
40
|
+
} else if (t === "radio") {
|
|
41
|
+
if (!el.name) el.name = path;
|
|
42
|
+
a = { read: () => el.checked ? asNumber(el.value) : current(), write: (v) => el.checked = String(v) === el.value, events: ["input"] };
|
|
43
|
+
} else if (t === "file") {
|
|
44
|
+
listen(el, "change", () => readFiles(el).then((files) => store.set(path, files)));
|
|
45
|
+
return;
|
|
46
|
+
} else if (t === "number" || t === "range") {
|
|
47
|
+
a = { read: () => el.value === "" ? "" : +el.value, write: (v) => el.value = String(v ?? ""), events: ["input"] };
|
|
48
|
+
} else {
|
|
49
|
+
a = { read: () => el.value, write: (v) => el.value = String(v ?? ""), events: ["input"] };
|
|
50
|
+
}
|
|
51
|
+
} else if (el instanceof HTMLSelectElement) {
|
|
52
|
+
a = {
|
|
53
|
+
read: () => el.multiple ? [...el.selectedOptions].map((o) => asNumber(o.value)) : asNumber(el.value),
|
|
54
|
+
write: (v) => {
|
|
55
|
+
if (el.multiple) for (const o of el.options) o.selected = Array.isArray(v) && v.map(String).includes(o.value);
|
|
56
|
+
else el.value = String(v ?? "");
|
|
57
|
+
},
|
|
58
|
+
events: ["change"]
|
|
59
|
+
};
|
|
60
|
+
} else if (el instanceof HTMLTextAreaElement || "value" in el) {
|
|
61
|
+
a = { read: () => el.value, write: (v) => el.value = String(v ?? ""), events: ["input", "change"] };
|
|
62
|
+
} else {
|
|
63
|
+
a = { read: () => el.getAttribute("value"), write: (v) => el.setAttribute("value", String(v ?? "")), events: ["change"] };
|
|
64
|
+
}
|
|
65
|
+
if (!store.has(path)) {
|
|
66
|
+
const initial = a.read();
|
|
67
|
+
if (initial !== void 0 && initial !== "") store.set(path, initial);
|
|
68
|
+
}
|
|
69
|
+
const sync = () => store.set(path, a.read());
|
|
70
|
+
for (const type of mods.get("event") ?? a.events) listen(el, type, sync);
|
|
71
|
+
listen(el, "sigmx-prop-change", sync);
|
|
72
|
+
effect(() => {
|
|
73
|
+
const v = current();
|
|
74
|
+
if (v !== void 0) a.write(v);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
export {
|
|
79
|
+
bind
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=bind.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/bind.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\ntype Adapter = { read(): unknown; write(v: unknown): void; events: string[] }\n\nconst readFiles = (input: HTMLInputElement) =>\n Promise.all(\n [...(input.files ?? [])].map(\n (f) =>\n new Promise<{ name: string; type: string; size: number; contents: string }>((resolve) => {\n const r = new FileReader()\n r.onloadend = () =>\n resolve({ name: f.name, type: f.type, size: f.size, contents: String(r.result).split(',')[1] ?? '' })\n r.readAsDataURL(f)\n }),\n ),\n )\n\n/**\n * Two-way binding: `bind:name` or `bind=\"name\"`. Creates the signal from the element when missing.\n * Checkbox groups bind to arrays, radios to the checked value, `select multiple` to arrays.\n * `__prop.value` binds a custom element property; `__event.change` picks the events to listen for.\n */\nexport const bind = attribute({\n name: 'bind',\n mount({ el, key, value, cased, mods, store, listen, effect }) {\n const path = key ? cased() : value.trim()\n const current = () => store.get(path)\n const asNumber = (s: string) => (typeof current() === 'number' ? +s : s)\n let a: Adapter\n const prop = mods.get('prop')?.[0]\n\n if (prop) {\n a = { read: () => (el as any)[prop], write: (v) => ((el as any)[prop] = v), events: ['input', 'change'] }\n } else if (el instanceof HTMLInputElement) {\n const t = el.type\n if (t === 'checkbox') {\n const own = el.hasAttribute('value') && el.value !== 'on'\n a = {\n read: () => {\n const cur = current()\n if (Array.isArray(cur)) {\n const set = new Set(cur)\n el.checked ? set.add(el.value) : set.delete(el.value)\n return [...set]\n }\n return own ? (el.checked ? el.value : '') : el.checked\n },\n write: (v) => {\n el.checked = Array.isArray(v) ? v.includes(el.value) : own ? v === el.value : !!v\n },\n events: ['input'],\n }\n } else if (t === 'radio') {\n if (!el.name) el.name = path\n a = { read: () => (el.checked ? asNumber(el.value) : current()), write: (v) => (el.checked = String(v) === el.value), events: ['input'] }\n } else if (t === 'file') {\n listen(el, 'change', () => readFiles(el).then((files) => store.set(path, files)))\n return\n } else if (t === 'number' || t === 'range') {\n a = { read: () => (el.value === '' ? '' : +el.value), write: (v) => (el.value = String(v ?? '')), events: ['input'] }\n } else {\n a = { read: () => el.value, write: (v) => (el.value = String(v ?? '')), events: ['input'] }\n }\n } else if (el instanceof HTMLSelectElement) {\n a = {\n read: () => (el.multiple ? [...el.selectedOptions].map((o) => asNumber(o.value)) : asNumber(el.value)),\n write: (v) => {\n if (el.multiple) for (const o of el.options) o.selected = Array.isArray(v) && v.map(String).includes(o.value)\n else el.value = String(v ?? '')\n },\n events: ['change'],\n }\n } else if (el instanceof HTMLTextAreaElement || 'value' in el) {\n a = { read: () => (el as any).value, write: (v) => ((el as any).value = String(v ?? '')), events: ['input', 'change'] }\n } else {\n a = { read: () => el.getAttribute('value'), write: (v) => el.setAttribute('value', String(v ?? '')), events: ['change'] }\n }\n\n if (!store.has(path)) {\n const initial = a.read()\n if (initial !== undefined && initial !== '') store.set(path, initial)\n }\n const sync = () => store.set(path, a.read())\n for (const type of mods.get('event') ?? a.events) listen(el, type, sync)\n listen(el, 'sigmx-prop-change', sync)\n effect(() => {\n const v = current()\n if (v !== undefined) a.write(v)\n })\n },\n})\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const className = attribute({
|
|
3
|
+
name: "class",
|
|
4
|
+
value: "required",
|
|
5
|
+
mount({ el, key, cased, evaluate, effect }) {
|
|
6
|
+
const applied = /* @__PURE__ */ new Set();
|
|
7
|
+
effect(() => {
|
|
8
|
+
const map = key ? { [cased("kebab")]: evaluate() } : evaluate();
|
|
9
|
+
for (const k in map) {
|
|
10
|
+
for (const name of k.split(/\s+/).filter(Boolean)) {
|
|
11
|
+
el.classList.toggle(name, !!map[k]);
|
|
12
|
+
map[k] ? applied.add(name) : applied.delete(name);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return () => el.classList.remove(...applied);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
className
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=class.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/class.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\n/** `class:active=\"expr\"` or `class=\"{ active: expr, 'a b': expr }\"`. */\nexport const className = attribute({\n name: 'class',\n value: 'required',\n mount({ el, key, cased, evaluate, effect }) {\n const applied = new Set<string>()\n effect(() => {\n const map: Record<string, unknown> = key ? { [cased('kebab')]: evaluate() } : evaluate()\n for (const k in map) {\n for (const name of k.split(/\\s+/).filter(Boolean)) {\n el.classList.toggle(name, !!map[k])\n map[k] ? applied.add(name) : applied.delete(name)\n }\n }\n })\n return () => el.classList.remove(...applied)\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,YAAY,UAAU;AAAA,EACjC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,GAAG;AAC1C,UAAM,UAAU,oBAAI,IAAY;AAChC,WAAO,MAAM;AACX,YAAM,MAA+B,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,EAAE,IAAI,SAAS;AACvF,iBAAW,KAAK,KAAK;AACnB,mBAAW,QAAQ,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO,GAAG;AACjD,aAAG,UAAU,OAAO,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAClC,cAAI,CAAC,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,OAAO,IAAI;AAAA,QAClD;AAAA,MACF;AAAA,IACF,CAAC;AACD,WAAO,MAAM,GAAG,UAAU,OAAO,GAAG,OAAO;AAAA,EAC7C;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { attribute, computed as makeComputed } from "../../core/index.js";
|
|
2
|
+
const computed = attribute({
|
|
3
|
+
name: "computed",
|
|
4
|
+
value: "required",
|
|
5
|
+
mount({ key, cased, evaluate, store, error }) {
|
|
6
|
+
if (key) {
|
|
7
|
+
store.define(cased(), makeComputed(() => evaluate()));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const obj = evaluate();
|
|
11
|
+
for (const k in obj) {
|
|
12
|
+
if (typeof obj[k] !== "function") throw error(`"${k}" must be a function`);
|
|
13
|
+
store.define(k, makeComputed(obj[k]));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
computed
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=computed.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/computed.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute, computed as makeComputed } from '../../core/index.js'\n\n/** `computed:name=\"expr\"` or `computed=\"{ name: () => expr }\"`. */\nexport const computed = attribute({\n name: 'computed',\n value: 'required',\n mount({ key, cased, evaluate, store, error }) {\n if (key) {\n store.define(cased(), makeComputed(() => evaluate()))\n return\n }\n const obj = evaluate()\n for (const k in obj) {\n if (typeof obj[k] !== 'function') throw error(`\"${k}\" must be a function`)\n store.define(k, makeComputed(obj[k]))\n }\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,oBAAoB;AAG7C,MAAM,WAAW,UAAU;AAAA,EAChC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,KAAK,OAAO,UAAU,OAAO,MAAM,GAAG;AAC5C,QAAI,KAAK;AACP,YAAM,OAAO,MAAM,GAAG,aAAa,MAAM,SAAS,CAAC,CAAC;AACpD;AAAA,IACF;AACA,UAAM,MAAM,SAAS;AACrB,eAAW,KAAK,KAAK;AACnB,UAAI,OAAO,IAAI,CAAC,MAAM,WAAY,OAAM,MAAM,IAAI,CAAC,sBAAsB;AACzE,YAAM,OAAO,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC;AAAA,IACtC;AAAA,EACF;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const customValidity = attribute({
|
|
3
|
+
name: "custom-validity",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
mount({ el, evaluate, effect, error }) {
|
|
7
|
+
if (!("setCustomValidity" in el)) throw error("only works on form fields");
|
|
8
|
+
effect(() => el.setCustomValidity(String(evaluate() ?? "")));
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
customValidity
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=customValidity.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/customValidity.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\n/** The expression's string becomes the field's validity message; '' means valid. */\nexport const customValidity = attribute({\n name: 'custom-validity',\n key: 'forbidden',\n value: 'required',\n mount({ el, evaluate, effect, error }) {\n if (!('setCustomValidity' in el)) throw error('only works on form fields')\n effect(() => (el as HTMLInputElement).setCustomValidity(String(evaluate() ?? '')))\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,iBAAiB,UAAU;AAAA,EACtC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,UAAU,QAAQ,MAAM,GAAG;AACrC,QAAI,EAAE,uBAAuB,IAAK,OAAM,MAAM,2BAA2B;AACzE,WAAO,MAAO,GAAwB,kBAAkB,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC;AAAA,EACnF;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const effect = attribute({
|
|
3
|
+
name: "effect",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
returns: false,
|
|
7
|
+
mount: (ctx) => ctx.effect(() => ctx.evaluate())
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
effect
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/effect.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\n/** Runs the expression now and whenever a signal it read changes. */\nexport const effect = attribute({\n name: 'effect',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount: (ctx) => ctx.effect(() => ctx.evaluate()),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,SAAS,UAAU;AAAA,EAC9B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO,CAAC,QAAQ,IAAI,OAAO,MAAM,IAAI,SAAS,CAAC;AACjD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const indicator = attribute({
|
|
3
|
+
name: "indicator",
|
|
4
|
+
mount({ el, key, value, cased, store, listen }) {
|
|
5
|
+
const path = key ? cased() : value.trim();
|
|
6
|
+
let active = 0;
|
|
7
|
+
store.set(path, false);
|
|
8
|
+
listen(document, "sigmx-fetch", (e) => {
|
|
9
|
+
if (e.detail.el !== el) return;
|
|
10
|
+
if (e.detail.type === "started") active++;
|
|
11
|
+
else if (e.detail.type === "finished") active = Math.max(0, active - 1);
|
|
12
|
+
store.set(path, active > 0);
|
|
13
|
+
});
|
|
14
|
+
return () => store.set(path, false);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
indicator
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=indicator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/indicator.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\n/** A boolean signal that is true while a request started from this element is in flight. */\nexport const indicator = attribute({\n name: 'indicator',\n mount({ el, key, value, cased, store, listen }) {\n const path = key ? cased() : value.trim()\n let active = 0\n store.set(path, false)\n listen(document, 'sigmx-fetch', (e: CustomEvent<{ el: Element; type: string }>) => {\n if (e.detail.el !== el) return\n if (e.detail.type === 'started') active++\n else if (e.detail.type === 'finished') active = Math.max(0, active - 1)\n store.set(path, active > 0)\n })\n return () => store.set(path, false)\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,YAAY,UAAU;AAAA,EACjC,MAAM;AAAA,EACN,MAAM,EAAE,IAAI,KAAK,OAAO,OAAO,OAAO,OAAO,GAAG;AAC9C,UAAM,OAAO,MAAM,MAAM,IAAI,MAAM,KAAK;AACxC,QAAI,SAAS;AACb,UAAM,IAAI,MAAM,KAAK;AACrB,WAAO,UAAU,eAAe,CAAC,MAAkD;AACjF,UAAI,EAAE,OAAO,OAAO,GAAI;AACxB,UAAI,EAAE,OAAO,SAAS,UAAW;AAAA,eACxB,EAAE,OAAO,SAAS,WAAY,UAAS,KAAK,IAAI,GAAG,SAAS,CAAC;AACtE,YAAM,IAAI,MAAM,SAAS,CAAC;AAAA,IAC5B,CAAC;AACD,WAAO,MAAM,MAAM,IAAI,MAAM,KAAK;AAAA,EACpC;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { attribute, withTiming, withViewTransition } from "../../core/index.js";
|
|
2
|
+
const init = attribute({
|
|
3
|
+
name: "init",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
returns: false,
|
|
7
|
+
mount({ mods, evaluate }) {
|
|
8
|
+
withTiming(withViewTransition(() => evaluate(), mods), mods)();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
init
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/init.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../core/index.js'\n\n/** Runs once when the element is mounted. Supports `__delay.500ms` and `__viewtransition`. */\nexport const init = attribute({\n name: 'init',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ mods, evaluate }) {\n withTiming(withViewTransition(() => evaluate(), mods), mods)()\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAGnD,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,MAAM,SAAS,GAAG;AACxB,eAAW,mBAAmB,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE;AAAA,EAC/D;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const jsonSignals = attribute({
|
|
3
|
+
name: "json-signals",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
mount({ el, value, mods, evaluate, effect, store }) {
|
|
6
|
+
const filter = value ? evaluate() : void 0;
|
|
7
|
+
effect(() => {
|
|
8
|
+
el.textContent = JSON.stringify(store.snapshot(filter), null, mods.has("terse") ? 0 : 2);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export {
|
|
13
|
+
jsonSignals
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=jsonSignals.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/jsonSignals.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\n/** Renders the store (or a filtered part) as JSON. `__terse` for single-line output. */\nexport const jsonSignals = attribute({\n name: 'json-signals',\n key: 'forbidden',\n mount({ el, value, mods, evaluate, effect, store }) {\n const filter = value ? evaluate() : undefined\n effect(() => {\n el.textContent = JSON.stringify(store.snapshot(filter), null, mods.has('terse') ? 0 : 2)\n })\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,cAAc,UAAU;AAAA,EACnC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM,EAAE,IAAI,OAAO,MAAM,UAAU,QAAQ,MAAM,GAAG;AAClD,UAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,WAAO,MAAM;AACX,SAAG,cAAc,KAAK,UAAU,MAAM,SAAS,MAAM,GAAG,MAAM,KAAK,IAAI,OAAO,IAAI,IAAI,CAAC;AAAA,IACzF,CAAC;AAAA,EACH;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { attribute } from "../../core/index.js";
|
|
2
|
+
const matchMedia = attribute({
|
|
3
|
+
name: "match-media",
|
|
4
|
+
key: "required",
|
|
5
|
+
value: "required",
|
|
6
|
+
mount({ cased, evaluate, store, listen }) {
|
|
7
|
+
let q = String(evaluate()).trim();
|
|
8
|
+
if (!/^[(a-z]/.test(q) || !q.startsWith("(") && q.includes(":") && !/^(not|only|all|screen|print)\b/.test(q)) q = `(${q})`;
|
|
9
|
+
const mql = window.matchMedia(q);
|
|
10
|
+
const path = cased();
|
|
11
|
+
const sync = () => store.set(path, mql.matches);
|
|
12
|
+
sync();
|
|
13
|
+
listen(mql, "change", sync);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
matchMedia
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=matchMedia.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/matchMedia.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../core/index.js'\n\n/** `match-media:is-dark=\"'prefers-color-scheme: dark'\"` keeps a boolean signal in sync. */\nexport const matchMedia = attribute({\n name: 'match-media',\n key: 'required',\n value: 'required',\n mount({ cased, evaluate, store, listen }) {\n let q = String(evaluate()).trim()\n if (!/^[(a-z]/.test(q) || (!q.startsWith('(') && q.includes(':') && !/^(not|only|all|screen|print)\\b/.test(q))) q = `(${q})`\n const mql = window.matchMedia(q)\n const path = cased()\n const sync = () => store.set(path, mql.matches)\n sync()\n listen(mql, 'change', sync)\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,aAAa,UAAU;AAAA,EAClC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,GAAG;AACxC,QAAI,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK;AAChC,QAAI,CAAC,UAAU,KAAK,CAAC,KAAM,CAAC,EAAE,WAAW,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,iCAAiC,KAAK,CAAC,EAAI,KAAI,IAAI,CAAC;AACzH,UAAM,MAAM,OAAO,WAAW,CAAC;AAC/B,UAAM,OAAO,MAAM;AACnB,UAAM,OAAO,MAAM,MAAM,IAAI,MAAM,IAAI,OAAO;AAC9C,SAAK;AACL,WAAO,KAAK,UAAU,IAAI;AAAA,EAC5B;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { attribute, withTiming, withViewTransition } from "../../core/index.js";
|
|
2
|
+
const on = attribute({
|
|
3
|
+
name: "on",
|
|
4
|
+
key: "required",
|
|
5
|
+
value: "required",
|
|
6
|
+
returns: false,
|
|
7
|
+
mount({ el, mods, cased, evaluate, listen }) {
|
|
8
|
+
const type = cased("kebab");
|
|
9
|
+
const outside = mods.has("outside");
|
|
10
|
+
const target = mods.has("window") ? window : mods.has("document") || outside || type.startsWith("sigmx-") ? document : el;
|
|
11
|
+
const run = withTiming(withViewTransition((e) => evaluate(e), mods), mods);
|
|
12
|
+
listen(
|
|
13
|
+
target,
|
|
14
|
+
type,
|
|
15
|
+
(e) => {
|
|
16
|
+
if (outside && el.contains(e.target)) return;
|
|
17
|
+
if (mods.has("prevent") || type === "submit" && el instanceof HTMLFormElement) e.preventDefault();
|
|
18
|
+
if (mods.has("stop")) e.stopPropagation();
|
|
19
|
+
run(e);
|
|
20
|
+
},
|
|
21
|
+
{ capture: mods.has("capture"), passive: mods.has("passive"), once: mods.has("once") }
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
export {
|
|
26
|
+
on
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=on.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/on.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../core/index.js'\n\n/**\n * `on:click=\"expr\"`. Modifiers: window, document, outside, prevent, stop, capture, passive, once,\n * delay/debounce/throttle, viewtransition, case.\n */\nexport const on = attribute({\n name: 'on',\n key: 'required',\n value: 'required',\n returns: false,\n mount({ el, mods, cased, evaluate, listen }) {\n const type = cased('kebab')\n const outside = mods.has('outside')\n const target: EventTarget =\n mods.has('window') ? window : mods.has('document') || outside || type.startsWith('sigmx-') ? document : el\n const run = withTiming(withViewTransition((e: Event) => evaluate(e), mods), mods)\n listen(\n target,\n type,\n (e: Event) => {\n if (outside && el.contains(e.target as Node)) return\n if (mods.has('prevent') || (type === 'submit' && el instanceof HTMLFormElement)) e.preventDefault()\n if (mods.has('stop')) e.stopPropagation()\n run(e)\n },\n { capture: mods.has('capture'), passive: mods.has('passive'), once: mods.has('once') },\n )\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAMnD,MAAM,KAAK,UAAU;AAAA,EAC1B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,IAAI,MAAM,OAAO,UAAU,OAAO,GAAG;AAC3C,UAAM,OAAO,MAAM,OAAO;AAC1B,UAAM,UAAU,KAAK,IAAI,SAAS;AAClC,UAAM,SACJ,KAAK,IAAI,QAAQ,IAAI,SAAS,KAAK,IAAI,UAAU,KAAK,WAAW,KAAK,WAAW,QAAQ,IAAI,WAAW;AAC1G,UAAM,MAAM,WAAW,mBAAmB,CAAC,MAAa,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI;AAChF;AAAA,MACE;AAAA,MACA;AAAA,MACA,CAAC,MAAa;AACZ,YAAI,WAAW,GAAG,SAAS,EAAE,MAAc,EAAG;AAC9C,YAAI,KAAK,IAAI,SAAS,KAAM,SAAS,YAAY,cAAc,gBAAkB,GAAE,eAAe;AAClG,YAAI,KAAK,IAAI,MAAM,EAAG,GAAE,gBAAgB;AACxC,YAAI,CAAC;AAAA,MACP;AAAA,MACA,EAAE,SAAS,KAAK,IAAI,SAAS,GAAG,SAAS,KAAK,IAAI,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,EAAE;AAAA,IACvF;AAAA,EACF;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { attribute, withTiming, withViewTransition } from "../../core/index.js";
|
|
2
|
+
const onIntersect = attribute({
|
|
3
|
+
name: "on-intersect",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
returns: false,
|
|
7
|
+
mount({ el, mods, evaluate }) {
|
|
8
|
+
const t = mods.get("threshold")?.[0];
|
|
9
|
+
const threshold = mods.has("full") ? 1 : mods.has("half") ? 0.5 : t ? Math.min(100, Math.max(0, +t)) / 100 : 0;
|
|
10
|
+
const run = withTiming(withViewTransition(() => evaluate(), mods), mods);
|
|
11
|
+
const io = new IntersectionObserver(
|
|
12
|
+
(entries) => {
|
|
13
|
+
for (const e of entries) {
|
|
14
|
+
if (e.isIntersecting === mods.has("exit")) continue;
|
|
15
|
+
run();
|
|
16
|
+
if (mods.has("once")) io.disconnect();
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{ threshold }
|
|
20
|
+
);
|
|
21
|
+
io.observe(el);
|
|
22
|
+
return () => io.disconnect();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
export {
|
|
26
|
+
onIntersect
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=onIntersect.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/attributes/onIntersect.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../core/index.js'\n\n/** Runs when the element enters the viewport. Modifiers: once, exit, full, half, threshold.N. */\nexport const onIntersect = attribute({\n name: 'on-intersect',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ el, mods, evaluate }) {\n const t = mods.get('threshold')?.[0]\n const threshold = mods.has('full') ? 1 : mods.has('half') ? 0.5 : t ? Math.min(100, Math.max(0, +t)) / 100 : 0\n const run = withTiming(withViewTransition(() => evaluate(), mods), mods)\n const io = new IntersectionObserver(\n (entries) => {\n for (const e of entries) {\n if (e.isIntersecting === mods.has('exit')) continue\n run()\n if (mods.has('once')) io.disconnect()\n }\n },\n { threshold },\n )\n io.observe(el)\n return () => io.disconnect()\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAGnD,MAAM,cAAc,UAAU;AAAA,EACnC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,IAAI,MAAM,SAAS,GAAG;AAC5B,UAAM,IAAI,KAAK,IAAI,WAAW,IAAI,CAAC;AACnC,UAAM,YAAY,KAAK,IAAI,MAAM,IAAI,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM;AAC7G,UAAM,MAAM,WAAW,mBAAmB,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI;AACvE,UAAM,KAAK,IAAI;AAAA,MACb,CAAC,YAAY;AACX,mBAAW,KAAK,SAAS;AACvB,cAAI,EAAE,mBAAmB,KAAK,IAAI,MAAM,EAAG;AAC3C,cAAI;AACJ,cAAI,KAAK,IAAI,MAAM,EAAG,IAAG,WAAW;AAAA,QACtC;AAAA,MACF;AAAA,MACA,EAAE,UAAU;AAAA,IACd;AACA,OAAG,QAAQ,EAAE;AACb,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|