@splendidlabz/utils 1.11.3 → 1.11.5
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/cjs/dom/accessibility.cjs +53 -0
- package/dist/cjs/dom/actions/index.cjs +410 -0
- package/dist/cjs/dom/actions/masonry.cjs +152 -0
- package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +157 -0
- package/dist/cjs/dom/actions/sticky.cjs +213 -0
- package/dist/cjs/dom/bounding-box.cjs +70 -0
- package/dist/cjs/dom/clipboard.cjs +37 -0
- package/dist/cjs/dom/cookie.cjs +57 -0
- package/dist/cjs/dom/css-vars.cjs +57 -0
- package/dist/cjs/dom/events.cjs +59 -0
- package/{src/dom/focusable.js → dist/cjs/dom/focusable.cjs} +51 -73
- package/dist/cjs/dom/font-size.cjs +80 -0
- package/dist/cjs/dom/get-element.cjs +98 -0
- package/dist/cjs/dom/hash.cjs +35 -0
- package/dist/cjs/dom/index.cjs +1267 -0
- package/dist/cjs/dom/keyboard.cjs +51 -0
- package/dist/cjs/dom/local-store.cjs +79 -0
- package/dist/cjs/dom/media.cjs +59 -0
- package/dist/cjs/dom/observers/index.cjs +253 -0
- package/dist/cjs/dom/observers/intersection-observer.cjs +91 -0
- package/dist/cjs/dom/observers/mutation-observer.cjs +95 -0
- package/dist/cjs/dom/observers/observer.cjs +48 -0
- package/dist/cjs/dom/observers/resize-observer.cjs +84 -0
- package/dist/cjs/dom/observers/scroll-observer.cjs +177 -0
- package/dist/cjs/dom/pkce.cjs +53 -0
- package/dist/cjs/dom/query-params.cjs +38 -0
- package/dist/cjs/dom/random-string.cjs +38 -0
- package/dist/cjs/dom/sanitize.cjs +65 -0
- package/dist/cjs/dom/session-store.cjs +49 -0
- package/dist/cjs/dom/spam-prevention.cjs +50 -0
- package/dist/cjs/dom/trap-focus.cjs +197 -0
- package/dist/cjs/dom/ui/aria-current.cjs +43 -0
- package/dist/cjs/dom/ui/inconsistent-button-fix.cjs +35 -0
- package/dist/cjs/dom/ui/index.cjs +105 -0
- package/dist/cjs/dom/ui/scroll-container.cjs +47 -0
- package/dist/cjs/dom/ui/traverse-and-scramble.cjs +50 -0
- package/dist/cjs/lib/arrays/index.cjs +139 -0
- package/dist/cjs/lib/arrays/item-position.cjs +42 -0
- package/dist/cjs/lib/arrays/join.cjs +43 -0
- package/dist/cjs/lib/arrays/shuffle.cjs +42 -0
- package/dist/cjs/lib/arrays/sort.cjs +67 -0
- package/dist/cjs/lib/arrays/split-array.cjs +41 -0
- package/dist/cjs/lib/arrays/unique.cjs +31 -0
- package/dist/cjs/lib/auth/index.cjs +53 -0
- package/dist/cjs/lib/auth/route-manager.cjs +51 -0
- package/dist/cjs/lib/checks.cjs +63 -0
- package/dist/cjs/lib/date/days.cjs +37 -0
- package/dist/cjs/lib/date/index.cjs +208 -0
- package/dist/cjs/lib/date/months.cjs +102 -0
- package/dist/cjs/lib/date/time.cjs +117 -0
- package/dist/cjs/lib/form/form-data.cjs +83 -0
- package/dist/cjs/lib/form/index.cjs +122 -0
- package/dist/cjs/lib/form/sanitize.cjs +61 -0
- package/dist/cjs/lib/functions/callback.cjs +31 -0
- package/dist/cjs/lib/functions/debounce.cjs +43 -0
- package/dist/cjs/lib/functions/env.cjs +32 -0
- package/dist/cjs/lib/functions/functional.cjs +82 -0
- package/dist/cjs/lib/functions/index.cjs +142 -0
- package/dist/cjs/lib/functions/throttle.cjs +38 -0
- package/dist/cjs/lib/functions/timeout.cjs +41 -0
- package/dist/cjs/lib/hash.cjs +43 -0
- package/dist/cjs/lib/index.cjs +1178 -0
- package/dist/cjs/lib/numbers/index.cjs +49 -0
- package/dist/cjs/lib/numbers/math.cjs +36 -0
- package/dist/cjs/lib/objects/camelcase-keys.cjs +80 -0
- package/dist/cjs/lib/objects/empty.cjs +39 -0
- package/dist/cjs/lib/objects/equal.cjs +47 -0
- package/dist/cjs/lib/objects/extend.cjs +147 -0
- package/dist/cjs/lib/objects/flatten.cjs +48 -0
- package/dist/cjs/lib/objects/index.cjs +378 -0
- package/dist/cjs/lib/objects/json.cjs +35 -0
- package/dist/cjs/lib/objects/loop.cjs +40 -0
- package/dist/cjs/lib/objects/mix/mix.cjs +115 -0
- package/dist/cjs/lib/objects/nested-property.cjs +45 -0
- package/dist/cjs/lib/objects/normalize-object.cjs +106 -0
- package/dist/cjs/lib/objects/omit-empty.cjs +40 -0
- package/dist/cjs/lib/objects/size.cjs +63 -0
- package/dist/cjs/lib/objects/split.cjs +39 -0
- package/dist/cjs/lib/promises/index.cjs +69 -0
- package/dist/cjs/lib/promises/reject.cjs +67 -0
- package/dist/cjs/lib/sse.cjs +99 -0
- package/dist/cjs/lib/strings/convert-case/convert-case.cjs +96 -0
- package/dist/cjs/lib/strings/index.cjs +197 -0
- package/dist/cjs/lib/strings/markdown.cjs +76 -0
- package/dist/cjs/lib/strings/name.cjs +46 -0
- package/dist/cjs/lib/strings/pluralize.cjs +40 -0
- package/dist/cjs/lib/strings/query-string.cjs +43 -0
- package/dist/cjs/lib/style/index.cjs +64 -0
- package/dist/cjs/lib/symbols/index.cjs +40 -0
- package/dist/cjs/lib/symbols/symbols.cjs +38 -0
- package/dist/cjs/node/dirname.cjs +49 -0
- package/dist/cjs/node/file-cache.cjs +200 -0
- package/dist/cjs/node/file.cjs +50 -0
- package/dist/cjs/node/hash.cjs +42 -0
- package/dist/cjs/node/index.cjs +296 -0
- package/dist/cjs/node/pkce.cjs +64 -0
- package/dist/cjs/node/random-string.cjs +43 -0
- package/dist/cjs/node/sanitize.cjs +65 -0
- package/dist/cjs/node/uuid.cjs +42 -0
- package/dist/esm/dom/accessibility.js +26 -0
- package/dist/esm/dom/actions/index.js +3 -0
- package/dist/esm/dom/actions/masonry.js +38 -0
- package/dist/esm/dom/actions/prefer-horizontal-scroll.js +90 -0
- package/dist/esm/dom/actions/sticky.js +70 -0
- package/dist/esm/dom/bounding-box.js +44 -0
- package/dist/esm/dom/clipboard.js +12 -0
- package/dist/esm/dom/cookie.js +31 -0
- package/dist/esm/dom/css-vars.js +21 -0
- package/dist/esm/dom/events.js +31 -0
- package/dist/esm/dom/focusable.js +117 -0
- package/dist/esm/dom/font-size.js +40 -0
- package/dist/esm/dom/get-element.js +66 -0
- package/dist/esm/dom/hash.js +10 -0
- package/dist/esm/dom/index.js +23 -0
- package/dist/esm/dom/keyboard.js +22 -0
- package/{src → dist/esm}/dom/local-store.js +16 -28
- package/dist/esm/dom/media.js +32 -0
- package/dist/esm/dom/observers/index.js +4 -0
- package/dist/esm/dom/observers/intersection-observer.js +36 -0
- package/dist/esm/dom/observers/mutation-observer.js +40 -0
- package/dist/esm/dom/observers/observer.js +15 -0
- package/dist/esm/dom/observers/resize-observer.js +29 -0
- package/dist/esm/dom/observers/scroll-observer.js +95 -0
- package/dist/esm/dom/pkce.js +20 -0
- package/dist/esm/dom/query-params.js +13 -0
- package/dist/esm/dom/random-string.js +12 -0
- package/dist/esm/dom/sanitize.js +8 -0
- package/dist/esm/dom/session-store.js +24 -0
- package/dist/esm/dom/spam-prevention.js +25 -0
- package/dist/esm/dom/trap-focus.js +51 -0
- package/dist/esm/dom/ui/aria-current.js +17 -0
- package/dist/esm/dom/ui/inconsistent-button-fix.js +10 -0
- package/dist/esm/dom/ui/index.js +4 -0
- package/dist/esm/dom/ui/scroll-container.js +22 -0
- package/dist/esm/dom/ui/traverse-and-scramble.js +25 -0
- package/dist/esm/lib/arrays/index.js +6 -0
- package/dist/esm/lib/arrays/item-position.js +15 -0
- package/dist/esm/lib/arrays/join.js +12 -0
- package/dist/esm/lib/arrays/shuffle.js +17 -0
- package/dist/esm/lib/arrays/sort.js +36 -0
- package/dist/esm/lib/arrays/split-array.js +16 -0
- package/dist/esm/lib/arrays/unique.js +6 -0
- package/dist/esm/lib/auth/index.js +1 -0
- package/dist/esm/lib/auth/route-manager.js +25 -0
- package/dist/esm/lib/checks.js +34 -0
- package/dist/esm/lib/date/days.js +12 -0
- package/dist/esm/lib/date/index.js +3 -0
- package/dist/esm/lib/date/months.js +77 -0
- package/dist/esm/lib/date/time.js +75 -0
- package/dist/esm/lib/form/form-data.js +57 -0
- package/dist/esm/lib/form/index.js +2 -0
- package/dist/esm/lib/form/sanitize.js +34 -0
- package/dist/esm/lib/functions/callback.js +6 -0
- package/dist/esm/lib/functions/debounce.js +18 -0
- package/dist/esm/lib/functions/env.js +7 -0
- package/dist/esm/lib/functions/functional.js +52 -0
- package/dist/esm/lib/functions/index.js +5 -0
- package/dist/esm/lib/functions/throttle.js +13 -0
- package/dist/esm/lib/functions/timeout.js +14 -0
- package/dist/esm/lib/hash.js +18 -0
- package/dist/esm/lib/index.js +14 -0
- package/dist/esm/lib/numbers/index.js +11 -0
- package/dist/esm/lib/numbers/math.js +10 -0
- package/dist/esm/lib/objects/camelcase-keys.js +16 -0
- package/dist/esm/lib/objects/empty.js +13 -0
- package/dist/esm/lib/objects/equal.js +11 -0
- package/dist/esm/lib/objects/extend.js +13 -0
- package/dist/esm/lib/objects/flatten.js +17 -0
- package/dist/esm/lib/objects/index.js +13 -0
- package/dist/esm/lib/objects/json.js +10 -0
- package/dist/esm/lib/objects/loop.js +14 -0
- package/dist/esm/lib/objects/mix/mix.js +88 -0
- package/dist/esm/lib/objects/nested-property.js +18 -0
- package/dist/esm/lib/objects/normalize-object.js +9 -0
- package/dist/esm/lib/objects/omit-empty.js +15 -0
- package/dist/esm/lib/objects/size.js +38 -0
- package/dist/esm/lib/objects/split.js +14 -0
- package/dist/esm/lib/promises/index.js +1 -0
- package/dist/esm/lib/promises/reject.js +17 -0
- package/dist/esm/lib/sse.js +50 -0
- package/dist/esm/lib/strings/convert-case/convert-case.js +64 -0
- package/dist/esm/lib/strings/index.js +5 -0
- package/dist/esm/lib/strings/markdown.js +40 -0
- package/dist/esm/lib/strings/name.js +21 -0
- package/dist/esm/lib/strings/pluralize.js +5 -0
- package/dist/esm/lib/strings/query-string.js +16 -0
- package/dist/esm/lib/style/index.js +12 -0
- package/dist/esm/lib/symbols/index.js +1 -0
- package/dist/esm/lib/symbols/symbols.js +12 -0
- package/dist/esm/node/context.js +0 -0
- package/dist/esm/node/dirname.js +13 -0
- package/dist/esm/node/file-cache.js +121 -0
- package/dist/esm/node/file.js +14 -0
- package/dist/esm/node/hash.js +7 -0
- package/dist/esm/node/index.js +7 -0
- package/dist/esm/node/pkce.js +20 -0
- package/dist/esm/node/random-string.js +8 -0
- package/dist/esm/node/sanitize.js +8 -0
- package/dist/esm/node/uuid.js +7 -0
- package/dist/types/dom/accessibility.d.cts +30 -0
- package/dist/types/dom/actions/index.d.cts +3 -0
- package/dist/types/dom/actions/masonry.d.cts +5 -0
- package/dist/types/dom/actions/prefer-horizontal-scroll.d.cts +5 -0
- package/dist/types/dom/actions/sticky.d.cts +5 -0
- package/{src/dom/bounding-box.js → dist/types/dom/bounding-box.d.cts} +8 -49
- package/dist/types/dom/clipboard.d.cts +7 -0
- package/dist/types/dom/cookie.d.cts +7 -0
- package/dist/types/dom/css-vars.d.cts +6 -0
- package/{src/dom/events.js → dist/types/dom/events.d.cts} +52 -31
- package/dist/types/dom/focusable.d.cts +78 -0
- package/dist/types/dom/font-size.d.cts +8 -0
- package/{src/dom/get-element.js → dist/types/dom/get-element.d.cts} +25 -99
- package/dist/types/dom/hash.d.cts +3 -0
- package/dist/types/dom/index.d.cts +31 -0
- package/{src/dom/keyboard.js → dist/types/dom/keyboard.d.cts} +7 -19
- package/dist/types/dom/local-store.d.cts +31 -0
- package/dist/types/dom/media.d.cts +5 -0
- package/dist/types/dom/observers/index.d.cts +4 -0
- package/dist/types/dom/observers/intersection-observer.d.cts +10 -0
- package/dist/types/dom/observers/mutation-observer.d.cts +9 -0
- package/dist/types/dom/observers/observer.d.cts +3 -0
- package/{src/dom/observers/resize-observer.js → dist/types/dom/observers/resize-observer.d.cts} +6 -32
- package/dist/types/dom/observers/scroll-observer.d.cts +40 -0
- package/dist/types/dom/pkce.d.cts +8 -0
- package/dist/types/dom/query-params.d.cts +6 -0
- package/dist/types/dom/random-string.d.cts +9 -0
- package/dist/types/dom/sanitize.d.cts +10 -0
- package/dist/types/dom/session-store.d.cts +7 -0
- package/dist/types/dom/spam-prevention.d.cts +14 -0
- package/dist/types/dom/trap-focus.d.cts +32 -0
- package/dist/types/dom/ui/aria-current.d.cts +7 -0
- package/{src/dom/ui/inconsistent-button-fix.js → dist/types/dom/ui/inconsistent-button-fix.d.cts} +5 -11
- package/dist/types/dom/ui/index.d.cts +4 -0
- package/dist/types/dom/ui/scroll-container.d.cts +3 -0
- package/dist/types/dom/ui/traverse-and-scramble.d.cts +21 -0
- package/dist/types/lib/arrays/index.d.cts +6 -0
- package/{src/lib/arrays/item-position.js → dist/types/lib/arrays/item-position.d.cts} +5 -12
- package/{src/lib/arrays/join.js → dist/types/lib/arrays/join.d.cts} +4 -9
- package/dist/types/lib/arrays/shuffle.d.cts +3 -0
- package/dist/types/lib/arrays/sort.d.cts +32 -0
- package/dist/types/lib/arrays/split-array.d.cts +6 -0
- package/dist/types/lib/arrays/unique.d.cts +3 -0
- package/dist/types/lib/auth/index.d.cts +1 -0
- package/dist/types/lib/auth/route-manager.d.cts +28 -0
- package/dist/types/lib/checks.d.cts +33 -0
- package/dist/types/lib/date/days.d.cts +7 -0
- package/dist/types/lib/date/index.d.cts +3 -0
- package/dist/types/lib/date/months.d.cts +11 -0
- package/dist/types/lib/date/time.d.cts +21 -0
- package/dist/types/lib/form/form-data.d.cts +9 -0
- package/dist/types/lib/form/index.d.cts +2 -0
- package/{src/lib/form/sanitize.js → dist/types/lib/form/sanitize.d.cts} +19 -39
- package/{src/lib/functions/callback.js → dist/types/lib/functions/callback.d.cts} +3 -3
- package/dist/types/lib/functions/debounce.d.cts +3 -0
- package/dist/types/lib/functions/env.d.cts +3 -0
- package/{src/lib/functions/functional.js → dist/types/lib/functions/functional.d.cts} +8 -49
- package/dist/types/lib/functions/index.d.cts +5 -0
- package/dist/types/lib/functions/throttle.d.cts +3 -0
- package/dist/types/lib/functions/timeout.d.cts +5 -0
- package/dist/types/lib/hash.d.cts +3 -0
- package/dist/types/lib/index.d.cts +43 -0
- package/dist/types/lib/numbers/index.d.cts +5 -0
- package/dist/types/lib/numbers/math.d.cts +4 -0
- package/dist/types/lib/objects/camelcase-keys.d.cts +3 -0
- package/dist/types/lib/objects/empty.d.cts +4 -0
- package/dist/types/lib/objects/equal.d.cts +4 -0
- package/dist/types/lib/objects/extend.d.cts +6 -0
- package/dist/types/lib/objects/flatten.d.cts +6 -0
- package/dist/types/lib/objects/index.d.cts +13 -0
- package/dist/types/lib/objects/json.d.cts +3 -0
- package/dist/types/lib/objects/loop.d.cts +4 -0
- package/dist/types/lib/objects/mix/mix.d.cts +44 -0
- package/{src/lib/objects/nested-property.js → dist/types/lib/objects/nested-property.d.cts} +4 -21
- package/dist/types/lib/objects/normalize-object.d.cts +3 -0
- package/dist/types/lib/objects/omit-empty.d.cts +3 -0
- package/dist/types/lib/objects/size.d.cts +3 -0
- package/dist/types/lib/objects/split.d.cts +14 -0
- package/dist/types/lib/promises/index.d.cts +1 -0
- package/dist/types/lib/promises/reject.d.cts +5 -0
- package/dist/types/lib/sse.d.cts +18 -0
- package/dist/types/lib/strings/convert-case/convert-case.d.cts +10 -0
- package/dist/types/lib/strings/index.d.cts +5 -0
- package/dist/types/lib/strings/markdown.d.cts +25 -0
- package/dist/types/lib/strings/name.d.cts +7 -0
- package/dist/types/lib/strings/pluralize.d.cts +3 -0
- package/dist/types/lib/strings/query-string.d.cts +10 -0
- package/dist/types/lib/style/index.d.cts +3 -0
- package/dist/types/lib/symbols/index.d.cts +1 -0
- package/dist/types/lib/symbols/symbols.d.cts +4 -0
- package/dist/types/node/context.d.cts +2 -0
- package/dist/types/node/dirname.d.cts +9 -0
- package/dist/types/node/file-cache.d.cts +56 -0
- package/dist/types/node/file.d.cts +4 -0
- package/dist/types/node/hash.d.cts +3 -0
- package/dist/types/node/index.d.cts +7 -0
- package/dist/types/node/pkce.d.cts +14 -0
- package/dist/types/node/random-string.d.cts +3 -0
- package/{src/node/sanitize.js → dist/types/node/sanitize.d.cts} +3 -6
- package/dist/types/node/uuid.d.cts +3 -0
- package/package.json +18 -15
- package/CHANGELOG.md +0 -237
- package/eslint.config.js +0 -2
- package/src/dom/accessibility.js +0 -58
- package/src/dom/actions/index.js +0 -3
- package/src/dom/actions/masonry.js +0 -43
- package/src/dom/actions/prefer-horizontal-scroll.js +0 -121
- package/src/dom/actions/sticky.js +0 -85
- package/src/dom/clipboard.js +0 -14
- package/src/dom/cookie.js +0 -32
- package/src/dom/css-vars.js +0 -19
- package/src/dom/font-size.js +0 -40
- package/src/dom/hash.js +0 -9
- package/src/dom/index.js +0 -23
- package/src/dom/media.js +0 -30
- package/src/dom/observers/index.js +0 -4
- package/src/dom/observers/intersection-observer.js +0 -43
- package/src/dom/observers/mutation-observer.js +0 -51
- package/src/dom/observers/observer.js +0 -18
- package/src/dom/observers/scroll-observer.js +0 -146
- package/src/dom/pkce.js +0 -34
- package/src/dom/query-params.js +0 -14
- package/src/dom/random-string.js +0 -18
- package/src/dom/random-string.test.js +0 -13
- package/src/dom/sanitize.js +0 -16
- package/src/dom/session-store.js +0 -29
- package/src/dom/spam-prevention.js +0 -40
- package/src/dom/trap-focus.js +0 -70
- package/src/dom/ui/aria-current.js +0 -20
- package/src/dom/ui/index.js +0 -4
- package/src/dom/ui/scroll-container.js +0 -25
- package/src/dom/ui/traverse-and-scramble.js +0 -61
- package/src/lib/arrays/index.js +0 -6
- package/src/lib/arrays/shuffle.js +0 -21
- package/src/lib/arrays/sort.js +0 -88
- package/src/lib/arrays/sort.spec.js +0 -123
- package/src/lib/arrays/split-array.js +0 -15
- package/src/lib/arrays/unique.js +0 -3
- package/src/lib/auth/index.js +0 -1
- package/src/lib/auth/route-manager.js +0 -45
- package/src/lib/checks.js +0 -57
- package/src/lib/date/days.js +0 -9
- package/src/lib/date/index.js +0 -3
- package/src/lib/date/months.js +0 -74
- package/src/lib/date/time.js +0 -83
- package/src/lib/form/form-data.js +0 -73
- package/src/lib/form/index.js +0 -2
- package/src/lib/form/sanitize.spec.js +0 -126
- package/src/lib/functions/debounce.js +0 -18
- package/src/lib/functions/env.js +0 -5
- package/src/lib/functions/functional.test.js +0 -196
- package/src/lib/functions/index.js +0 -5
- package/src/lib/functions/throttle.js +0 -11
- package/src/lib/functions/timeout.js +0 -15
- package/src/lib/hash.js +0 -18
- package/src/lib/hash.spec.js +0 -163
- package/src/lib/index.js +0 -14
- package/src/lib/numbers/index.js +0 -12
- package/src/lib/numbers/math.js +0 -9
- package/src/lib/numbers/split-unit.test.js +0 -45
- package/src/lib/objects/camelcase-keys.js +0 -17
- package/src/lib/objects/camelcase-keys.test.js +0 -72
- package/src/lib/objects/empty.js +0 -10
- package/src/lib/objects/equal.js +0 -9
- package/src/lib/objects/extend.js +0 -16
- package/src/lib/objects/extend.test.js +0 -35
- package/src/lib/objects/flatten.js +0 -19
- package/src/lib/objects/index.js +0 -13
- package/src/lib/objects/json.js +0 -7
- package/src/lib/objects/loop.js +0 -11
- package/src/lib/objects/loop.test.js +0 -31
- package/src/lib/objects/mix/mix.js +0 -191
- package/src/lib/objects/mix/mix.md +0 -78
- package/src/lib/objects/mix/mix.test.js +0 -445
- package/src/lib/objects/normalize-object.js +0 -10
- package/src/lib/objects/omit-empty.js +0 -23
- package/src/lib/objects/omit-empty.test.js +0 -85
- package/src/lib/objects/size.js +0 -41
- package/src/lib/objects/split.js +0 -19
- package/src/lib/promises/index.js +0 -1
- package/src/lib/promises/reject.js +0 -17
- package/src/lib/sse.js +0 -61
- package/src/lib/strings/convert-case/convert-case.js +0 -86
- package/src/lib/strings/convert-case/convert-case.md +0 -44
- package/src/lib/strings/convert-case/convert-case.test.js +0 -50
- package/src/lib/strings/index.js +0 -5
- package/src/lib/strings/markdown.js +0 -71
- package/src/lib/strings/markdown.spec.js +0 -73
- package/src/lib/strings/name.js +0 -24
- package/src/lib/strings/name.test.js +0 -67
- package/src/lib/strings/pluralize.js +0 -2
- package/src/lib/strings/query-string.js +0 -18
- package/src/lib/style/index.js +0 -13
- package/src/lib/symbols/index.js +0 -1
- package/src/lib/symbols/symbols.js +0 -9
- package/src/node/dirname.js +0 -17
- package/src/node/file-cache.js +0 -184
- package/src/node/file.js +0 -13
- package/src/node/hash.js +0 -5
- package/src/node/index.js +0 -7
- package/src/node/pkce.js +0 -33
- package/src/node/random-string.js +0 -10
- package/src/node/random-string.test.js +0 -15
- package/src/node/sanitize.spec.js +0 -142
- package/src/node/uuid.js +0 -5
- package/tsconfig.json +0 -23
- package/tsup.config.js +0 -38
- package/tsup.config.mjs +0 -63
- /package/{src/node/context.js → dist/cjs/node/context.cjs} +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/node/sanitize.js
|
|
30
|
+
var sanitize_exports = {};
|
|
31
|
+
__export(sanitize_exports, {
|
|
32
|
+
sanitize: () => sanitize2
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(sanitize_exports);
|
|
35
|
+
var import_sanitize_html = __toESM(require("sanitize-html"), 1);
|
|
36
|
+
|
|
37
|
+
// src/lib/form/sanitize.js
|
|
38
|
+
function sanitize(value, options = {}) {
|
|
39
|
+
const { sanitizer, ...rest } = options;
|
|
40
|
+
if (!sanitizer) throw new Error("sanitizer function is required");
|
|
41
|
+
if (typeof value === "string") return sanitizer(value, rest);
|
|
42
|
+
if (Array.isArray(value)) return sanitizeArray(value, { sanitizer, ...rest });
|
|
43
|
+
if (value && typeof value === "object") {
|
|
44
|
+
return Object.fromEntries(
|
|
45
|
+
Object.entries(value).map(([key, val]) => [
|
|
46
|
+
key,
|
|
47
|
+
sanitize(val, { sanitizer, ...rest })
|
|
48
|
+
])
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
function sanitizeArray(arr, { sanitizer, ...rest }) {
|
|
54
|
+
if (!sanitizer) throw new Error("sanitizer function is required");
|
|
55
|
+
return arr.map((item) => sanitize(item, { sanitizer, ...rest }));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/node/sanitize.js
|
|
59
|
+
function sanitize2(value, options = {}) {
|
|
60
|
+
return sanitize(value, { sanitizer: import_sanitize_html.default, ...options });
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
sanitize
|
|
65
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/node/uuid.js
|
|
30
|
+
var uuid_exports = {};
|
|
31
|
+
__export(uuid_exports, {
|
|
32
|
+
uuid: () => uuid
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(uuid_exports);
|
|
35
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
36
|
+
function uuid() {
|
|
37
|
+
return import_crypto.default.randomUUID();
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
uuid
|
|
42
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function hasAccessibleName(label, labelledBy) {
|
|
2
|
+
if (label || labelledBy) return true;
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
function checkForAccessibleName({
|
|
6
|
+
name,
|
|
7
|
+
ariaLabel,
|
|
8
|
+
ariaLabelledBy,
|
|
9
|
+
severity = "warn"
|
|
10
|
+
} = {}) {
|
|
11
|
+
if (ariaLabel || ariaLabelledBy) return true;
|
|
12
|
+
const message = `${name} is missing an accessible name. Please provide an accessible name with 'aria-label' or 'aria-labelledby'.`;
|
|
13
|
+
if (severity === "warn") console.warn(message);
|
|
14
|
+
if (severity === "error") console.error(message);
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
function isInvalidAriaPopup(value) {
|
|
18
|
+
const allowedPopoupValues = ["dialog", "menu", "listbox", "grid", "tree"];
|
|
19
|
+
if (!allowedPopoupValues.includes(value)) return true;
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
checkForAccessibleName,
|
|
24
|
+
hasAccessibleName,
|
|
25
|
+
isInvalidAriaPopup
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getChildrenElements } from "../get-element.js";
|
|
2
|
+
import { mediaLoaded } from "../media.js";
|
|
3
|
+
import { resizeObserver } from "../observers/resize-observer.js";
|
|
4
|
+
async function masonry(node) {
|
|
5
|
+
if (nativeMasonrySupport(node)) return;
|
|
6
|
+
const colGap = parseFloat(getComputedStyle(node).columnGap);
|
|
7
|
+
const items = getChildrenElements(node);
|
|
8
|
+
node.style.setProperty("row-gap", "1px", "important");
|
|
9
|
+
node.style.gridAutoRows = "0px";
|
|
10
|
+
node.updateMasonryLayout = (_) => layout({ colGap, items });
|
|
11
|
+
try {
|
|
12
|
+
await mediaLoaded(node);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
}
|
|
15
|
+
layout({ colGap, items });
|
|
16
|
+
const obs = resizeObserver(node, {
|
|
17
|
+
async callback(opts) {
|
|
18
|
+
layout({ colGap, items });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
async function layout({ colGap: colGap2, items: items2 }) {
|
|
22
|
+
items2.forEach((item) => {
|
|
23
|
+
const ib = item.getBoundingClientRect();
|
|
24
|
+
item.style.gridRowEnd = `span ${Math.round(ib.height + colGap2)}`;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
destroy() {
|
|
29
|
+
obs.disconnect();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function nativeMasonrySupport(node) {
|
|
34
|
+
return getComputedStyle(node).gridTemplateRows === "masonry";
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
masonry
|
|
38
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { omitEmpty } from "../../lib/objects/omit-empty.js";
|
|
2
|
+
import { getCSSVar, setCSSVar } from "../css-vars.js";
|
|
3
|
+
import { addListeners, removeListeners } from "../events.js";
|
|
4
|
+
const DEFAULT_OPTIONS = {
|
|
5
|
+
scrollSnapDelay: 1e3
|
|
6
|
+
};
|
|
7
|
+
function preferHorizontalScroll(node, props = {}) {
|
|
8
|
+
if (!node.classList.contains("scrollable-prefer-horizontal")) return;
|
|
9
|
+
const state = {
|
|
10
|
+
origSnapType: null,
|
|
11
|
+
currentSnapType: null,
|
|
12
|
+
snapTimeoutID: null
|
|
13
|
+
};
|
|
14
|
+
const options = {
|
|
15
|
+
...DEFAULT_OPTIONS,
|
|
16
|
+
...omitEmpty({
|
|
17
|
+
scrollSnapDelay: getCSSVar(node, "--scroll-snap-delay")
|
|
18
|
+
}),
|
|
19
|
+
...omitEmpty(props)
|
|
20
|
+
};
|
|
21
|
+
const listeners = [
|
|
22
|
+
{
|
|
23
|
+
event: "wheel",
|
|
24
|
+
node,
|
|
25
|
+
handler: handleWheel
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
event: "pointerenter",
|
|
29
|
+
node,
|
|
30
|
+
handler: handlePointerEnter
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
event: "pointerleave",
|
|
34
|
+
node,
|
|
35
|
+
handler: handlePointerLeave
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
addListeners(listeners);
|
|
39
|
+
function handleWheel(event) {
|
|
40
|
+
const direction = event.deltaY > 0 ? "down" : "up";
|
|
41
|
+
const updatedDelta = event.deltaY;
|
|
42
|
+
if (isTrackpad(event)) return false;
|
|
43
|
+
setCSSVar(node, "--snap-type", "none");
|
|
44
|
+
const scrolledAmount = node.scrollLeft;
|
|
45
|
+
const scrollWidth = node.scrollWidth;
|
|
46
|
+
const clientWidth = node.clientWidth;
|
|
47
|
+
const scrollableAmount = scrollWidth - clientWidth;
|
|
48
|
+
if (direction === "down" && scrolledAmount < scrollableAmount) {
|
|
49
|
+
node.scrollLeft += updatedDelta;
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
if (direction === "up" && scrolledAmount > 0) {
|
|
53
|
+
node.scrollLeft += updatedDelta;
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
}
|
|
56
|
+
const { snapTimeoutID } = state;
|
|
57
|
+
if (snapTimeoutID) clearTimeout(snapTimeoutID);
|
|
58
|
+
state.snapTimeoutID = setTimeout((_) => {
|
|
59
|
+
restoreHijackedState(node, state);
|
|
60
|
+
}, options.scrollSnapDelay);
|
|
61
|
+
}
|
|
62
|
+
function handlePointerEnter(event) {
|
|
63
|
+
state.origSnapType = getCSSVar(node, "--snap-type") || "proximity";
|
|
64
|
+
}
|
|
65
|
+
function handlePointerLeave(event) {
|
|
66
|
+
restoreHijackedState(node, state);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
destroy() {
|
|
70
|
+
removeListeners(listeners);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function restoreHijackedState(node, state) {
|
|
75
|
+
const scrollLeft = node.scrollLeft;
|
|
76
|
+
setCSSVar(node, "--snap-type", state.origSnapType);
|
|
77
|
+
const finalScrollLeft = node.scrollLeft;
|
|
78
|
+
setCSSVar(node, "--snap-type", "none");
|
|
79
|
+
node.scrollTo({ left: scrollLeft, behavior: "instant" });
|
|
80
|
+
node.scrollTo({ left: finalScrollLeft, behavior: "smooth" });
|
|
81
|
+
setTimeout((_) => {
|
|
82
|
+
setCSSVar(node, "--snap-type", state.origSnapType);
|
|
83
|
+
}, 250);
|
|
84
|
+
}
|
|
85
|
+
function isTrackpad(event) {
|
|
86
|
+
if (event.wheelDeltaY === event.deltaY * -3) return true;
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
preferHorizontalScroll
|
|
90
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { boundingBoxRelativeToAncestor } from "../bounding-box.js";
|
|
2
|
+
import { resizeObserver } from "../observers/resize-observer.js";
|
|
3
|
+
import { findScrollContainer } from "../ui/scroll-container.js";
|
|
4
|
+
function sticky(node, props = {}) {
|
|
5
|
+
const scrollContainer = findScrollContainer(node);
|
|
6
|
+
let stickyTBLR = getComputedTBLR(node);
|
|
7
|
+
const obs = resizeObserver(node, {
|
|
8
|
+
callback: ({ entry }) => {
|
|
9
|
+
stickyTBLR = getComputedTBLR(node);
|
|
10
|
+
isSticking();
|
|
11
|
+
scrollContainer === document.documentElement ? window.addEventListener("scroll", scrollEventListener) : scrollContainer.addEventListener("scroll", scrollEventListener);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
function scrollEventListener(event) {
|
|
15
|
+
isSticking();
|
|
16
|
+
}
|
|
17
|
+
function isSticking() {
|
|
18
|
+
const { top, bottom, left, right } = stickyTBLR;
|
|
19
|
+
const relativeRect = boundingBoxRelativeToAncestor({
|
|
20
|
+
element: node,
|
|
21
|
+
ancestorElement: scrollContainer
|
|
22
|
+
});
|
|
23
|
+
if (!isNaN(top)) {
|
|
24
|
+
if (relativeRect.top - top <= 1) {
|
|
25
|
+
node.classList.add("sticking");
|
|
26
|
+
} else {
|
|
27
|
+
node.classList.remove("sticking");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!isNaN(bottom)) {
|
|
31
|
+
if (relativeRect.bottom + bottom >= -1) {
|
|
32
|
+
node.classList.add("sticking");
|
|
33
|
+
} else {
|
|
34
|
+
node.classList.remove("sticking");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!isNaN(left)) {
|
|
38
|
+
if (relativeRect.left - left <= 1) {
|
|
39
|
+
node.classList.add("sticking");
|
|
40
|
+
} else {
|
|
41
|
+
node.classList.remove("sticking");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (!isNaN(right)) {
|
|
45
|
+
if (relativeRect.right + right >= -1) {
|
|
46
|
+
node.classList.add("sticking");
|
|
47
|
+
} else {
|
|
48
|
+
node.classList.remove("sticking");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
destroy() {
|
|
54
|
+
obs.disconnect();
|
|
55
|
+
scrollContainer.removeEventListener("scroll", scrollEventListener);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getComputedTBLR(element) {
|
|
60
|
+
const style = getComputedStyle(element);
|
|
61
|
+
return {
|
|
62
|
+
top: parseFloat(style.top),
|
|
63
|
+
bottom: parseFloat(style.bottom),
|
|
64
|
+
left: parseFloat(style.left),
|
|
65
|
+
right: parseFloat(style.right)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
sticky
|
|
70
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function boundingBox(element, { containsPadding = true } = {}) {
|
|
2
|
+
const box = element.getBoundingClientRect();
|
|
3
|
+
const ret = {};
|
|
4
|
+
for (const prop in box) ret[prop] = box[prop];
|
|
5
|
+
if (!containsPadding) {
|
|
6
|
+
const style = getComputedStyle(element);
|
|
7
|
+
const paddingTop = parseFloat(style.paddingTop);
|
|
8
|
+
const paddingRight = parseFloat(style.paddingRight);
|
|
9
|
+
const paddingBottom = parseFloat(style.paddingBottom);
|
|
10
|
+
const paddingLeft = parseFloat(style.paddingLeft);
|
|
11
|
+
ret.x = ret.x + paddingLeft;
|
|
12
|
+
ret.y = ret.y + paddingTop;
|
|
13
|
+
ret.width = ret.width - paddingLeft - paddingRight;
|
|
14
|
+
ret.height = ret.height - paddingTop - paddingBottom;
|
|
15
|
+
ret.top = ret.top + paddingTop;
|
|
16
|
+
ret.bottom = ret.bottom - paddingBottom;
|
|
17
|
+
ret.right = ret.right - paddingRight;
|
|
18
|
+
ret.left = ret.left + paddingLeft;
|
|
19
|
+
}
|
|
20
|
+
ret.xCenter = (ret.left + ret.right) / 2;
|
|
21
|
+
ret.yCenter = (ret.top + ret.bottom) / 2;
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
24
|
+
function boundingBoxRelativeToAncestor({ element, ancestorElement }) {
|
|
25
|
+
ancestorElement = ancestorElement || element.parentElement;
|
|
26
|
+
const box = boundingBox(element);
|
|
27
|
+
const ancestorBox = boundingBox(ancestorElement, {
|
|
28
|
+
containsPadding: false
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
top: box.top - ancestorBox.top,
|
|
32
|
+
right: box.right - ancestorBox.right,
|
|
33
|
+
bottom: box.bottom - ancestorBox.bottom,
|
|
34
|
+
left: box.left - ancestorBox.left,
|
|
35
|
+
width: box.width,
|
|
36
|
+
height: box.height,
|
|
37
|
+
xCenter: (box.left + box.right) / 2 - ancestorBox.left,
|
|
38
|
+
yCenter: (box.top + box.bottom) / 2 - ancestorBox.top
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
boundingBox,
|
|
43
|
+
boundingBoxRelativeToAncestor
|
|
44
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function copyRichText(element) {
|
|
2
|
+
const range = document.createRange();
|
|
3
|
+
range.selectNode(element);
|
|
4
|
+
const selection = window.getSelection();
|
|
5
|
+
selection.removeAllRanges();
|
|
6
|
+
selection.addRange(range);
|
|
7
|
+
document.execCommand("copy");
|
|
8
|
+
selection.removeAllRanges();
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
copyRichText
|
|
12
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const cookies = {
|
|
2
|
+
get(name) {
|
|
3
|
+
return getCookie(name);
|
|
4
|
+
},
|
|
5
|
+
set(name, value, days) {
|
|
6
|
+
setCookie(name, value, days);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
function getCookie(name) {
|
|
10
|
+
const match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
|
|
11
|
+
if (!match) return null;
|
|
12
|
+
const decoded = decodeURIComponent(match[2]);
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(decoded);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return decoded;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function setCookie(name, value, days) {
|
|
20
|
+
let expires = "";
|
|
21
|
+
if (days) {
|
|
22
|
+
const date = /* @__PURE__ */ new Date();
|
|
23
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
24
|
+
expires = "; expires=" + date.toUTCString();
|
|
25
|
+
}
|
|
26
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
cookies,
|
|
30
|
+
getCookie
|
|
31
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getElement } from "./get-element.js";
|
|
2
|
+
function getCSSValue(element, prop) {
|
|
3
|
+
return getCSSVar(element, prop);
|
|
4
|
+
}
|
|
5
|
+
function setCSSValue(element, prop, value) {
|
|
6
|
+
setCSSVar(element, prop, value);
|
|
7
|
+
}
|
|
8
|
+
function getCSSVar(element, prop) {
|
|
9
|
+
element = getElement(element);
|
|
10
|
+
return getComputedStyle(element).getPropertyValue(prop);
|
|
11
|
+
}
|
|
12
|
+
function setCSSVar(element, prop, value) {
|
|
13
|
+
element = getElement(element);
|
|
14
|
+
element.style.setProperty(prop, value);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
getCSSValue,
|
|
18
|
+
getCSSVar,
|
|
19
|
+
setCSSValue,
|
|
20
|
+
setCSSVar
|
|
21
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function addListeners(listeners) {
|
|
2
|
+
listeners.forEach(({ node, event, handler }) => {
|
|
3
|
+
node.addEventListener(event, handler);
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
function removeListeners(listeners) {
|
|
7
|
+
listeners.forEach(({ node, event, handler }) => {
|
|
8
|
+
node.removeEventListener(event, handler);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function dispatchEvent(node, eventName, detail, options = {}) {
|
|
12
|
+
node.dispatchEvent(
|
|
13
|
+
new CustomEvent(eventName, {
|
|
14
|
+
...options,
|
|
15
|
+
detail
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
function updateEvent(event, updates) {
|
|
20
|
+
const { type, ...rest } = event;
|
|
21
|
+
return new CustomEvent(event.type, {
|
|
22
|
+
...rest,
|
|
23
|
+
...updates
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
addListeners,
|
|
28
|
+
dispatchEvent,
|
|
29
|
+
removeListeners,
|
|
30
|
+
updateEvent
|
|
31
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
function getFocusableElements(container = document.body) {
|
|
2
|
+
return {
|
|
3
|
+
/**
|
|
4
|
+
* Gets the number of keyboard focusable elements.
|
|
5
|
+
* This is useful for checking if there are any focusable elements
|
|
6
|
+
* before attempting to focus them.
|
|
7
|
+
*
|
|
8
|
+
* @returns {number} The number of keyboard focusable elements
|
|
9
|
+
*/
|
|
10
|
+
get length() {
|
|
11
|
+
return this.keyboard.length;
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Gets all focusable elements within the container that are visible and enabled.
|
|
15
|
+
* This includes elements that can be focused via mouse or programmatically,
|
|
16
|
+
* but may not be keyboard focusable.
|
|
17
|
+
*
|
|
18
|
+
* Elements are considered focusable if they:
|
|
19
|
+
* - Are not disabled
|
|
20
|
+
* - Are not hidden
|
|
21
|
+
* - Are not display:none
|
|
22
|
+
*
|
|
23
|
+
* @returns {HTMLElement[]} Array of focusable elements that are visible and enabled
|
|
24
|
+
*/
|
|
25
|
+
get all() {
|
|
26
|
+
const elements = Array.from(
|
|
27
|
+
container.querySelectorAll(
|
|
28
|
+
`a,
|
|
29
|
+
button,
|
|
30
|
+
input,
|
|
31
|
+
textarea,
|
|
32
|
+
select,
|
|
33
|
+
details,
|
|
34
|
+
iframe,
|
|
35
|
+
embed,
|
|
36
|
+
object,
|
|
37
|
+
summary,
|
|
38
|
+
dialog,
|
|
39
|
+
audio[controls],
|
|
40
|
+
video[controls],
|
|
41
|
+
[contenteditable],
|
|
42
|
+
[tabindex]
|
|
43
|
+
`
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
return elements.filter((el) => {
|
|
47
|
+
if (el.hasAttribute("disabled")) return false;
|
|
48
|
+
if (el.hasAttribute("hidden")) return false;
|
|
49
|
+
if (window.getComputedStyle(el).display === "none") return false;
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Gets elements that can be focused via keyboard (tabIndex > -1).
|
|
55
|
+
* These are the elements that will be focused when using the Tab key.
|
|
56
|
+
*
|
|
57
|
+
* @returns {HTMLElement[]} Array of keyboard focusable elements
|
|
58
|
+
*/
|
|
59
|
+
get keyboard() {
|
|
60
|
+
return this.all.filter((el) => el instanceof HTMLElement && el.tabIndex > -1);
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Alias for keyboard focusable elements.
|
|
64
|
+
* This is provided for semantic clarity in certain contexts.
|
|
65
|
+
*
|
|
66
|
+
* @returns {HTMLElement[]} Array of keyboard focusable elements
|
|
67
|
+
*/
|
|
68
|
+
get keyboardOnly() {
|
|
69
|
+
return this.keyboard;
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Gets the first keyboard focusable element.
|
|
73
|
+
* This is useful for setting initial focus when opening a modal or dialog.
|
|
74
|
+
*
|
|
75
|
+
* @returns {HTMLElement|null} The first focusable element or null if none exist
|
|
76
|
+
*/
|
|
77
|
+
get first() {
|
|
78
|
+
return this.keyboard[0] || null;
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* Gets the last keyboard focusable element.
|
|
82
|
+
* This is useful for focus trapping when using Shift+Tab.
|
|
83
|
+
*
|
|
84
|
+
* @returns {HTMLElement|null} The last focusable element or null if none exist
|
|
85
|
+
*/
|
|
86
|
+
get last() {
|
|
87
|
+
return this.keyboard[this.length - 1] || null;
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Gets the next focusable element after the given index.
|
|
91
|
+
* This is useful for implementing custom tab order or focus management.
|
|
92
|
+
*
|
|
93
|
+
* @param {number} index - The current element's index in the keyboard focusable array
|
|
94
|
+
* @returns {HTMLElement|null} The next focusable element or null if none exists
|
|
95
|
+
*/
|
|
96
|
+
next(index) {
|
|
97
|
+
return this.keyboard[index + 1] || null;
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Gets the previous focusable element before the given index.
|
|
101
|
+
* This is useful for implementing custom tab order or focus management.
|
|
102
|
+
*
|
|
103
|
+
* @param {number} index - The current element's index in the keyboard focusable array
|
|
104
|
+
* @returns {HTMLElement|null} The previous focusable element or null if none exists
|
|
105
|
+
*/
|
|
106
|
+
prev(index) {
|
|
107
|
+
return this.keyboard[index - 1] || null;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function Focusable(container = document.body) {
|
|
112
|
+
return getFocusableElements(container);
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
Focusable,
|
|
116
|
+
getFocusableElements
|
|
117
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { splitUnit } from "../lib/numbers/index.js";
|
|
2
|
+
function getUnit(value) {
|
|
3
|
+
const [, unit] = splitUnit(value);
|
|
4
|
+
return unit;
|
|
5
|
+
}
|
|
6
|
+
function rem(multiple = 1) {
|
|
7
|
+
const value = parseFloat(getComputedStyle(document.body)["font-size"]);
|
|
8
|
+
return Math.round(value * multiple);
|
|
9
|
+
}
|
|
10
|
+
function em(element = document.body, multiple = 1) {
|
|
11
|
+
const value = parseFloat(getComputedStyle(element)["font-size"]);
|
|
12
|
+
return Math.round(value * multiple);
|
|
13
|
+
}
|
|
14
|
+
function rlh(multiple = 1) {
|
|
15
|
+
const lineHeight = parseFloat(getComputedStyle(document.body)["line-height"]);
|
|
16
|
+
return Math.round(lineHeight * multiple);
|
|
17
|
+
}
|
|
18
|
+
function lh(element = document.body, multiple = 1) {
|
|
19
|
+
const lineHeight = getComputedStyle(element)["line-height"];
|
|
20
|
+
const value = parseFloat(lineHeight);
|
|
21
|
+
return Math.round(value * multiple);
|
|
22
|
+
}
|
|
23
|
+
function toPx(value, element = null) {
|
|
24
|
+
const [numeric, unit] = splitUnit(value);
|
|
25
|
+
let finalValue = 0;
|
|
26
|
+
if (unit === "rem") finalValue = rem(numeric);
|
|
27
|
+
if (unit === "em") finalValue = em(element, numeric);
|
|
28
|
+
if (unit === "lh") finalValue = lh(element, numeric);
|
|
29
|
+
if (unit === "px") finalValue = numeric;
|
|
30
|
+
if (!unit) finalValue = numeric;
|
|
31
|
+
return finalValue;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
em,
|
|
35
|
+
getUnit,
|
|
36
|
+
lh,
|
|
37
|
+
rem,
|
|
38
|
+
rlh,
|
|
39
|
+
toPx
|
|
40
|
+
};
|