@splendidlabz/utils 1.6.0 → 1.7.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/CHANGELOG.md +7 -0
- package/dist/cjs/dom/accessibility.cjs +53 -0
- package/dist/cjs/dom/actions/index.cjs +407 -0
- package/dist/cjs/dom/actions/masonry.cjs +149 -0
- package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +157 -0
- package/dist/cjs/dom/actions/sticky.cjs +211 -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 +95 -0
- package/dist/cjs/dom/focusable.cjs +143 -0
- package/dist/cjs/dom/font-size.cjs +74 -0
- package/dist/cjs/dom/get-element.cjs +98 -0
- package/dist/cjs/dom/hash.cjs +35 -0
- package/dist/cjs/dom/index.cjs +1197 -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 +156 -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 +82 -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 +58 -0
- package/dist/cjs/lib/date/days.cjs +37 -0
- package/dist/cjs/lib/date/index.cjs +206 -0
- package/dist/cjs/lib/date/months.cjs +102 -0
- package/dist/cjs/lib/date/time.cjs +115 -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/debounce.cjs +43 -0
- package/dist/cjs/lib/functions/env.cjs +32 -0
- package/dist/cjs/lib/functions/functional.cjs +62 -0
- package/dist/cjs/lib/functions/index.cjs +122 -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 +1141 -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 +146 -0
- package/dist/cjs/lib/objects/flatten.cjs +48 -0
- package/dist/cjs/lib/objects/index.cjs +375 -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 +112 -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 +190 -0
- package/dist/cjs/lib/strings/markdown.cjs +59 -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/common.cjs +42 -0
- package/dist/cjs/node/dirname.cjs +49 -0
- package/dist/cjs/node/file-cache.cjs +196 -0
- package/dist/cjs/node/file.cjs +50 -0
- package/dist/cjs/node/hash.cjs +42 -0
- package/dist/cjs/node/index.cjs +290 -0
- package/dist/cjs/node/pkce.cjs +62 -0
- package/dist/cjs/node/random-string.cjs +43 -0
- package/dist/cjs/node/sanitize.cjs +65 -0
- package/dist/esm/dom/accessibility.js +27 -0
- package/dist/esm/dom/actions/index.js +379 -0
- package/dist/esm/dom/actions/masonry.js +123 -0
- package/dist/esm/dom/actions/prefer-horizontal-scroll.js +131 -0
- package/dist/esm/dom/actions/sticky.js +185 -0
- package/dist/esm/dom/bounding-box.js +45 -0
- package/dist/esm/dom/clipboard.js +13 -0
- package/dist/esm/dom/cookie.js +32 -0
- package/dist/esm/dom/css-vars.js +28 -0
- package/dist/esm/dom/events.js +67 -0
- package/dist/esm/dom/focusable.js +118 -0
- package/dist/esm/dom/font-size.js +44 -0
- package/dist/esm/dom/get-element.js +67 -0
- package/dist/esm/dom/hash.js +11 -0
- package/dist/esm/dom/index.js +1100 -0
- package/dist/esm/dom/keyboard.js +23 -0
- package/dist/esm/dom/local-store.js +55 -0
- package/dist/esm/dom/media.js +33 -0
- package/dist/esm/dom/observers/index.js +128 -0
- package/dist/esm/dom/observers/intersection-observer.js +65 -0
- package/dist/esm/dom/observers/mutation-observer.js +69 -0
- package/dist/esm/dom/observers/observer.js +22 -0
- package/dist/esm/dom/observers/resize-observer.js +56 -0
- package/dist/esm/dom/pkce.js +27 -0
- package/dist/esm/dom/query-params.js +14 -0
- package/dist/esm/dom/random-string.js +13 -0
- package/dist/esm/dom/sanitize.js +31 -0
- package/dist/esm/dom/session-store.js +25 -0
- package/dist/esm/dom/spam-prevention.js +26 -0
- package/dist/esm/dom/trap-focus.js +170 -0
- package/dist/esm/dom/ui/aria-current.js +18 -0
- package/dist/esm/dom/ui/inconsistent-button-fix.js +11 -0
- package/dist/esm/dom/ui/index.js +75 -0
- package/dist/esm/dom/ui/scroll-container.js +23 -0
- package/dist/esm/dom/ui/traverse-and-scramble.js +26 -0
- package/dist/esm/lib/arrays/index.js +106 -0
- package/dist/esm/lib/arrays/item-position.js +16 -0
- package/dist/esm/lib/arrays/join.js +17 -0
- package/dist/esm/lib/arrays/shuffle.js +18 -0
- package/dist/esm/lib/arrays/sort.js +41 -0
- package/dist/esm/lib/arrays/split-array.js +17 -0
- package/dist/esm/lib/arrays/unique.js +7 -0
- package/dist/esm/lib/auth/index.js +26 -0
- package/dist/esm/lib/auth/route-manager.js +26 -0
- package/dist/esm/lib/checks.js +31 -0
- package/dist/esm/lib/date/days.js +13 -0
- package/dist/esm/lib/date/index.js +171 -0
- package/dist/esm/lib/date/months.js +78 -0
- package/dist/esm/lib/date/time.js +82 -0
- package/dist/esm/lib/form/form-data.js +58 -0
- package/dist/esm/lib/form/index.js +92 -0
- package/dist/esm/lib/form/sanitize.js +35 -0
- package/dist/esm/lib/functions/debounce.js +19 -0
- package/dist/esm/lib/functions/env.js +8 -0
- package/dist/esm/lib/functions/functional.js +35 -0
- package/dist/esm/lib/functions/index.js +87 -0
- package/dist/esm/lib/functions/throttle.js +14 -0
- package/dist/esm/lib/functions/timeout.js +15 -0
- package/dist/esm/lib/hash.js +19 -0
- package/dist/esm/lib/index.js +1023 -0
- package/dist/esm/lib/numbers/index.js +21 -0
- package/dist/esm/lib/numbers/math.js +11 -0
- package/dist/esm/lib/objects/camelcase-keys.js +54 -0
- package/dist/esm/lib/objects/empty.js +14 -0
- package/dist/esm/lib/objects/equal.js +12 -0
- package/dist/esm/lib/objects/extend.js +120 -0
- package/dist/esm/lib/objects/flatten.js +22 -0
- package/dist/esm/lib/objects/index.js +321 -0
- package/dist/esm/lib/objects/json.js +11 -0
- package/dist/esm/lib/objects/loop.js +15 -0
- package/dist/esm/lib/objects/mix/mix.js +87 -0
- package/dist/esm/lib/objects/nested-property.js +19 -0
- package/dist/esm/lib/objects/normalize-object.js +80 -0
- package/dist/esm/lib/objects/omit-empty.js +16 -0
- package/dist/esm/lib/objects/size.js +39 -0
- package/dist/esm/lib/objects/split.js +15 -0
- package/dist/esm/lib/promises/index.js +33 -0
- package/dist/esm/lib/promises/reject.js +33 -0
- package/dist/esm/lib/sse.js +72 -0
- package/dist/esm/lib/strings/convert-case/convert-case.js +65 -0
- package/dist/esm/lib/strings/index.js +140 -0
- package/dist/esm/lib/strings/markdown.js +34 -0
- package/dist/esm/lib/strings/name.js +22 -0
- package/dist/esm/lib/strings/pluralize.js +6 -0
- package/dist/esm/lib/strings/query-string.js +17 -0
- package/dist/esm/lib/style/index.js +38 -0
- package/dist/esm/lib/symbols/index.js +13 -0
- package/dist/esm/lib/symbols/symbols.js +13 -0
- package/dist/esm/node/common.js +8 -0
- package/dist/esm/node/dirname.js +14 -0
- package/dist/esm/node/file-cache.js +158 -0
- package/dist/esm/node/file.js +15 -0
- package/dist/esm/node/hash.js +8 -0
- package/dist/esm/node/index.js +243 -0
- package/dist/esm/node/pkce.js +28 -0
- package/dist/esm/node/random-string.js +9 -0
- package/dist/esm/node/sanitize.js +31 -0
- package/dist/{dom/accessibility.d.ts → types/dom/accessibility.d.cts} +5 -3
- 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/dist/{dom/bounding-box.d.ts → types/dom/bounding-box.d.cts} +4 -2
- package/dist/{dom/clipboard.d.ts → types/dom/clipboard.d.cts} +3 -1
- package/dist/types/dom/cookie.d.cts +7 -0
- package/dist/types/dom/css-vars.d.cts +6 -0
- package/dist/types/dom/events.d.cts +20 -0
- package/dist/{dom/focusable.d.ts → types/dom/focusable.d.cts} +5 -3
- package/dist/types/dom/font-size.d.cts +7 -0
- package/dist/{dom/get-element.d.ts → types/dom/get-element.d.cts} +10 -8
- package/dist/types/dom/hash.d.cts +3 -0
- package/dist/types/dom/index.d.cts +30 -0
- package/dist/{dom/keyboard.d.ts → types/dom/keyboard.d.cts} +7 -5
- package/dist/{dom/local-store.d.ts → types/dom/local-store.d.cts} +3 -1
- package/dist/types/dom/media.d.cts +5 -0
- package/dist/types/dom/observers/index.d.cts +3 -0
- package/dist/{dom/observers/intersection-observer.d.ts → types/dom/observers/intersection-observer.d.cts} +3 -1
- package/dist/{dom/observers/mutation-observer.d.ts → types/dom/observers/mutation-observer.d.cts} +3 -1
- package/dist/types/dom/observers/observer.d.cts +3 -0
- package/dist/{dom/observers/resize-observer.d.ts → types/dom/observers/resize-observer.d.cts} +3 -1
- package/dist/{node/pkce.d.ts → types/dom/pkce.d.cts} +3 -1
- package/dist/{dom/query-params.d.ts → types/dom/query-params.d.cts} +3 -1
- package/dist/{dom/random-string.d.ts → types/dom/random-string.d.cts} +4 -2
- package/dist/{dom/sanitize.d.ts → types/dom/sanitize.d.cts} +3 -1
- package/dist/{dom/session-store.d.ts → types/dom/session-store.d.cts} +3 -1
- package/dist/types/dom/spam-prevention.d.cts +14 -0
- package/dist/{dom/trap-focus.d.ts → types/dom/trap-focus.d.cts} +8 -4
- package/dist/types/dom/ui/aria-current.d.cts +7 -0
- package/dist/{dom/ui/inconsistent-button-fix.d.ts → types/dom/ui/inconsistent-button-fix.d.cts} +3 -1
- package/dist/types/dom/ui/index.d.cts +4 -0
- package/dist/types/dom/ui/scroll-container.d.cts +3 -0
- package/dist/{dom/ui/traverse-and-scramble.d.ts → types/dom/ui/traverse-and-scramble.d.cts} +3 -1
- package/dist/types/lib/arrays/index.d.cts +6 -0
- package/dist/{lib/arrays/item-position.d.ts → types/lib/arrays/item-position.d.cts} +5 -3
- package/dist/{lib/arrays/join.d.ts → types/lib/arrays/join.d.cts} +3 -1
- package/dist/types/lib/arrays/shuffle.d.cts +3 -0
- package/dist/{lib/arrays/sort.d.ts → types/lib/arrays/sort.d.cts} +3 -1
- 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/{lib/auth/route-manager.d.ts → types/lib/auth/route-manager.d.cts} +5 -2
- package/dist/{lib/checks.d.ts → types/lib/checks.d.cts} +6 -4
- package/dist/{lib/date/days.d.ts → types/lib/date/days.d.cts} +3 -1
- package/dist/types/lib/date/index.d.cts +3 -0
- package/dist/{lib/date/months.d.ts → types/lib/date/months.d.cts} +3 -1
- 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/dist/{lib/form/sanitize.d.ts → types/lib/form/sanitize.d.cts} +6 -4
- package/dist/types/lib/functions/debounce.d.cts +3 -0
- package/dist/types/lib/functions/env.d.cts +3 -0
- package/dist/types/lib/functions/functional.d.cts +6 -0
- 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 +4 -0
- package/dist/{lib/objects/nested-property.d.ts → types/lib/objects/nested-property.d.cts} +5 -3
- 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/{lib/objects/split.d.ts → types/lib/objects/split.d.cts} +3 -1
- package/dist/types/lib/promises/index.d.cts +1 -0
- package/dist/types/lib/promises/reject.d.cts +5 -0
- package/dist/{lib/sse.d.ts → types/lib/sse.d.cts} +4 -2
- 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/{lib/strings/markdown.d.ts → types/lib/strings/markdown.d.cts} +4 -2
- 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/common.d.cts +3 -0
- package/dist/types/node/dirname.d.cts +9 -0
- package/dist/{node/file-cache.d.ts → types/node/file-cache.d.cts} +7 -5
- 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/{dom/pkce.d.ts → types/node/pkce.d.cts} +3 -1
- package/dist/types/node/random-string.d.cts +3 -0
- package/dist/{node/sanitize.d.ts → types/node/sanitize.d.cts} +3 -1
- package/package.json +28 -15
- package/{dom → src/dom}/index.js +1 -0
- package/src/dom/spam-prevention.js +39 -0
- package/{dom → src/dom}/ui/aria-current.js +1 -1
- package/{lib → src/lib}/arrays/index.js +1 -0
- package/{lib → src/lib}/arrays/sort.js +6 -6
- package/src/lib/arrays/split-array.js +15 -0
- package/{lib → src/lib}/auth/route-manager.js +1 -0
- package/{lib → src/lib}/date/time.js +36 -5
- package/{lib → src/lib}/objects/mix/mix.js +30 -11
- package/{lib → src/lib}/objects/mix/mix.test.js +49 -1
- package/src/lib/strings/pluralize.js +2 -0
- package/{lib → src/lib}/style/index.js +2 -0
- package/tsconfig.json +6 -6
- package/tsup.config.js +38 -0
- package/tsup.config.mjs +43 -0
- package/dist/dom/actions/index.d.ts +0 -3
- package/dist/dom/actions/masonry.d.ts +0 -3
- package/dist/dom/actions/prefer-horizontal-scroll.d.ts +0 -3
- package/dist/dom/actions/sticky.d.ts +0 -3
- package/dist/dom/cookie.d.ts +0 -5
- package/dist/dom/css-vars.d.ts +0 -4
- package/dist/dom/events.d.ts +0 -18
- package/dist/dom/font-size.d.ts +0 -5
- package/dist/dom/hash.d.ts +0 -1
- package/dist/dom/index.d.ts +0 -22
- package/dist/dom/media.d.ts +0 -3
- package/dist/dom/observers/index.d.ts +0 -3
- package/dist/dom/observers/observer.d.ts +0 -1
- package/dist/dom/ui/aria-current.d.ts +0 -5
- package/dist/dom/ui/index.d.ts +0 -4
- package/dist/dom/ui/scroll-container.d.ts +0 -1
- package/dist/lib/arrays/index.d.ts +0 -5
- package/dist/lib/arrays/shuffle.d.ts +0 -1
- package/dist/lib/arrays/unique.d.ts +0 -1
- package/dist/lib/auth/index.d.ts +0 -1
- package/dist/lib/date/index.d.ts +0 -3
- package/dist/lib/date/time.d.ts +0 -8
- package/dist/lib/form/form-data.d.ts +0 -7
- package/dist/lib/form/index.d.ts +0 -2
- package/dist/lib/functions/debounce.d.ts +0 -1
- package/dist/lib/functions/env.d.ts +0 -1
- package/dist/lib/functions/functional.d.ts +0 -4
- package/dist/lib/functions/index.d.ts +0 -5
- package/dist/lib/functions/throttle.d.ts +0 -1
- package/dist/lib/functions/timeout.d.ts +0 -3
- package/dist/lib/hash.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -14
- package/dist/lib/numbers/index.d.ts +0 -2
- package/dist/lib/numbers/math.d.ts +0 -2
- package/dist/lib/objects/camelcase-keys.d.ts +0 -1
- package/dist/lib/objects/empty.d.ts +0 -2
- package/dist/lib/objects/equal.d.ts +0 -2
- package/dist/lib/objects/extend.d.ts +0 -4
- package/dist/lib/objects/flatten.d.ts +0 -4
- package/dist/lib/objects/index.d.ts +0 -13
- package/dist/lib/objects/json.d.ts +0 -1
- package/dist/lib/objects/loop.d.ts +0 -2
- package/dist/lib/objects/mix/mix.d.ts +0 -1
- package/dist/lib/objects/normalize-object.d.ts +0 -1
- package/dist/lib/objects/omit-empty.d.ts +0 -1
- package/dist/lib/objects/size.d.ts +0 -1
- package/dist/lib/promises/index.d.ts +0 -1
- package/dist/lib/promises/reject.d.ts +0 -3
- package/dist/lib/strings/convert-case/convert-case.d.ts +0 -8
- package/dist/lib/strings/index.d.ts +0 -5
- package/dist/lib/strings/name.d.ts +0 -5
- package/dist/lib/strings/pluralize.d.ts +0 -1
- package/dist/lib/strings/query-string.d.ts +0 -8
- package/dist/lib/style/index.d.ts +0 -1
- package/dist/lib/symbols/index.d.ts +0 -1
- package/dist/lib/symbols/symbols.d.ts +0 -2
- package/dist/node/common.d.ts +0 -1
- package/dist/node/dirname.d.ts +0 -7
- package/dist/node/file.d.ts +0 -2
- package/dist/node/hash.d.ts +0 -1
- package/dist/node/index.d.ts +0 -7
- package/dist/node/random-string.d.ts +0 -1
- package/lib/strings/pluralize.js +0 -2
- /package/{dom → src/dom}/accessibility.js +0 -0
- /package/{dom → src/dom}/actions/index.js +0 -0
- /package/{dom → src/dom}/actions/masonry.js +0 -0
- /package/{dom → src/dom}/actions/prefer-horizontal-scroll.js +0 -0
- /package/{dom → src/dom}/actions/sticky.js +0 -0
- /package/{dom → src/dom}/bounding-box.js +0 -0
- /package/{dom → src/dom}/clipboard.js +0 -0
- /package/{dom → src/dom}/cookie.js +0 -0
- /package/{dom → src/dom}/css-vars.js +0 -0
- /package/{dom → src/dom}/events.js +0 -0
- /package/{dom → src/dom}/events.test.js +0 -0
- /package/{dom → src/dom}/focusable.js +0 -0
- /package/{dom → src/dom}/font-size.js +0 -0
- /package/{dom → src/dom}/get-element.js +0 -0
- /package/{dom → src/dom}/hash.js +0 -0
- /package/{dom → src/dom}/keyboard.js +0 -0
- /package/{dom → src/dom}/local-store.js +0 -0
- /package/{dom → src/dom}/media.js +0 -0
- /package/{dom → src/dom}/observers/index.js +0 -0
- /package/{dom → src/dom}/observers/intersection-observer.js +0 -0
- /package/{dom → src/dom}/observers/mutation-observer.js +0 -0
- /package/{dom → src/dom}/observers/observer.js +0 -0
- /package/{dom → src/dom}/observers/resize-observer.js +0 -0
- /package/{dom → src/dom}/pkce.js +0 -0
- /package/{dom → src/dom}/query-params.js +0 -0
- /package/{dom → src/dom}/random-string.js +0 -0
- /package/{dom → src/dom}/random-string.test.js +0 -0
- /package/{dom → src/dom}/sanitize.js +0 -0
- /package/{dom → src/dom}/session-store.js +0 -0
- /package/{dom → src/dom}/trap-focus.js +0 -0
- /package/{dom → src/dom}/ui/inconsistent-button-fix.js +0 -0
- /package/{dom → src/dom}/ui/index.js +0 -0
- /package/{dom → src/dom}/ui/scroll-container.js +0 -0
- /package/{dom → src/dom}/ui/traverse-and-scramble.js +0 -0
- /package/{lib → src/lib}/arrays/item-position.js +0 -0
- /package/{lib → src/lib}/arrays/join.js +0 -0
- /package/{lib → src/lib}/arrays/shuffle.js +0 -0
- /package/{lib → src/lib}/arrays/sort.spec.js +0 -0
- /package/{lib → src/lib}/arrays/unique.js +0 -0
- /package/{lib → src/lib}/auth/index.js +0 -0
- /package/{lib → src/lib}/checks.js +0 -0
- /package/{lib → src/lib}/date/days.js +0 -0
- /package/{lib → src/lib}/date/index.js +0 -0
- /package/{lib → src/lib}/date/months.js +0 -0
- /package/{lib → src/lib}/form/form-data.js +0 -0
- /package/{lib → src/lib}/form/index.js +0 -0
- /package/{lib → src/lib}/form/sanitize.js +0 -0
- /package/{lib → src/lib}/form/sanitize.spec.js +0 -0
- /package/{lib → src/lib}/functions/debounce.js +0 -0
- /package/{lib → src/lib}/functions/env.js +0 -0
- /package/{lib → src/lib}/functions/functional.js +0 -0
- /package/{lib → src/lib}/functions/index.js +0 -0
- /package/{lib → src/lib}/functions/throttle.js +0 -0
- /package/{lib → src/lib}/functions/timeout.js +0 -0
- /package/{lib → src/lib}/hash.js +0 -0
- /package/{lib → src/lib}/hash.spec.js +0 -0
- /package/{lib → src/lib}/index.js +0 -0
- /package/{lib → src/lib}/numbers/index.js +0 -0
- /package/{lib → src/lib}/numbers/math.js +0 -0
- /package/{lib → src/lib}/objects/camelcase-keys.js +0 -0
- /package/{lib → src/lib}/objects/camelcase-keys.test.js +0 -0
- /package/{lib → src/lib}/objects/empty.js +0 -0
- /package/{lib → src/lib}/objects/equal.js +0 -0
- /package/{lib → src/lib}/objects/extend.js +0 -0
- /package/{lib → src/lib}/objects/extend.test.js +0 -0
- /package/{lib → src/lib}/objects/flatten.js +0 -0
- /package/{lib → src/lib}/objects/index.js +0 -0
- /package/{lib → src/lib}/objects/json.js +0 -0
- /package/{lib → src/lib}/objects/loop.js +0 -0
- /package/{lib → src/lib}/objects/loop.test.js +0 -0
- /package/{lib → src/lib}/objects/mix/mix.md +0 -0
- /package/{lib → src/lib}/objects/nested-property.js +0 -0
- /package/{lib → src/lib}/objects/normalize-object.js +0 -0
- /package/{lib → src/lib}/objects/omit-empty.js +0 -0
- /package/{lib → src/lib}/objects/omit-empty.test.js +0 -0
- /package/{lib → src/lib}/objects/size.js +0 -0
- /package/{lib → src/lib}/objects/split.js +0 -0
- /package/{lib → src/lib}/promises/index.js +0 -0
- /package/{lib → src/lib}/promises/reject.js +0 -0
- /package/{lib → src/lib}/sse.js +0 -0
- /package/{lib → src/lib}/strings/convert-case/convert-case.js +0 -0
- /package/{lib → src/lib}/strings/convert-case/convert-case.md +0 -0
- /package/{lib → src/lib}/strings/convert-case/convert-case.test.js +0 -0
- /package/{lib → src/lib}/strings/index.js +0 -0
- /package/{lib → src/lib}/strings/markdown.js +0 -0
- /package/{lib → src/lib}/strings/name.js +0 -0
- /package/{lib → src/lib}/strings/name.test.js +0 -0
- /package/{lib → src/lib}/strings/query-string.js +0 -0
- /package/{lib → src/lib}/symbols/index.js +0 -0
- /package/{lib → src/lib}/symbols/symbols.js +0 -0
- /package/{node → src/node}/common.js +0 -0
- /package/{node → src/node}/dirname.js +0 -0
- /package/{node → src/node}/file-cache.js +0 -0
- /package/{node → src/node}/file.js +0 -0
- /package/{node → src/node}/hash.js +0 -0
- /package/{node → src/node}/index.js +0 -0
- /package/{node → src/node}/pkce.js +0 -0
- /package/{node → src/node}/random-string.js +0 -0
- /package/{node → src/node}/random-string.test.js +0 -0
- /package/{node → src/node}/sanitize.js +0 -0
- /package/{node → src/node}/sanitize.spec.js +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// src/dom/focusable.js
|
|
2
|
+
function getFocusableElements(container = document.body) {
|
|
3
|
+
return {
|
|
4
|
+
/**
|
|
5
|
+
* Gets the number of keyboard focusable elements.
|
|
6
|
+
* This is useful for checking if there are any focusable elements
|
|
7
|
+
* before attempting to focus them.
|
|
8
|
+
*
|
|
9
|
+
* @returns {number} The number of keyboard focusable elements
|
|
10
|
+
*/
|
|
11
|
+
get length() {
|
|
12
|
+
return this.keyboard.length;
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* Gets all focusable elements within the container that are visible and enabled.
|
|
16
|
+
* This includes elements that can be focused via mouse or programmatically,
|
|
17
|
+
* but may not be keyboard focusable.
|
|
18
|
+
*
|
|
19
|
+
* Elements are considered focusable if they:
|
|
20
|
+
* - Are not disabled
|
|
21
|
+
* - Are not hidden
|
|
22
|
+
* - Are not display:none
|
|
23
|
+
*
|
|
24
|
+
* @returns {HTMLElement[]} Array of focusable elements that are visible and enabled
|
|
25
|
+
*/
|
|
26
|
+
get all() {
|
|
27
|
+
const elements = Array.from(
|
|
28
|
+
container.querySelectorAll(
|
|
29
|
+
`a,
|
|
30
|
+
button,
|
|
31
|
+
input,
|
|
32
|
+
textarea,
|
|
33
|
+
select,
|
|
34
|
+
details,
|
|
35
|
+
iframe,
|
|
36
|
+
embed,
|
|
37
|
+
object,
|
|
38
|
+
summary,
|
|
39
|
+
dialog,
|
|
40
|
+
audio[controls],
|
|
41
|
+
video[controls],
|
|
42
|
+
[contenteditable],
|
|
43
|
+
[tabindex]
|
|
44
|
+
`
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
return elements.filter((el) => {
|
|
48
|
+
if (el.hasAttribute("disabled")) return false;
|
|
49
|
+
if (el.hasAttribute("hidden")) return false;
|
|
50
|
+
if (window.getComputedStyle(el).display === "none") return false;
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Gets elements that can be focused via keyboard (tabIndex > -1).
|
|
56
|
+
* These are the elements that will be focused when using the Tab key.
|
|
57
|
+
*
|
|
58
|
+
* @returns {HTMLElement[]} Array of keyboard focusable elements
|
|
59
|
+
*/
|
|
60
|
+
get keyboard() {
|
|
61
|
+
return this.all.filter((el) => el instanceof HTMLElement && el.tabIndex > -1);
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Alias for keyboard focusable elements.
|
|
65
|
+
* This is provided for semantic clarity in certain contexts.
|
|
66
|
+
*
|
|
67
|
+
* @returns {HTMLElement[]} Array of keyboard focusable elements
|
|
68
|
+
*/
|
|
69
|
+
get keyboardOnly() {
|
|
70
|
+
return this.keyboard;
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Gets the first keyboard focusable element.
|
|
74
|
+
* This is useful for setting initial focus when opening a modal or dialog.
|
|
75
|
+
*
|
|
76
|
+
* @returns {HTMLElement|null} The first focusable element or null if none exist
|
|
77
|
+
*/
|
|
78
|
+
get first() {
|
|
79
|
+
return this.keyboard[0] || null;
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Gets the last keyboard focusable element.
|
|
83
|
+
* This is useful for focus trapping when using Shift+Tab.
|
|
84
|
+
*
|
|
85
|
+
* @returns {HTMLElement|null} The last focusable element or null if none exist
|
|
86
|
+
*/
|
|
87
|
+
get last() {
|
|
88
|
+
return this.keyboard[this.length - 1] || null;
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Gets the next focusable element after the given index.
|
|
92
|
+
* This is useful for implementing custom tab order or focus management.
|
|
93
|
+
*
|
|
94
|
+
* @param {number} index - The current element's index in the keyboard focusable array
|
|
95
|
+
* @returns {HTMLElement|null} The next focusable element or null if none exists
|
|
96
|
+
*/
|
|
97
|
+
next(index) {
|
|
98
|
+
return this.keyboard[index + 1] || null;
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Gets the previous focusable element before the given index.
|
|
102
|
+
* This is useful for implementing custom tab order or focus management.
|
|
103
|
+
*
|
|
104
|
+
* @param {number} index - The current element's index in the keyboard focusable array
|
|
105
|
+
* @returns {HTMLElement|null} The previous focusable element or null if none exists
|
|
106
|
+
*/
|
|
107
|
+
prev(index) {
|
|
108
|
+
return this.keyboard[index - 1] || null;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/dom/keyboard.js
|
|
114
|
+
function isTab(event) {
|
|
115
|
+
return !event.shiftKey && event.key === "Tab";
|
|
116
|
+
}
|
|
117
|
+
function isShiftTab(event) {
|
|
118
|
+
return event.shiftKey && event.key === "Tab";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/dom/trap-focus.js
|
|
122
|
+
function trapFocus({ event, focusables }) {
|
|
123
|
+
if (event.key !== "Tab") return;
|
|
124
|
+
if (isTab(event) && document.activeElement === focusables.last) {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
focusables.first.focus();
|
|
127
|
+
}
|
|
128
|
+
if (isShiftTab(event) && document.activeElement === focusables.first) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
focusables.last.focus();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function manageFocus({
|
|
134
|
+
event,
|
|
135
|
+
triggerNode,
|
|
136
|
+
contentNode,
|
|
137
|
+
focusables,
|
|
138
|
+
tabOutFocus = "next",
|
|
139
|
+
// 'trigger'
|
|
140
|
+
onLeave = function() {
|
|
141
|
+
}
|
|
142
|
+
}) {
|
|
143
|
+
const activeEl = document.activeElement;
|
|
144
|
+
if (activeEl === contentNode && isShiftTab(event)) return backFocus();
|
|
145
|
+
if (activeEl === contentNode && focusables.length === 0 && isTab(event))
|
|
146
|
+
return nextFocus();
|
|
147
|
+
if (activeEl === focusables.last && isTab(event)) return nextFocus();
|
|
148
|
+
if (activeEl === focusables.first && isShiftTab(event)) return backFocus();
|
|
149
|
+
function backFocus() {
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
triggerNode.focus();
|
|
152
|
+
onLeave("back");
|
|
153
|
+
}
|
|
154
|
+
function nextFocus() {
|
|
155
|
+
if (tabOutFocus === "trigger") triggerNode.focus();
|
|
156
|
+
if (tabOutFocus === "next") {
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
const DOMFocusables = getFocusableElements().keyboard;
|
|
159
|
+
const index = DOMFocusables.findIndex((e) => e === triggerNode);
|
|
160
|
+
const next = DOMFocusables[index + 1];
|
|
161
|
+
if (next) next.focus();
|
|
162
|
+
else triggerNode.focus();
|
|
163
|
+
}
|
|
164
|
+
onLeave("forward");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
manageFocus,
|
|
169
|
+
trapFocus
|
|
170
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/dom/ui/aria-current.js
|
|
2
|
+
function markActiveAnchorIn(container, anchorType = "page") {
|
|
3
|
+
if (!container) return;
|
|
4
|
+
const { pathname } = window.location;
|
|
5
|
+
const element = container.querySelector(`[href="${pathname}"]`);
|
|
6
|
+
if (!element) return;
|
|
7
|
+
element.setAttribute("aria-current", "page");
|
|
8
|
+
return element;
|
|
9
|
+
}
|
|
10
|
+
function scrollToElement(element, { scrollBehaviour = "instant", scrollMargin = "3rem" } = {}) {
|
|
11
|
+
if (!element) return;
|
|
12
|
+
element.style.scrollMarginTop = scrollMargin;
|
|
13
|
+
element.scrollIntoView({ behavior: scrollBehaviour });
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
markActiveAnchorIn,
|
|
17
|
+
scrollToElement
|
|
18
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/dom/ui/aria-current.js
|
|
2
|
+
function markActiveAnchorIn(container, anchorType = "page") {
|
|
3
|
+
if (!container) return;
|
|
4
|
+
const { pathname } = window.location;
|
|
5
|
+
const element = container.querySelector(`[href="${pathname}"]`);
|
|
6
|
+
if (!element) return;
|
|
7
|
+
element.setAttribute("aria-current", "page");
|
|
8
|
+
return element;
|
|
9
|
+
}
|
|
10
|
+
function scrollToElement(element, { scrollBehaviour = "instant", scrollMargin = "3rem" } = {}) {
|
|
11
|
+
if (!element) return;
|
|
12
|
+
element.style.scrollMarginTop = scrollMargin;
|
|
13
|
+
element.scrollIntoView({ behavior: scrollBehaviour });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/dom/ui/inconsistent-button-fix.js
|
|
17
|
+
function inconsistentButtonFix() {
|
|
18
|
+
document.addEventListener("click", (event) => {
|
|
19
|
+
if (event.target instanceof HTMLButtonElement) {
|
|
20
|
+
event.target.focus();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/dom/ui/scroll-container.js
|
|
26
|
+
function findScrollContainer(element, direction = "both") {
|
|
27
|
+
if (!element) return;
|
|
28
|
+
let parent = element.parentElement;
|
|
29
|
+
while (parent) {
|
|
30
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(parent);
|
|
31
|
+
if (direction === "both") {
|
|
32
|
+
if (overflow.includes("auto") || overflow.includes("scroll"))
|
|
33
|
+
return parent;
|
|
34
|
+
}
|
|
35
|
+
if (direction === "horizontal") {
|
|
36
|
+
if (overflowX === "auto" || overflowX === "scroll") return parent;
|
|
37
|
+
}
|
|
38
|
+
if (direction === "vertical") {
|
|
39
|
+
if (overflowY === "auto" || overflowY === "scroll") return parent;
|
|
40
|
+
}
|
|
41
|
+
parent = parent.parentElement;
|
|
42
|
+
}
|
|
43
|
+
return document.documentElement;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/dom/ui/traverse-and-scramble.js
|
|
47
|
+
function traverseAndScramble(node, { excludes = [] } = {}) {
|
|
48
|
+
if (node instanceof Element && excludes.some((selector) => node.matches(selector))) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
node.childNodes.forEach((child) => {
|
|
52
|
+
if (child.nodeType === 3) {
|
|
53
|
+
child.nodeValue = scrambleText(child.nodeValue);
|
|
54
|
+
} else if (child.nodeType === 1 && child instanceof Element) {
|
|
55
|
+
traverseAndScramble(child, { excludes });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function scrambleText(text) {
|
|
60
|
+
return text.split("").map((char) => {
|
|
61
|
+
if (/^[A-Za-z0-9]$/.test(char)) {
|
|
62
|
+
const randomCharCode = Math.random() < 26 / 36 ? Math.floor(Math.random() * 26) + (char === char.toUpperCase() ? 65 : 97) : Math.floor(Math.random() * 10) + 48;
|
|
63
|
+
return String.fromCharCode(randomCharCode);
|
|
64
|
+
} else {
|
|
65
|
+
return char;
|
|
66
|
+
}
|
|
67
|
+
}).join("");
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
findScrollContainer,
|
|
71
|
+
inconsistentButtonFix,
|
|
72
|
+
markActiveAnchorIn,
|
|
73
|
+
scrollToElement,
|
|
74
|
+
traverseAndScramble
|
|
75
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/dom/ui/scroll-container.js
|
|
2
|
+
function findScrollContainer(element, direction = "both") {
|
|
3
|
+
if (!element) return;
|
|
4
|
+
let parent = element.parentElement;
|
|
5
|
+
while (parent) {
|
|
6
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(parent);
|
|
7
|
+
if (direction === "both") {
|
|
8
|
+
if (overflow.includes("auto") || overflow.includes("scroll"))
|
|
9
|
+
return parent;
|
|
10
|
+
}
|
|
11
|
+
if (direction === "horizontal") {
|
|
12
|
+
if (overflowX === "auto" || overflowX === "scroll") return parent;
|
|
13
|
+
}
|
|
14
|
+
if (direction === "vertical") {
|
|
15
|
+
if (overflowY === "auto" || overflowY === "scroll") return parent;
|
|
16
|
+
}
|
|
17
|
+
parent = parent.parentElement;
|
|
18
|
+
}
|
|
19
|
+
return document.documentElement;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
findScrollContainer
|
|
23
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/dom/ui/traverse-and-scramble.js
|
|
2
|
+
function traverseAndScramble(node, { excludes = [] } = {}) {
|
|
3
|
+
if (node instanceof Element && excludes.some((selector) => node.matches(selector))) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
node.childNodes.forEach((child) => {
|
|
7
|
+
if (child.nodeType === 3) {
|
|
8
|
+
child.nodeValue = scrambleText(child.nodeValue);
|
|
9
|
+
} else if (child.nodeType === 1 && child instanceof Element) {
|
|
10
|
+
traverseAndScramble(child, { excludes });
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function scrambleText(text) {
|
|
15
|
+
return text.split("").map((char) => {
|
|
16
|
+
if (/^[A-Za-z0-9]$/.test(char)) {
|
|
17
|
+
const randomCharCode = Math.random() < 26 / 36 ? Math.floor(Math.random() * 26) + (char === char.toUpperCase() ? 65 : 97) : Math.floor(Math.random() * 10) + 48;
|
|
18
|
+
return String.fromCharCode(randomCharCode);
|
|
19
|
+
} else {
|
|
20
|
+
return char;
|
|
21
|
+
}
|
|
22
|
+
}).join("");
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
traverseAndScramble
|
|
26
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// src/lib/arrays/item-position.js
|
|
2
|
+
function last(array, index) {
|
|
3
|
+
console.warn("last is deprecated. Use isLastItem instead.");
|
|
4
|
+
return index === array.length - 1;
|
|
5
|
+
}
|
|
6
|
+
function isLastItem(array, index) {
|
|
7
|
+
return index === array.length - 1;
|
|
8
|
+
}
|
|
9
|
+
function lastArrayItem(array) {
|
|
10
|
+
return array[array.length - 1];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/lib/arrays/join.js
|
|
14
|
+
function joinWithConjunction(array, { conjunction = "and" } = {}) {
|
|
15
|
+
if (!array?.length) return "";
|
|
16
|
+
if (array.length === 1) return array[0];
|
|
17
|
+
if (array.length === 2) return `${array[0]} ${conjunction} ${array[1]}`;
|
|
18
|
+
const lastItem = lastArrayItem(array);
|
|
19
|
+
const rest = array.slice(0, -1);
|
|
20
|
+
return `${rest.join(", ")} ${conjunction} ${lastItem}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/lib/arrays/shuffle.js
|
|
24
|
+
function shuffle(array) {
|
|
25
|
+
const clone = array.slice();
|
|
26
|
+
let currentIndex = array.length;
|
|
27
|
+
let temporaryValue;
|
|
28
|
+
let randomIndex;
|
|
29
|
+
while (currentIndex !== 0) {
|
|
30
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
31
|
+
currentIndex -= 1;
|
|
32
|
+
temporaryValue = clone[currentIndex];
|
|
33
|
+
clone[currentIndex] = clone[randomIndex];
|
|
34
|
+
clone[randomIndex] = temporaryValue;
|
|
35
|
+
}
|
|
36
|
+
return clone;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/lib/objects/nested-property.js
|
|
40
|
+
function getNestedValue(object, path) {
|
|
41
|
+
return path.split(".").reduce((acc, part) => acc?.[part], object);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/lib/arrays/sort.js
|
|
45
|
+
function sort(array, { props = null, reverse = false } = {}) {
|
|
46
|
+
const clone = array.slice();
|
|
47
|
+
if (props === null) {
|
|
48
|
+
return clone.sort((a, b) => {
|
|
49
|
+
const comparison = compareValues(a, b);
|
|
50
|
+
return reverse ? -comparison : comparison;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const properties = Array.isArray(props) ? props : [props];
|
|
54
|
+
return clone.sort((a, b) => {
|
|
55
|
+
for (const property of properties) {
|
|
56
|
+
const aValue = getNestedValue(a, property);
|
|
57
|
+
const bValue = getNestedValue(b, property);
|
|
58
|
+
if (aValue === bValue) continue;
|
|
59
|
+
if (aValue == null) return 1;
|
|
60
|
+
if (bValue == null) return -1;
|
|
61
|
+
const comparison = compareValues(aValue, bValue);
|
|
62
|
+
return reverse ? -comparison : comparison;
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function compareValues(a, b) {
|
|
68
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
69
|
+
if (typeof a === "string" && typeof b === "string") return a.localeCompare(b);
|
|
70
|
+
const aDate = new Date(a);
|
|
71
|
+
const bDate = new Date(b);
|
|
72
|
+
const aTime = aDate.getTime();
|
|
73
|
+
const bTime = bDate.getTime();
|
|
74
|
+
if (!isNaN(aTime) && !isNaN(bTime)) return aTime - bTime;
|
|
75
|
+
return String(a).localeCompare(String(b));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/lib/arrays/split-array.js
|
|
79
|
+
function splitArray(array, predicate) {
|
|
80
|
+
const ret = {
|
|
81
|
+
picked: [],
|
|
82
|
+
omitted: []
|
|
83
|
+
};
|
|
84
|
+
array.forEach((item, index, arr) => {
|
|
85
|
+
if (predicate(item, index, arr)) ret.picked.push(item);
|
|
86
|
+
else ret.omitted.push(item);
|
|
87
|
+
});
|
|
88
|
+
ret.p = ret.picked;
|
|
89
|
+
ret.o = ret.omitted;
|
|
90
|
+
return ret;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/lib/arrays/unique.js
|
|
94
|
+
function uniqueArray(array) {
|
|
95
|
+
return Array.from(new Set(array));
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
isLastItem,
|
|
99
|
+
joinWithConjunction,
|
|
100
|
+
last,
|
|
101
|
+
lastArrayItem,
|
|
102
|
+
shuffle,
|
|
103
|
+
sort,
|
|
104
|
+
splitArray,
|
|
105
|
+
uniqueArray
|
|
106
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/lib/arrays/item-position.js
|
|
2
|
+
function last(array, index) {
|
|
3
|
+
console.warn("last is deprecated. Use isLastItem instead.");
|
|
4
|
+
return index === array.length - 1;
|
|
5
|
+
}
|
|
6
|
+
function isLastItem(array, index) {
|
|
7
|
+
return index === array.length - 1;
|
|
8
|
+
}
|
|
9
|
+
function lastArrayItem(array) {
|
|
10
|
+
return array[array.length - 1];
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
isLastItem,
|
|
14
|
+
last,
|
|
15
|
+
lastArrayItem
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/lib/arrays/item-position.js
|
|
2
|
+
function lastArrayItem(array) {
|
|
3
|
+
return array[array.length - 1];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/lib/arrays/join.js
|
|
7
|
+
function joinWithConjunction(array, { conjunction = "and" } = {}) {
|
|
8
|
+
if (!array?.length) return "";
|
|
9
|
+
if (array.length === 1) return array[0];
|
|
10
|
+
if (array.length === 2) return `${array[0]} ${conjunction} ${array[1]}`;
|
|
11
|
+
const lastItem = lastArrayItem(array);
|
|
12
|
+
const rest = array.slice(0, -1);
|
|
13
|
+
return `${rest.join(", ")} ${conjunction} ${lastItem}`;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
joinWithConjunction
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/lib/arrays/shuffle.js
|
|
2
|
+
function shuffle(array) {
|
|
3
|
+
const clone = array.slice();
|
|
4
|
+
let currentIndex = array.length;
|
|
5
|
+
let temporaryValue;
|
|
6
|
+
let randomIndex;
|
|
7
|
+
while (currentIndex !== 0) {
|
|
8
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
9
|
+
currentIndex -= 1;
|
|
10
|
+
temporaryValue = clone[currentIndex];
|
|
11
|
+
clone[currentIndex] = clone[randomIndex];
|
|
12
|
+
clone[randomIndex] = temporaryValue;
|
|
13
|
+
}
|
|
14
|
+
return clone;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
shuffle
|
|
18
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/lib/objects/nested-property.js
|
|
2
|
+
function getNestedValue(object, path) {
|
|
3
|
+
return path.split(".").reduce((acc, part) => acc?.[part], object);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/lib/arrays/sort.js
|
|
7
|
+
function sort(array, { props = null, reverse = false } = {}) {
|
|
8
|
+
const clone = array.slice();
|
|
9
|
+
if (props === null) {
|
|
10
|
+
return clone.sort((a, b) => {
|
|
11
|
+
const comparison = compareValues(a, b);
|
|
12
|
+
return reverse ? -comparison : comparison;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const properties = Array.isArray(props) ? props : [props];
|
|
16
|
+
return clone.sort((a, b) => {
|
|
17
|
+
for (const property of properties) {
|
|
18
|
+
const aValue = getNestedValue(a, property);
|
|
19
|
+
const bValue = getNestedValue(b, property);
|
|
20
|
+
if (aValue === bValue) continue;
|
|
21
|
+
if (aValue == null) return 1;
|
|
22
|
+
if (bValue == null) return -1;
|
|
23
|
+
const comparison = compareValues(aValue, bValue);
|
|
24
|
+
return reverse ? -comparison : comparison;
|
|
25
|
+
}
|
|
26
|
+
return 0;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function compareValues(a, b) {
|
|
30
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
31
|
+
if (typeof a === "string" && typeof b === "string") return a.localeCompare(b);
|
|
32
|
+
const aDate = new Date(a);
|
|
33
|
+
const bDate = new Date(b);
|
|
34
|
+
const aTime = aDate.getTime();
|
|
35
|
+
const bTime = bDate.getTime();
|
|
36
|
+
if (!isNaN(aTime) && !isNaN(bTime)) return aTime - bTime;
|
|
37
|
+
return String(a).localeCompare(String(b));
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
sort
|
|
41
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/lib/arrays/split-array.js
|
|
2
|
+
function splitArray(array, predicate) {
|
|
3
|
+
const ret = {
|
|
4
|
+
picked: [],
|
|
5
|
+
omitted: []
|
|
6
|
+
};
|
|
7
|
+
array.forEach((item, index, arr) => {
|
|
8
|
+
if (predicate(item, index, arr)) ret.picked.push(item);
|
|
9
|
+
else ret.omitted.push(item);
|
|
10
|
+
});
|
|
11
|
+
ret.p = ret.picked;
|
|
12
|
+
ret.o = ret.omitted;
|
|
13
|
+
return ret;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
splitArray
|
|
17
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/lib/auth/route-manager.js
|
|
2
|
+
function RouteManager(config) {
|
|
3
|
+
const { protectedRoutes, bypassRoutes } = config;
|
|
4
|
+
return {
|
|
5
|
+
isProtectedRoute(pathname) {
|
|
6
|
+
return isMatch(protectedRoutes, pathname);
|
|
7
|
+
},
|
|
8
|
+
isBypassRoute(pathname) {
|
|
9
|
+
return isMatch(bypassRoutes, pathname);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function AuthManager(config) {
|
|
14
|
+
return RouteManager(config);
|
|
15
|
+
}
|
|
16
|
+
function isMatch(routeConfig, pathname) {
|
|
17
|
+
const { is, startsWith, includes } = routeConfig;
|
|
18
|
+
const isExactMatch = is && is.some((u) => pathname === u);
|
|
19
|
+
const startsWithMatch = startsWith && startsWith.some((u) => pathname.startsWith(u));
|
|
20
|
+
const includesMatch = includes && includes.some((u) => pathname.includes(u));
|
|
21
|
+
return isExactMatch || startsWithMatch || includesMatch;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
AuthManager,
|
|
25
|
+
RouteManager
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/lib/auth/route-manager.js
|
|
2
|
+
function RouteManager(config) {
|
|
3
|
+
const { protectedRoutes, bypassRoutes } = config;
|
|
4
|
+
return {
|
|
5
|
+
isProtectedRoute(pathname) {
|
|
6
|
+
return isMatch(protectedRoutes, pathname);
|
|
7
|
+
},
|
|
8
|
+
isBypassRoute(pathname) {
|
|
9
|
+
return isMatch(bypassRoutes, pathname);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function AuthManager(config) {
|
|
14
|
+
return RouteManager(config);
|
|
15
|
+
}
|
|
16
|
+
function isMatch(routeConfig, pathname) {
|
|
17
|
+
const { is, startsWith, includes } = routeConfig;
|
|
18
|
+
const isExactMatch = is && is.some((u) => pathname === u);
|
|
19
|
+
const startsWithMatch = startsWith && startsWith.some((u) => pathname.startsWith(u));
|
|
20
|
+
const includesMatch = includes && includes.some((u) => pathname.includes(u));
|
|
21
|
+
return isExactMatch || startsWithMatch || includesMatch;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
AuthManager,
|
|
25
|
+
RouteManager
|
|
26
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/lib/checks.js
|
|
2
|
+
function isObject(x) {
|
|
3
|
+
return typeof x === "object" && !Array.isArray(x) && x !== null;
|
|
4
|
+
}
|
|
5
|
+
function isArray(x) {
|
|
6
|
+
return Array.isArray(x);
|
|
7
|
+
}
|
|
8
|
+
function notObject(x) {
|
|
9
|
+
return !isObject(x);
|
|
10
|
+
}
|
|
11
|
+
function getType(x) {
|
|
12
|
+
if (typeof x === "string") return "string";
|
|
13
|
+
if (typeof x === "number") {
|
|
14
|
+
if (Number.isInteger(x)) return "integer";
|
|
15
|
+
return "float";
|
|
16
|
+
}
|
|
17
|
+
if (typeof x === "boolean") return "boolean";
|
|
18
|
+
if (typeof x === "function") return "function";
|
|
19
|
+
if (typeof x === "undefined") return "undefined";
|
|
20
|
+
if (typeof x === "symbol") return "symbol";
|
|
21
|
+
if (typeof x === "bigint") return "bigint";
|
|
22
|
+
if (Array.isArray(x)) return "array";
|
|
23
|
+
if (typeof x === "object") return "object";
|
|
24
|
+
return "unknown";
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
getType,
|
|
28
|
+
isArray,
|
|
29
|
+
isObject,
|
|
30
|
+
notObject
|
|
31
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/lib/date/days.js
|
|
2
|
+
var DAYS = [
|
|
3
|
+
{ short: "Sun", long: "Sunday", numeric: 1 },
|
|
4
|
+
{ short: "Mon", long: "Monday", numeric: 2 },
|
|
5
|
+
{ short: "Tue", long: "Tuesday", numeric: 3 },
|
|
6
|
+
{ short: "Wed", long: "Wednesday", numeric: 4 },
|
|
7
|
+
{ short: "Thu", long: "Thursday", numeric: 5 },
|
|
8
|
+
{ short: "Fri", long: "Friday", numeric: 6 },
|
|
9
|
+
{ short: "Sat", long: "Saturday", numeric: 7 }
|
|
10
|
+
];
|
|
11
|
+
export {
|
|
12
|
+
DAYS
|
|
13
|
+
};
|