@hortonstudio/main 1.2.4 → 1.2.6
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/attributes-master/.changeset/README.md +8 -0
- package/attributes-master/.changeset/config.json +11 -0
- package/attributes-master/.gitattributes +2 -0
- package/attributes-master/.github/ISSUE_TEMPLATE/bug_report.md +42 -0
- package/attributes-master/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- package/attributes-master/.github/workflows/ci.yml +66 -0
- package/attributes-master/.github/workflows/release.yml +40 -0
- package/attributes-master/.prettierignore +3 -0
- package/attributes-master/.prettierrc +8 -0
- package/attributes-master/.vscode/extensions.json +3 -0
- package/attributes-master/.vscode/settings.json +7 -0
- package/attributes-master/CONTRIBUTING.md +72 -0
- package/attributes-master/LICENSE.md +201 -0
- package/attributes-master/README.md +31 -0
- package/attributes-master/eslint.config.js +3 -0
- package/attributes-master/package.json +34 -0
- package/attributes-master/packages/accordion/CHANGELOG.md +89 -0
- package/attributes-master/packages/accordion/README.md +31 -0
- package/attributes-master/packages/accordion/package.json +25 -0
- package/attributes-master/packages/accordion/src/actions/a11y.ts +39 -0
- package/attributes-master/packages/accordion/src/actions/classes.ts +27 -0
- package/attributes-master/packages/accordion/src/actions/content.ts +42 -0
- package/attributes-master/packages/accordion/src/actions/list.ts +36 -0
- package/attributes-master/packages/accordion/src/actions/query.ts +27 -0
- package/attributes-master/packages/accordion/src/actions/settings.ts +61 -0
- package/attributes-master/packages/accordion/src/factory.ts +145 -0
- package/attributes-master/packages/accordion/src/index.ts +3 -0
- package/attributes-master/packages/accordion/src/init.ts +37 -0
- package/attributes-master/packages/accordion/src/utils/constants.ts +62 -0
- package/attributes-master/packages/accordion/src/utils/helpers.ts +5 -0
- package/attributes-master/packages/accordion/src/utils/selectors.ts +12 -0
- package/attributes-master/packages/accordion/src/utils/types.ts +23 -0
- package/attributes-master/packages/accordion/tsconfig.json +3 -0
- package/attributes-master/packages/attributes/CHANGELOG.md +564 -0
- package/attributes-master/packages/attributes/README.md +66 -0
- package/attributes-master/packages/attributes/bin/build.ts +107 -0
- package/attributes-master/packages/attributes/bin/live-reload.js +1 -0
- package/attributes-master/packages/attributes/package.json +77 -0
- package/attributes-master/packages/attributes/playwright.config.ts +89 -0
- package/attributes-master/packages/attributes/src/attributes.ts +153 -0
- package/attributes-master/packages/attributes/src/load.ts +125 -0
- package/attributes-master/packages/attributes/tests/accordion.spec.ts +137 -0
- package/attributes-master/packages/attributes/tests/codehighlight.spec.ts +23 -0
- package/attributes-master/packages/attributes/tests/combobox.spec.ts +321 -0
- package/attributes-master/packages/attributes/tests/copyclip.spec.ts +19 -0
- package/attributes-master/packages/attributes/tests/displayvalues.spec.ts +48 -0
- package/attributes-master/packages/attributes/tests/favcustom.spec.ts +23 -0
- package/attributes-master/packages/attributes/tests/inject.spec.ts +40 -0
- package/attributes-master/packages/attributes/tests/inputactive.spec.ts +77 -0
- package/attributes-master/packages/attributes/tests/inputcounter.spec.ts +83 -0
- package/attributes-master/packages/attributes/tests/list.spec.ts +800 -0
- package/attributes-master/packages/attributes/tests/mirrorclick.spec.ts +22 -0
- package/attributes-master/packages/attributes/tests/mirrorinput.spec.ts +37 -0
- package/attributes-master/packages/attributes/tests/modal.spec.ts +34 -0
- package/attributes-master/packages/attributes/tests/numbercount.spec.ts +40 -0
- package/attributes-master/packages/attributes/tests/readtime.spec.ts +19 -0
- package/attributes-master/packages/attributes/tests/selectcustom.spec.ts +51 -0
- package/attributes-master/packages/attributes/tests/socialshare.spec.ts +54 -0
- package/attributes-master/packages/attributes/tests/starrating.spec.ts +79 -0
- package/attributes-master/packages/attributes/tests/toc.spec.ts +38 -0
- package/attributes-master/packages/attributes/tests/utils/index.ts +16 -0
- package/attributes-master/packages/attributes/tsconfig.json +6 -0
- package/attributes-master/packages/autovideo/CHANGELOG.md +182 -0
- package/attributes-master/packages/autovideo/README.md +31 -0
- package/attributes-master/packages/autovideo/package.json +22 -0
- package/attributes-master/packages/autovideo/src/index.ts +3 -0
- package/attributes-master/packages/autovideo/src/init.ts +52 -0
- package/attributes-master/packages/autovideo/src/types.ts +5 -0
- package/attributes-master/packages/autovideo/src/utils/constants.ts +4 -0
- package/attributes-master/packages/autovideo/tsconfig.json +3 -0
- package/attributes-master/packages/codehighlight/CHANGELOG.md +185 -0
- package/attributes-master/packages/codehighlight/README.md +27 -0
- package/attributes-master/packages/codehighlight/package.json +23 -0
- package/attributes-master/packages/codehighlight/src/actions/import.ts +50 -0
- package/attributes-master/packages/codehighlight/src/index.ts +3 -0
- package/attributes-master/packages/codehighlight/src/init.ts +53 -0
- package/attributes-master/packages/codehighlight/src/utils/constants.ts +24 -0
- package/attributes-master/packages/codehighlight/src/utils/selectors.ts +5 -0
- package/attributes-master/packages/codehighlight/src/utils/themes.ts +202 -0
- package/attributes-master/packages/codehighlight/tsconfig.json +3 -0
- package/attributes-master/packages/combobox/CHANGELOG.md +99 -0
- package/attributes-master/packages/combobox/README.md +27 -0
- package/attributes-master/packages/combobox/package.json +23 -0
- package/attributes-master/packages/combobox/src/actions/a11y.ts +29 -0
- package/attributes-master/packages/combobox/src/actions/body/index.ts +12 -0
- package/attributes-master/packages/combobox/src/actions/clearDropdown/index.ts +37 -0
- package/attributes-master/packages/combobox/src/actions/dropdownList/index.ts +220 -0
- package/attributes-master/packages/combobox/src/actions/dropdownToggle/index.ts +34 -0
- package/attributes-master/packages/combobox/src/actions/events.ts +75 -0
- package/attributes-master/packages/combobox/src/actions/input/index.ts +235 -0
- package/attributes-master/packages/combobox/src/actions/observe.ts +158 -0
- package/attributes-master/packages/combobox/src/actions/populate.ts +97 -0
- package/attributes-master/packages/combobox/src/actions/selectElement/index.ts +23 -0
- package/attributes-master/packages/combobox/src/actions/settings.ts +134 -0
- package/attributes-master/packages/combobox/src/actions/state.ts +34 -0
- package/attributes-master/packages/combobox/src/index.ts +3 -0
- package/attributes-master/packages/combobox/src/init.ts +52 -0
- package/attributes-master/packages/combobox/src/utils/constants.ts +48 -0
- package/attributes-master/packages/combobox/src/utils/dropdowns.ts +120 -0
- package/attributes-master/packages/combobox/src/utils/index.ts +1 -0
- package/attributes-master/packages/combobox/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/combobox/src/utils/types.ts +14 -0
- package/attributes-master/packages/combobox/tsconfig.json +3 -0
- package/attributes-master/packages/copyclip/CHANGELOG.md +213 -0
- package/attributes-master/packages/copyclip/README.md +27 -0
- package/attributes-master/packages/copyclip/package.json +23 -0
- package/attributes-master/packages/copyclip/src/factory.ts +67 -0
- package/attributes-master/packages/copyclip/src/index.ts +3 -0
- package/attributes-master/packages/copyclip/src/init.ts +68 -0
- package/attributes-master/packages/copyclip/src/utils/constants.ts +40 -0
- package/attributes-master/packages/copyclip/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/copyclip/tsconfig.json +3 -0
- package/attributes-master/packages/displayvalues/CHANGELOG.md +164 -0
- package/attributes-master/packages/displayvalues/README.md +27 -0
- package/attributes-master/packages/displayvalues/package.json +22 -0
- package/attributes-master/packages/displayvalues/src/actions/collect.ts +17 -0
- package/attributes-master/packages/displayvalues/src/actions/events.ts +22 -0
- package/attributes-master/packages/displayvalues/src/actions/sync.ts +23 -0
- package/attributes-master/packages/displayvalues/src/index.ts +3 -0
- package/attributes-master/packages/displayvalues/src/init.ts +31 -0
- package/attributes-master/packages/displayvalues/src/utils/constants.ts +20 -0
- package/attributes-master/packages/displayvalues/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/displayvalues/src/utils/stores.ts +3 -0
- package/attributes-master/packages/displayvalues/tsconfig.json +3 -0
- package/attributes-master/packages/docs/CHANGELOG.md +108 -0
- package/attributes-master/packages/docs/README.md +3 -0
- package/attributes-master/packages/docs/bin/build.js +92 -0
- package/attributes-master/packages/docs/bin/live-reload.js +1 -0
- package/attributes-master/packages/docs/package.json +40 -0
- package/attributes-master/packages/docs/src/copy.ts +260 -0
- package/attributes-master/packages/docs/src/x-ray.ts +377 -0
- package/attributes-master/packages/docs/tsconfig.json +3 -0
- package/attributes-master/packages/favcustom/CHANGELOG.md +194 -0
- package/attributes-master/packages/favcustom/README.md +27 -0
- package/attributes-master/packages/favcustom/package.json +22 -0
- package/attributes-master/packages/favcustom/src/index.ts +3 -0
- package/attributes-master/packages/favcustom/src/init.ts +30 -0
- package/attributes-master/packages/favcustom/src/utils/constants.ts +10 -0
- package/attributes-master/packages/favcustom/src/utils/selectors.ts +5 -0
- package/attributes-master/packages/favcustom/tsconfig.json +3 -0
- package/attributes-master/packages/formsubmit/CHANGELOG.md +161 -0
- package/attributes-master/packages/formsubmit/README.md +51 -0
- package/attributes-master/packages/formsubmit/package.json +22 -0
- package/attributes-master/packages/formsubmit/src/actions/redirect.ts +9 -0
- package/attributes-master/packages/formsubmit/src/actions/reset.ts +49 -0
- package/attributes-master/packages/formsubmit/src/actions/submit.ts +34 -0
- package/attributes-master/packages/formsubmit/src/components/Form.ts +231 -0
- package/attributes-master/packages/formsubmit/src/factory.ts +62 -0
- package/attributes-master/packages/formsubmit/src/index.ts +3 -0
- package/attributes-master/packages/formsubmit/src/init.ts +24 -0
- package/attributes-master/packages/formsubmit/src/utils/attributes.ts +19 -0
- package/attributes-master/packages/formsubmit/src/utils/constants.ts +89 -0
- package/attributes-master/packages/formsubmit/src/utils/dom.ts +76 -0
- package/attributes-master/packages/formsubmit/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/formsubmit/src/utils/types.ts +7 -0
- package/attributes-master/packages/formsubmit/tsconfig.json +3 -0
- package/attributes-master/packages/inject/CHANGELOG.md +117 -0
- package/attributes-master/packages/inject/README.md +60 -0
- package/attributes-master/packages/inject/package.json +22 -0
- package/attributes-master/packages/inject/src/actions/collect.ts +125 -0
- package/attributes-master/packages/inject/src/actions/css.ts +27 -0
- package/attributes-master/packages/inject/src/actions/prefetch.ts +44 -0
- package/attributes-master/packages/inject/src/factory.ts +123 -0
- package/attributes-master/packages/inject/src/index.ts +3 -0
- package/attributes-master/packages/inject/src/init.ts +22 -0
- package/attributes-master/packages/inject/src/utils/constants.ts +89 -0
- package/attributes-master/packages/inject/src/utils/helpers.ts +36 -0
- package/attributes-master/packages/inject/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/inject/src/utils/types.ts +16 -0
- package/attributes-master/packages/inject/tsconfig.json +3 -0
- package/attributes-master/packages/inputactive/CHANGELOG.md +58 -0
- package/attributes-master/packages/inputactive/README.md +25 -0
- package/attributes-master/packages/inputactive/package.json +22 -0
- package/attributes-master/packages/inputactive/src/actions/classes.ts +43 -0
- package/attributes-master/packages/inputactive/src/factory.ts +24 -0
- package/attributes-master/packages/inputactive/src/index.ts +3 -0
- package/attributes-master/packages/inputactive/src/init.ts +18 -0
- package/attributes-master/packages/inputactive/src/utils/constants.ts +13 -0
- package/attributes-master/packages/inputactive/src/utils/selectors.ts +5 -0
- package/attributes-master/packages/inputactive/tsconfig.json +3 -0
- package/attributes-master/packages/inputcounter/CHANGELOG.md +110 -0
- package/attributes-master/packages/inputcounter/README.md +25 -0
- package/attributes-master/packages/inputcounter/package.json +22 -0
- package/attributes-master/packages/inputcounter/src/actions/a11y.ts +23 -0
- package/attributes-master/packages/inputcounter/src/actions/buttons.ts +61 -0
- package/attributes-master/packages/inputcounter/src/actions/input.ts +31 -0
- package/attributes-master/packages/inputcounter/src/actions/style.ts +12 -0
- package/attributes-master/packages/inputcounter/src/factory.ts +51 -0
- package/attributes-master/packages/inputcounter/src/index.ts +3 -0
- package/attributes-master/packages/inputcounter/src/init.ts +22 -0
- package/attributes-master/packages/inputcounter/src/utils/constants.ts +59 -0
- package/attributes-master/packages/inputcounter/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/inputcounter/tsconfig.json +3 -0
- package/attributes-master/packages/list/CHANGELOG.md +185 -0
- package/attributes-master/packages/list/README.md +331 -0
- package/attributes-master/packages/list/package.json +37 -0
- package/attributes-master/packages/list/src/combine/index.ts +38 -0
- package/attributes-master/packages/list/src/components/List.ts +861 -0
- package/attributes-master/packages/list/src/components/ListItem.ts +229 -0
- package/attributes-master/packages/list/src/components/index.ts +2 -0
- package/attributes-master/packages/list/src/factory.ts +130 -0
- package/attributes-master/packages/list/src/filter/dynamic/conditions.ts +639 -0
- package/attributes-master/packages/list/src/filter/dynamic/groups.ts +221 -0
- package/attributes-master/packages/list/src/filter/dynamic/index.ts +119 -0
- package/attributes-master/packages/list/src/filter/dynamic/utils.ts +44 -0
- package/attributes-master/packages/list/src/filter/elements.ts +93 -0
- package/attributes-master/packages/list/src/filter/filter.ts +118 -0
- package/attributes-master/packages/list/src/filter/filter.worker.ts +152 -0
- package/attributes-master/packages/list/src/filter/index.ts +94 -0
- package/attributes-master/packages/list/src/filter/standard/conditions.ts +123 -0
- package/attributes-master/packages/list/src/filter/standard/facets.ts +253 -0
- package/attributes-master/packages/list/src/filter/standard/index.ts +176 -0
- package/attributes-master/packages/list/src/filter/standard/query.ts +111 -0
- package/attributes-master/packages/list/src/filter/tags.ts +314 -0
- package/attributes-master/packages/list/src/filter/types.ts +62 -0
- package/attributes-master/packages/list/src/filter/utils.ts +126 -0
- package/attributes-master/packages/list/src/index.ts +4 -0
- package/attributes-master/packages/list/src/init.ts +38 -0
- package/attributes-master/packages/list/src/load/all.ts +27 -0
- package/attributes-master/packages/list/src/load/elements.ts +39 -0
- package/attributes-master/packages/list/src/load/index.ts +63 -0
- package/attributes-master/packages/list/src/load/infinite.ts +79 -0
- package/attributes-master/packages/list/src/load/load.ts +191 -0
- package/attributes-master/packages/list/src/load/more.ts +97 -0
- package/attributes-master/packages/list/src/load/pagination.ts +402 -0
- package/attributes-master/packages/list/src/nest/index.ts +198 -0
- package/attributes-master/packages/list/src/prevnext/index.ts +98 -0
- package/attributes-master/packages/list/src/select/index.ts +56 -0
- package/attributes-master/packages/list/src/slider/index.ts +62 -0
- package/attributes-master/packages/list/src/sort/buttons.ts +96 -0
- package/attributes-master/packages/list/src/sort/dropdown.ts +179 -0
- package/attributes-master/packages/list/src/sort/index.ts +81 -0
- package/attributes-master/packages/list/src/sort/query.ts +63 -0
- package/attributes-master/packages/list/src/sort/select.ts +67 -0
- package/attributes-master/packages/list/src/sort/sort.ts +79 -0
- package/attributes-master/packages/list/src/sort/types.ts +28 -0
- package/attributes-master/packages/list/src/static/index.ts +73 -0
- package/attributes-master/packages/list/src/tabs/index.ts +97 -0
- package/attributes-master/packages/list/src/utils/constants.ts +728 -0
- package/attributes-master/packages/list/src/utils/dom.ts +108 -0
- package/attributes-master/packages/list/src/utils/pagination.ts +14 -0
- package/attributes-master/packages/list/src/utils/selectors.ts +18 -0
- package/attributes-master/packages/list/src/utils/store.ts +5 -0
- package/attributes-master/packages/list/tsconfig.json +3 -0
- package/attributes-master/packages/mirrorclick/CHANGELOG.md +171 -0
- package/attributes-master/packages/mirrorclick/README.md +25 -0
- package/attributes-master/packages/mirrorclick/package.json +22 -0
- package/attributes-master/packages/mirrorclick/src/index.ts +3 -0
- package/attributes-master/packages/mirrorclick/src/init.ts +35 -0
- package/attributes-master/packages/mirrorclick/src/utils/constants.ts +20 -0
- package/attributes-master/packages/mirrorclick/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/mirrorclick/tsconfig.json +3 -0
- package/attributes-master/packages/mirrorinput/CHANGELOG.md +172 -0
- package/attributes-master/packages/mirrorinput/README.md +25 -0
- package/attributes-master/packages/mirrorinput/package.json +22 -0
- package/attributes-master/packages/mirrorinput/src/index.ts +3 -0
- package/attributes-master/packages/mirrorinput/src/init.ts +48 -0
- package/attributes-master/packages/mirrorinput/src/utils/constants.ts +15 -0
- package/attributes-master/packages/mirrorinput/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/mirrorinput/tsconfig.json +3 -0
- package/attributes-master/packages/modal/CHANGELOG.md +94 -0
- package/attributes-master/packages/modal/README.md +29 -0
- package/attributes-master/packages/modal/package.json +23 -0
- package/attributes-master/packages/modal/src/actions/a11y.ts +46 -0
- package/attributes-master/packages/modal/src/actions/modal.ts +164 -0
- package/attributes-master/packages/modal/src/actions/settings.ts +21 -0
- package/attributes-master/packages/modal/src/factory.ts +26 -0
- package/attributes-master/packages/modal/src/index.ts +3 -0
- package/attributes-master/packages/modal/src/init.ts +22 -0
- package/attributes-master/packages/modal/src/utils/constants.ts +54 -0
- package/attributes-master/packages/modal/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/modal/src/utils/types.ts +12 -0
- package/attributes-master/packages/modal/tsconfig.json +3 -0
- package/attributes-master/packages/numbercount/CHANGELOG.md +90 -0
- package/attributes-master/packages/numbercount/README.md +27 -0
- package/attributes-master/packages/numbercount/package.json +23 -0
- package/attributes-master/packages/numbercount/src/actions/a11y.ts +26 -0
- package/attributes-master/packages/numbercount/src/actions/animate.ts +43 -0
- package/attributes-master/packages/numbercount/src/actions/observe.ts +44 -0
- package/attributes-master/packages/numbercount/src/factory.ts +31 -0
- package/attributes-master/packages/numbercount/src/index.ts +3 -0
- package/attributes-master/packages/numbercount/src/init.ts +22 -0
- package/attributes-master/packages/numbercount/src/utils/constants.ts +40 -0
- package/attributes-master/packages/numbercount/src/utils/helpers.ts +31 -0
- package/attributes-master/packages/numbercount/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/numbercount/tsconfig.json +3 -0
- package/attributes-master/packages/queryparam/CHANGELOG.md +118 -0
- package/attributes-master/packages/queryparam/README.md +25 -0
- package/attributes-master/packages/queryparam/package.json +22 -0
- package/attributes-master/packages/queryparam/src/factory.ts +51 -0
- package/attributes-master/packages/queryparam/src/index.ts +3 -0
- package/attributes-master/packages/queryparam/src/init.ts +40 -0
- package/attributes-master/packages/queryparam/src/utils/constants.ts +18 -0
- package/attributes-master/packages/queryparam/src/utils/selectors.ts +5 -0
- package/attributes-master/packages/queryparam/tsconfig.json +3 -0
- package/attributes-master/packages/rangeslider/CHANGELOG.md +236 -0
- package/attributes-master/packages/rangeslider/README.md +95 -0
- package/attributes-master/packages/rangeslider/package.json +23 -0
- package/attributes-master/packages/rangeslider/src/actions/a11y.ts +21 -0
- package/attributes-master/packages/rangeslider/src/actions/events.ts +9 -0
- package/attributes-master/packages/rangeslider/src/actions/settings.ts +97 -0
- package/attributes-master/packages/rangeslider/src/actions/styles.ts +10 -0
- package/attributes-master/packages/rangeslider/src/actions/values.ts +47 -0
- package/attributes-master/packages/rangeslider/src/components/Fill.ts +70 -0
- package/attributes-master/packages/rangeslider/src/components/Handle.ts +281 -0
- package/attributes-master/packages/rangeslider/src/factory.ts +100 -0
- package/attributes-master/packages/rangeslider/src/index.ts +3 -0
- package/attributes-master/packages/rangeslider/src/init.ts +194 -0
- package/attributes-master/packages/rangeslider/src/utils/constants.ts +87 -0
- package/attributes-master/packages/rangeslider/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/rangeslider/src/utils/types.ts +6 -0
- package/attributes-master/packages/rangeslider/tsconfig.json +3 -0
- package/attributes-master/packages/readtime/CHANGELOG.md +108 -0
- package/attributes-master/packages/readtime/README.md +25 -0
- package/attributes-master/packages/readtime/package.json +22 -0
- package/attributes-master/packages/readtime/src/factory.ts +21 -0
- package/attributes-master/packages/readtime/src/index.ts +3 -0
- package/attributes-master/packages/readtime/src/init.ts +19 -0
- package/attributes-master/packages/readtime/src/utils/constants.ts +33 -0
- package/attributes-master/packages/readtime/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/readtime/tsconfig.json +3 -0
- package/attributes-master/packages/removequery/CHANGELOG.md +8 -0
- package/attributes-master/packages/removequery/README.md +25 -0
- package/attributes-master/packages/removequery/package.json +22 -0
- package/attributes-master/packages/removequery/src/index.ts +3 -0
- package/attributes-master/packages/removequery/src/init.ts +18 -0
- package/attributes-master/packages/removequery/src/utils/constants.ts +5 -0
- package/attributes-master/packages/removequery/tsconfig.json +3 -0
- package/attributes-master/packages/scrolldisable/CHANGELOG.md +164 -0
- package/attributes-master/packages/scrolldisable/README.md +29 -0
- package/attributes-master/packages/scrolldisable/package.json +27 -0
- package/attributes-master/packages/scrolldisable/src/click.ts +40 -0
- package/attributes-master/packages/scrolldisable/src/display.ts +117 -0
- package/attributes-master/packages/scrolldisable/src/index.ts +3 -0
- package/attributes-master/packages/scrolldisable/src/init.ts +36 -0
- package/attributes-master/packages/scrolldisable/src/scroll.ts +63 -0
- package/attributes-master/packages/scrolldisable/src/utils/constants.ts +56 -0
- package/attributes-master/packages/scrolldisable/src/utils/selectors.ts +6 -0
- package/attributes-master/packages/scrolldisable/tsconfig.json +3 -0
- package/attributes-master/packages/selectcustom/CHANGELOG.md +242 -0
- package/attributes-master/packages/selectcustom/README.md +25 -0
- package/attributes-master/packages/selectcustom/package.json +23 -0
- package/attributes-master/packages/selectcustom/src/actions/a11y.ts +29 -0
- package/attributes-master/packages/selectcustom/src/actions/events.ts +159 -0
- package/attributes-master/packages/selectcustom/src/actions/observe.ts +83 -0
- package/attributes-master/packages/selectcustom/src/actions/populate.ts +67 -0
- package/attributes-master/packages/selectcustom/src/actions/settings.ts +68 -0
- package/attributes-master/packages/selectcustom/src/actions/state.ts +41 -0
- package/attributes-master/packages/selectcustom/src/index.ts +3 -0
- package/attributes-master/packages/selectcustom/src/init.ts +51 -0
- package/attributes-master/packages/selectcustom/src/utils/constants.ts +34 -0
- package/attributes-master/packages/selectcustom/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/selectcustom/src/utils/types.ts +14 -0
- package/attributes-master/packages/selectcustom/tsconfig.json +3 -0
- package/attributes-master/packages/sliderdots/CHANGELOG.md +220 -0
- package/attributes-master/packages/sliderdots/README.md +27 -0
- package/attributes-master/packages/sliderdots/package.json +22 -0
- package/attributes-master/packages/sliderdots/src/actions/events.ts +26 -0
- package/attributes-master/packages/sliderdots/src/actions/observe.ts +40 -0
- package/attributes-master/packages/sliderdots/src/actions/populate.ts +46 -0
- package/attributes-master/packages/sliderdots/src/actions/sync.ts +28 -0
- package/attributes-master/packages/sliderdots/src/actions/wait.ts +28 -0
- package/attributes-master/packages/sliderdots/src/factory.ts +57 -0
- package/attributes-master/packages/sliderdots/src/index.ts +3 -0
- package/attributes-master/packages/sliderdots/src/init.ts +30 -0
- package/attributes-master/packages/sliderdots/src/utils/constants.ts +33 -0
- package/attributes-master/packages/sliderdots/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/sliderdots/src/utils/types.ts +7 -0
- package/attributes-master/packages/sliderdots/tsconfig.json +3 -0
- package/attributes-master/packages/smartlightbox/CHANGELOG.md +203 -0
- package/attributes-master/packages/smartlightbox/README.md +25 -0
- package/attributes-master/packages/smartlightbox/package.json +22 -0
- package/attributes-master/packages/smartlightbox/src/actions/collect.ts +15 -0
- package/attributes-master/packages/smartlightbox/src/actions/move.ts +25 -0
- package/attributes-master/packages/smartlightbox/src/index.ts +3 -0
- package/attributes-master/packages/smartlightbox/src/init.ts +61 -0
- package/attributes-master/packages/smartlightbox/src/utils/constants.ts +31 -0
- package/attributes-master/packages/smartlightbox/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/smartlightbox/tsconfig.json +3 -0
- package/attributes-master/packages/socialshare/CHANGELOG.md +170 -0
- package/attributes-master/packages/socialshare/README.md +25 -0
- package/attributes-master/packages/socialshare/package.json +25 -0
- package/attributes-master/packages/socialshare/src/actions/collect.ts +93 -0
- package/attributes-master/packages/socialshare/src/actions/share.ts +91 -0
- package/attributes-master/packages/socialshare/src/actions/trigger.ts +46 -0
- package/attributes-master/packages/socialshare/src/factory.ts +149 -0
- package/attributes-master/packages/socialshare/src/index.ts +3 -0
- package/attributes-master/packages/socialshare/src/init.ts +35 -0
- package/attributes-master/packages/socialshare/src/utils/constants.ts +94 -0
- package/attributes-master/packages/socialshare/src/utils/dom.ts +8 -0
- package/attributes-master/packages/socialshare/src/utils/selectors.ts +6 -0
- package/attributes-master/packages/socialshare/src/utils/stores.ts +10 -0
- package/attributes-master/packages/socialshare/src/utils/types.ts +34 -0
- package/attributes-master/packages/socialshare/tsconfig.json +3 -0
- package/attributes-master/packages/starrating/CHANGELOG.md +70 -0
- package/attributes-master/packages/starrating/README.md +25 -0
- package/attributes-master/packages/starrating/package.json +22 -0
- package/attributes-master/packages/starrating/src/actions/classes.ts +41 -0
- package/attributes-master/packages/starrating/src/actions/events.ts +80 -0
- package/attributes-master/packages/starrating/src/factory.ts +24 -0
- package/attributes-master/packages/starrating/src/index.ts +3 -0
- package/attributes-master/packages/starrating/src/init.ts +24 -0
- package/attributes-master/packages/starrating/src/utils/constants.ts +20 -0
- package/attributes-master/packages/starrating/src/utils/helpers.ts +63 -0
- package/attributes-master/packages/starrating/src/utils/selectors.ts +9 -0
- package/attributes-master/packages/starrating/tsconfig.json +3 -0
- package/attributes-master/packages/template/README.md +25 -0
- package/attributes-master/packages/template/package.json +22 -0
- package/attributes-master/packages/template/src/actions/console.ts +4 -0
- package/attributes-master/packages/template/src/index.ts +3 -0
- package/attributes-master/packages/template/src/init.ts +14 -0
- package/attributes-master/packages/template/src/utils/constants.ts +18 -0
- package/attributes-master/packages/template/src/utils/selectors.ts +5 -0
- package/attributes-master/packages/template/tsconfig.json +3 -0
- package/attributes-master/packages/toc/CHANGELOG.md +192 -0
- package/attributes-master/packages/toc/README.md +25 -0
- package/attributes-master/packages/toc/package.json +23 -0
- package/attributes-master/packages/toc/src/actions/collect.ts +136 -0
- package/attributes-master/packages/toc/src/actions/create.ts +44 -0
- package/attributes-master/packages/toc/src/actions/events.ts +29 -0
- package/attributes-master/packages/toc/src/actions/observe.ts +31 -0
- package/attributes-master/packages/toc/src/actions/populate.ts +68 -0
- package/attributes-master/packages/toc/src/actions/prepare.ts +25 -0
- package/attributes-master/packages/toc/src/actions/scroll.ts +33 -0
- package/attributes-master/packages/toc/src/components/TOCItem.ts +88 -0
- package/attributes-master/packages/toc/src/factory.ts +47 -0
- package/attributes-master/packages/toc/src/index.ts +3 -0
- package/attributes-master/packages/toc/src/init.ts +37 -0
- package/attributes-master/packages/toc/src/utils/constants.ts +55 -0
- package/attributes-master/packages/toc/src/utils/helpers.ts +23 -0
- package/attributes-master/packages/toc/src/utils/selectors.ts +6 -0
- package/attributes-master/packages/toc/src/utils/types.ts +21 -0
- package/attributes-master/packages/toc/tsconfig.json +3 -0
- package/attributes-master/packages/utils/CHANGELOG.md +43 -0
- package/attributes-master/packages/utils/package.json +27 -0
- package/attributes-master/packages/utils/src/animations/factory.ts +100 -0
- package/attributes-master/packages/utils/src/animations/index.ts +73 -0
- package/attributes-master/packages/utils/src/animations/types.ts +37 -0
- package/attributes-master/packages/utils/src/components/Interaction.ts +79 -0
- package/attributes-master/packages/utils/src/components/Renderer.ts +59 -0
- package/attributes-master/packages/utils/src/components/index.ts +2 -0
- package/attributes-master/packages/utils/src/constants/a11y.ts +50 -0
- package/attributes-master/packages/utils/src/constants/attributes.ts +57 -0
- package/attributes-master/packages/utils/src/constants/index.ts +5 -0
- package/attributes-master/packages/utils/src/constants/keyboard.ts +10 -0
- package/attributes-master/packages/utils/src/constants/webflow.ts +74 -0
- package/attributes-master/packages/utils/src/helpers/dates.ts +17 -0
- package/attributes-master/packages/utils/src/helpers/dom.ts +82 -0
- package/attributes-master/packages/utils/src/helpers/events.ts +59 -0
- package/attributes-master/packages/utils/src/helpers/fetch.ts +217 -0
- package/attributes-master/packages/utils/src/helpers/forms.ts +238 -0
- package/attributes-master/packages/utils/src/helpers/guards.ts +138 -0
- package/attributes-master/packages/utils/src/helpers/index.ts +11 -0
- package/attributes-master/packages/utils/src/helpers/numbers.ts +86 -0
- package/attributes-master/packages/utils/src/helpers/selectors.ts +249 -0
- package/attributes-master/packages/utils/src/helpers/strings.ts +19 -0
- package/attributes-master/packages/utils/src/helpers/wait.ts +36 -0
- package/attributes-master/packages/utils/src/helpers/webflow.ts +117 -0
- package/attributes-master/packages/utils/src/index.ts +5 -0
- package/attributes-master/packages/utils/src/types/core.ts +100 -0
- package/attributes-master/packages/utils/src/types/dom.ts +31 -0
- package/attributes-master/packages/utils/src/types/index.ts +4 -0
- package/attributes-master/packages/utils/src/types/utils.ts +20 -0
- package/attributes-master/packages/utils/src/types/webflow.ts +147 -0
- package/attributes-master/packages/utils/tsconfig.json +3 -0
- package/attributes-master/packages/videohls/CHANGELOG.md +76 -0
- package/attributes-master/packages/videohls/README.md +27 -0
- package/attributes-master/packages/videohls/package.json +26 -0
- package/attributes-master/packages/videohls/src/actions/list.ts +23 -0
- package/attributes-master/packages/videohls/src/actions/video.ts +44 -0
- package/attributes-master/packages/videohls/src/index.ts +3 -0
- package/attributes-master/packages/videohls/src/init.ts +28 -0
- package/attributes-master/packages/videohls/src/utils/constants.ts +12 -0
- package/attributes-master/packages/videohls/src/utils/selectors.ts +5 -0
- package/attributes-master/packages/videohls/src/utils/stores.ts +3 -0
- package/attributes-master/packages/videohls/tsconfig.json +3 -0
- package/attributes-master/pnpm-lock.yaml +3317 -0
- package/attributes-master/pnpm-workspace.yaml +3 -0
- package/attributes-master/tsconfig.json +6 -0
- package/index.js +173 -257
- package/package.json +1 -1
@@ -0,0 +1,56 @@
|
|
1
|
+
import { isHTMLSelectElement } from '@finsweet/attributes-utils';
|
2
|
+
|
3
|
+
import type { List } from '../components';
|
4
|
+
import { queryAllElements } from '../utils/selectors';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Inits the list select dropdowns.
|
8
|
+
* @param list
|
9
|
+
* @param selectElements
|
10
|
+
*/
|
11
|
+
export const initListSelects = (list: List, selectElements: HTMLElement[]) => {
|
12
|
+
list.webflowModules.add('slider');
|
13
|
+
|
14
|
+
selectElements.forEach((sliderReference) => initListSelect(list, sliderReference));
|
15
|
+
};
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Inits a list select dropdown.
|
19
|
+
* @param list
|
20
|
+
* @param selectElement
|
21
|
+
*/
|
22
|
+
const initListSelect = (list: List, selectElement: HTMLElement) => {
|
23
|
+
if (!isHTMLSelectElement(selectElement)) return;
|
24
|
+
|
25
|
+
// Store rendered options
|
26
|
+
const renderedOptions = new Map<string, HTMLOptionElement>();
|
27
|
+
|
28
|
+
// Handle items
|
29
|
+
list.addHook('render', (items = []) => {
|
30
|
+
const allOptionValues = new Set<string>();
|
31
|
+
|
32
|
+
for (const item of items) {
|
33
|
+
const optionValues = queryAllElements('select-value', { scope: item.element });
|
34
|
+
|
35
|
+
for (const optionValue of optionValues) {
|
36
|
+
allOptionValues.add(optionValue.innerText);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
for (const optionValue of allOptionValues) {
|
41
|
+
if (renderedOptions.has(optionValue)) continue;
|
42
|
+
|
43
|
+
const option = new Option(optionValue, optionValue);
|
44
|
+
|
45
|
+
selectElement.options.add(option);
|
46
|
+
renderedOptions.set(optionValue, option);
|
47
|
+
}
|
48
|
+
|
49
|
+
for (const [optionValue, option] of renderedOptions) {
|
50
|
+
if (allOptionValues.has(optionValue)) continue;
|
51
|
+
|
52
|
+
option?.remove();
|
53
|
+
renderedOptions.delete(optionValue);
|
54
|
+
}
|
55
|
+
});
|
56
|
+
};
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { ARIA_ROLE_KEY, SLIDER_CSS_CLASSES } from '@finsweet/attributes-utils';
|
2
|
+
|
3
|
+
import type { List, ListItem } from '../components';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Inits the list sliders.
|
7
|
+
* @param list
|
8
|
+
* @param slidersReferences
|
9
|
+
*/
|
10
|
+
export const initListSliders = (list: List, slidersReferences: HTMLElement[]) => {
|
11
|
+
list.webflowModules.add('slider');
|
12
|
+
|
13
|
+
slidersReferences.forEach((sliderReference) => initListSlider(list, sliderReference));
|
14
|
+
};
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Inits a list slider.
|
18
|
+
* @param list
|
19
|
+
* @param sliderReference
|
20
|
+
*/
|
21
|
+
const initListSlider = (list: List, sliderReference: HTMLElement) => {
|
22
|
+
const sliderElement = sliderReference.closest(`.${SLIDER_CSS_CLASSES.slider}`);
|
23
|
+
if (!sliderElement) return;
|
24
|
+
|
25
|
+
const sliderMask = sliderElement.querySelector(`.${SLIDER_CSS_CLASSES.sliderMask}`);
|
26
|
+
if (!sliderMask) return;
|
27
|
+
|
28
|
+
const existingSlides = sliderElement.querySelectorAll(`.${SLIDER_CSS_CLASSES.slide}`);
|
29
|
+
if (!existingSlides.length) return;
|
30
|
+
|
31
|
+
// Store the template CSS classes
|
32
|
+
const slideCSS = existingSlides[0].classList.value;
|
33
|
+
|
34
|
+
// Remove existing slides
|
35
|
+
for (const slide of existingSlides) slide.remove();
|
36
|
+
|
37
|
+
// Store rendered items
|
38
|
+
const renderedItems = new Map<ListItem, HTMLDivElement>();
|
39
|
+
|
40
|
+
list.addHook('render', (items = []) => {
|
41
|
+
for (const item of items) {
|
42
|
+
if (renderedItems.has(item)) continue;
|
43
|
+
|
44
|
+
item.element.removeAttribute(ARIA_ROLE_KEY);
|
45
|
+
|
46
|
+
const newSlide = document.createElement('div');
|
47
|
+
newSlide.setAttribute('class', slideCSS);
|
48
|
+
|
49
|
+
newSlide.appendChild(item.element);
|
50
|
+
sliderMask.appendChild(newSlide);
|
51
|
+
|
52
|
+
renderedItems.set(item, newSlide);
|
53
|
+
}
|
54
|
+
|
55
|
+
for (const [item, slide] of renderedItems) {
|
56
|
+
if (items.includes(item)) continue;
|
57
|
+
|
58
|
+
slide?.remove();
|
59
|
+
renderedItems.delete(item);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
};
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import {
|
2
|
+
addListener,
|
3
|
+
ARIA_ROLE_KEY,
|
4
|
+
ARIA_ROLE_VALUES,
|
5
|
+
ARIA_SORT_KEY,
|
6
|
+
ARIA_SORT_VALUES,
|
7
|
+
isNotEmpty,
|
8
|
+
TABINDEX_KEY,
|
9
|
+
} from '@finsweet/attributes-utils';
|
10
|
+
import { computed, effect, ref } from '@vue/reactivity';
|
11
|
+
|
12
|
+
import type { List } from '../components/List';
|
13
|
+
import { getAttribute, hasAttributeValue } from '../utils/selectors';
|
14
|
+
import type { SortingDirection } from './types';
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Inits the sorting with a group of Buttons.
|
18
|
+
* @param buttons The button elements.
|
19
|
+
* @param list The {@link List} instance.
|
20
|
+
|
21
|
+
*/
|
22
|
+
export const initButtons = (buttons: HTMLElement[], list: List) => {
|
23
|
+
const activeButton = ref<HTMLElement | undefined>();
|
24
|
+
|
25
|
+
const cleanups = buttons
|
26
|
+
.flatMap((button) => {
|
27
|
+
const fieldKey = getAttribute(button, 'field')?.trim();
|
28
|
+
if (!fieldKey) return;
|
29
|
+
|
30
|
+
const reverse = hasAttributeValue(button, 'reverse', 'true');
|
31
|
+
const ascClass = getAttribute(button, 'ascclass');
|
32
|
+
const desClass = getAttribute(button, 'descclass');
|
33
|
+
|
34
|
+
const currentDirection = ref<SortingDirection | undefined>();
|
35
|
+
|
36
|
+
button.setAttribute(ARIA_ROLE_KEY, ARIA_ROLE_VALUES.columnheader);
|
37
|
+
button.setAttribute(TABINDEX_KEY, '0');
|
38
|
+
|
39
|
+
// Dynamically set the `aria-sort` attribute
|
40
|
+
const ariaSort = computed(() => {
|
41
|
+
if (activeButton.value !== button) return 'none';
|
42
|
+
|
43
|
+
return currentDirection.value === 'asc' ? ARIA_SORT_VALUES.ascending : ARIA_SORT_VALUES.descending;
|
44
|
+
});
|
45
|
+
|
46
|
+
const ariaSortRunner = effect(() => {
|
47
|
+
button.setAttribute(ARIA_SORT_KEY, ariaSort.value);
|
48
|
+
});
|
49
|
+
|
50
|
+
// Dynamically set the direction CSS class
|
51
|
+
const cssClass = computed(() => {
|
52
|
+
if (activeButton.value !== button) return null;
|
53
|
+
|
54
|
+
return currentDirection.value === 'asc' ? ascClass : desClass;
|
55
|
+
});
|
56
|
+
|
57
|
+
const cssClassRunner = effect(() => {
|
58
|
+
button.classList.remove(ascClass, desClass);
|
59
|
+
|
60
|
+
if (cssClass.value) {
|
61
|
+
button.classList.add(cssClass.value);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
// Sort on click
|
66
|
+
const clickCleanup = addListener(button, 'click', async (e) => {
|
67
|
+
e.preventDefault();
|
68
|
+
|
69
|
+
activeButton.value = button;
|
70
|
+
currentDirection.value = getNextDirection(currentDirection.value, reverse);
|
71
|
+
|
72
|
+
list.sorting.value = {
|
73
|
+
fieldKey,
|
74
|
+
direction: currentDirection.value,
|
75
|
+
interacted: true,
|
76
|
+
};
|
77
|
+
});
|
78
|
+
|
79
|
+
return [() => ariaSortRunner.effect.stop(), () => cssClassRunner.effect.stop(), clickCleanup];
|
80
|
+
})
|
81
|
+
.filter(isNotEmpty);
|
82
|
+
|
83
|
+
return () => {
|
84
|
+
for (const cleanup of cleanups) cleanup();
|
85
|
+
};
|
86
|
+
};
|
87
|
+
|
88
|
+
/**
|
89
|
+
* @returns The new direction of a button.
|
90
|
+
* @param currentDirection The current direction of a button.
|
91
|
+
*/
|
92
|
+
const getNextDirection = (currentDirection: SortingDirection | undefined, reverse: boolean): SortingDirection => {
|
93
|
+
if (!currentDirection) return reverse ? 'desc' : 'asc';
|
94
|
+
|
95
|
+
return currentDirection === 'desc' ? 'asc' : 'desc';
|
96
|
+
};
|
@@ -0,0 +1,179 @@
|
|
1
|
+
import {
|
2
|
+
addListener,
|
3
|
+
ARIA_HASPOPUP_KEY,
|
4
|
+
ARIA_MULTISELECTABLE_KEY,
|
5
|
+
ARIA_ROLE_KEY,
|
6
|
+
ARIA_ROLE_VALUES,
|
7
|
+
ARIA_SELECTED_KEY,
|
8
|
+
closeDropdown,
|
9
|
+
CURRENT_CSS_CLASS,
|
10
|
+
DROPDOWN_CSS_CLASSES,
|
11
|
+
type DropdownElement,
|
12
|
+
type DropdownList,
|
13
|
+
type DropdownToggle,
|
14
|
+
isElement,
|
15
|
+
} from '@finsweet/attributes-utils';
|
16
|
+
import { effect, type Ref, ref } from '@vue/reactivity';
|
17
|
+
|
18
|
+
import type { List } from '../components/List';
|
19
|
+
import { getAttribute, queryElement } from '../utils/selectors';
|
20
|
+
import type { SortingDirection } from './types';
|
21
|
+
|
22
|
+
type DropdownOption = {
|
23
|
+
element: HTMLAnchorElement;
|
24
|
+
fieldKey?: string;
|
25
|
+
direction?: SortingDirection;
|
26
|
+
cleanup: () => void;
|
27
|
+
};
|
28
|
+
|
29
|
+
type DropdownOptions = Map<HTMLAnchorElement, DropdownOption>;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Inits sorting on a `Dropdown` component.
|
33
|
+
* @param dropdown The {@link DropdownElement} element.
|
34
|
+
* @param list The {@link List} instance.
|
35
|
+
*/
|
36
|
+
export const initDropdown = (dropdown: DropdownElement, list: List) => {
|
37
|
+
const dropdownToggle = dropdown.querySelector<DropdownToggle>(`.${DROPDOWN_CSS_CLASSES.dropdownToggle}`);
|
38
|
+
const dropdownList = dropdown.querySelector<DropdownList>(`.${DROPDOWN_CSS_CLASSES.dropdownList}`);
|
39
|
+
|
40
|
+
if (!dropdownToggle || !dropdownList) {
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
|
44
|
+
setDropdownAria(dropdownToggle, dropdownList);
|
45
|
+
|
46
|
+
const activeOption = ref<DropdownOption | undefined>();
|
47
|
+
|
48
|
+
// Listen events
|
49
|
+
const dropdownLabelCleanup = initDropdownLabel(dropdownToggle, activeOption);
|
50
|
+
|
51
|
+
const dropdownOptions = initDropdownOptions(dropdownList, activeOption);
|
52
|
+
if (!dropdownOptions) {
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
56
|
+
const clickCleanup = addListener(dropdownList, 'click', async (e) => {
|
57
|
+
e.preventDefault();
|
58
|
+
|
59
|
+
const { target } = e;
|
60
|
+
|
61
|
+
if (!isElement(target)) {
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
|
65
|
+
const optionElement = target.closest('a');
|
66
|
+
if (!optionElement) return;
|
67
|
+
|
68
|
+
const optionData = dropdownOptions.get(optionElement);
|
69
|
+
if (!optionData) return;
|
70
|
+
|
71
|
+
const isSelected = activeOption.value?.element === optionElement;
|
72
|
+
if (isSelected) return;
|
73
|
+
|
74
|
+
activeOption.value = optionData;
|
75
|
+
|
76
|
+
list.sorting.value = {
|
77
|
+
fieldKey: optionData.fieldKey,
|
78
|
+
direction: optionData.direction,
|
79
|
+
interacted: true,
|
80
|
+
};
|
81
|
+
|
82
|
+
closeDropdown(dropdownToggle);
|
83
|
+
});
|
84
|
+
|
85
|
+
return () => {
|
86
|
+
dropdownLabelCleanup?.();
|
87
|
+
clickCleanup();
|
88
|
+
};
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Collects all options in the Dropdown.
|
93
|
+
* @param dropdownList The {@link DropdownList} element.
|
94
|
+
* @returns
|
95
|
+
*/
|
96
|
+
const initDropdownOptions = (dropdownList: DropdownList, activeOption: Ref<DropdownOption | undefined>) => {
|
97
|
+
const dropdownOptions: DropdownOptions = new Map();
|
98
|
+
|
99
|
+
const options = [...dropdownList.querySelectorAll('a')];
|
100
|
+
if (!options.length) return;
|
101
|
+
|
102
|
+
for (const element of options) {
|
103
|
+
element.setAttribute(ARIA_ROLE_KEY, ARIA_ROLE_VALUES.option);
|
104
|
+
|
105
|
+
const rawField = getAttribute(element, 'field')?.trim();
|
106
|
+
|
107
|
+
let fieldKey: string | undefined;
|
108
|
+
let direction: SortingDirection | undefined;
|
109
|
+
|
110
|
+
if (rawField) {
|
111
|
+
if (rawField.endsWith('-asc')) {
|
112
|
+
direction = 'asc';
|
113
|
+
fieldKey = rawField.slice(0, -4);
|
114
|
+
} else if (rawField.endsWith('-desc')) {
|
115
|
+
direction = 'desc';
|
116
|
+
fieldKey = rawField.slice(0, -5);
|
117
|
+
} else {
|
118
|
+
direction = 'asc';
|
119
|
+
fieldKey = rawField;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
// Handle active state
|
124
|
+
const runner = effect(() => {
|
125
|
+
const isSelected = activeOption.value?.element === element;
|
126
|
+
|
127
|
+
if (isSelected) {
|
128
|
+
element.setAttribute(ARIA_SELECTED_KEY, 'true');
|
129
|
+
element.classList.add(CURRENT_CSS_CLASS);
|
130
|
+
} else {
|
131
|
+
element.removeAttribute(ARIA_SELECTED_KEY);
|
132
|
+
element.classList.remove(CURRENT_CSS_CLASS);
|
133
|
+
}
|
134
|
+
});
|
135
|
+
|
136
|
+
dropdownOptions.set(element, {
|
137
|
+
element,
|
138
|
+
fieldKey,
|
139
|
+
direction,
|
140
|
+
cleanup: () => runner.effect.stop(),
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
return dropdownOptions;
|
145
|
+
};
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Dynamically updates the Dropdown label with the selected option.
|
149
|
+
* @param dropdownToggle The {@link DropdownToggle}.
|
150
|
+
* @returns A cleanup function.
|
151
|
+
*/
|
152
|
+
const initDropdownLabel = (dropdownToggle: DropdownToggle, activeOption: Ref<DropdownOption | undefined>) => {
|
153
|
+
const dropdownLabel = queryElement('dropdown-label', { scope: dropdownToggle });
|
154
|
+
if (!dropdownLabel) return;
|
155
|
+
|
156
|
+
const originalHTML = dropdownLabel.innerHTML;
|
157
|
+
|
158
|
+
const runner = effect(() => {
|
159
|
+
if (!activeOption.value) {
|
160
|
+
dropdownLabel.innerHTML = originalHTML;
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
|
164
|
+
dropdownLabel.innerHTML = activeOption.value.element.innerHTML;
|
165
|
+
});
|
166
|
+
|
167
|
+
return () => runner.effect.stop();
|
168
|
+
};
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Adds `a11y` attributes to the Dropdown elements.
|
172
|
+
* @param dropdownToggle The {@link DropdownToggle} element.
|
173
|
+
* @param dropdownList The {@link DropdownList} element.
|
174
|
+
*/
|
175
|
+
const setDropdownAria = (dropdownToggle: DropdownToggle, dropdownList: DropdownList) => {
|
176
|
+
dropdownToggle.setAttribute(ARIA_HASPOPUP_KEY, ARIA_ROLE_VALUES.listbox);
|
177
|
+
dropdownList.setAttribute(ARIA_ROLE_KEY, ARIA_ROLE_VALUES.listbox);
|
178
|
+
dropdownList.setAttribute(ARIA_MULTISELECTABLE_KEY, 'false');
|
179
|
+
};
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import { DROPDOWN_CSS_CLASSES, type DropdownElement, isHTMLSelectElement } from '@finsweet/attributes-utils';
|
2
|
+
import { watch } from '@vue/reactivity';
|
3
|
+
import debounce from 'just-debounce';
|
4
|
+
|
5
|
+
import type { List } from '../components/List';
|
6
|
+
import { getAttribute } from '../utils/selectors';
|
7
|
+
import { initButtons } from './buttons';
|
8
|
+
import { initDropdown } from './dropdown';
|
9
|
+
import { getListSortingQuery, setListSortingQuery } from './query';
|
10
|
+
import { initHTMLSelect } from './select';
|
11
|
+
import { sortListItems } from './sort';
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Inits sorting functionality for the list.
|
15
|
+
*/
|
16
|
+
export const initListSorting = (list: List, triggers: HTMLElement[]) => {
|
17
|
+
const sortingClass = getAttribute(list.listElement, 'sortingclass');
|
18
|
+
|
19
|
+
// Init mode
|
20
|
+
const [firstTrigger] = triggers;
|
21
|
+
const isSelect = isHTMLSelectElement(firstTrigger);
|
22
|
+
const isDropdown = firstTrigger.closest<DropdownElement>(`.${DROPDOWN_CSS_CLASSES.dropdown}`);
|
23
|
+
|
24
|
+
const modeCleanup = isSelect
|
25
|
+
? initHTMLSelect(firstTrigger, list)
|
26
|
+
: isDropdown
|
27
|
+
? initDropdown(isDropdown, list)
|
28
|
+
: initButtons(triggers, list);
|
29
|
+
|
30
|
+
// Set up hooks
|
31
|
+
const sortHookCleanup = list.addHook('sort', (items) => {
|
32
|
+
const sortedItems = sortListItems(items, list.sorting.value);
|
33
|
+
return sortedItems;
|
34
|
+
});
|
35
|
+
|
36
|
+
const beforeRenderHookCleanup = list.addHook('beforeRender', async (items) => {
|
37
|
+
if (list.triggeredHook === 'sort') {
|
38
|
+
list.wrapperElement.classList.add(sortingClass);
|
39
|
+
|
40
|
+
const animations = list.wrapperElement.getAnimations({ subtree: true });
|
41
|
+
|
42
|
+
await Promise.all(animations.map((a) => a.finished));
|
43
|
+
}
|
44
|
+
|
45
|
+
return items;
|
46
|
+
});
|
47
|
+
|
48
|
+
const afterRenderHookCleanup = list.addHook('afterRender', (items) => {
|
49
|
+
list.wrapperElement.classList.remove(sortingClass);
|
50
|
+
|
51
|
+
return items;
|
52
|
+
});
|
53
|
+
|
54
|
+
// Set up reactivity
|
55
|
+
const sortingCleanup = watch(
|
56
|
+
list.sorting,
|
57
|
+
debounce(() => {
|
58
|
+
list.triggerHook('sort', {
|
59
|
+
scrollToAnchor: list.hasInteracted.value,
|
60
|
+
resetCurrentPage: list.hasInteracted.value,
|
61
|
+
});
|
62
|
+
|
63
|
+
// Handle query params
|
64
|
+
if (list.showQuery) {
|
65
|
+
setListSortingQuery(list);
|
66
|
+
}
|
67
|
+
}, 0),
|
68
|
+
{ deep: true, immediate: true }
|
69
|
+
);
|
70
|
+
|
71
|
+
// Read query params
|
72
|
+
getListSortingQuery(list);
|
73
|
+
|
74
|
+
return () => {
|
75
|
+
modeCleanup?.();
|
76
|
+
sortHookCleanup();
|
77
|
+
beforeRenderHookCleanup();
|
78
|
+
afterRenderHookCleanup();
|
79
|
+
sortingCleanup();
|
80
|
+
};
|
81
|
+
};
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import type { List } from '../components';
|
2
|
+
import { listInstancesStore } from '../utils/store';
|
3
|
+
import type { SortingDirection } from './types';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @param list
|
7
|
+
* @returns A regex to match the filters query string.
|
8
|
+
*/
|
9
|
+
const getListSortingQueryRegex = (list: List) => {
|
10
|
+
const allFieldKeys = Object.keys(list.allFieldsData.value);
|
11
|
+
|
12
|
+
const regex = new RegExp(`sort_(${allFieldKeys.join('|')})$`);
|
13
|
+
return regex;
|
14
|
+
};
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Gets the filters query string for the list.
|
18
|
+
* @param list
|
19
|
+
*/
|
20
|
+
export const getListSortingQuery = async (list: List) => {
|
21
|
+
const usePrefix = listInstancesStore.size > 1;
|
22
|
+
const existingParams = await list.getAllSearchParams(usePrefix);
|
23
|
+
|
24
|
+
const regex = getListSortingQueryRegex(list);
|
25
|
+
|
26
|
+
const param = existingParams.find(([key, value]) => key.match(regex) && (value === 'asc' || value === 'desc'));
|
27
|
+
if (!param) return;
|
28
|
+
|
29
|
+
const [key, value] = param;
|
30
|
+
|
31
|
+
const match = key.match(regex);
|
32
|
+
if (!match) return;
|
33
|
+
|
34
|
+
const fieldKey = match[1];
|
35
|
+
|
36
|
+
list.sorting.value.fieldKey = fieldKey;
|
37
|
+
list.sorting.value.direction = value as SortingDirection;
|
38
|
+
list.sorting.value.interacted = true;
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Sets the filters query string for the list.
|
43
|
+
* @param list
|
44
|
+
*/
|
45
|
+
export const setListSortingQuery = async (list: List) => {
|
46
|
+
const usePrefix = listInstancesStore.size > 1;
|
47
|
+
const existingParams = await list.getAllSearchParams(usePrefix);
|
48
|
+
|
49
|
+
const regex = getListSortingQueryRegex(list);
|
50
|
+
|
51
|
+
for (const [key] of existingParams) {
|
52
|
+
if (!key.match(regex)) continue;
|
53
|
+
|
54
|
+
await list.setSearchParam(key, null, usePrefix);
|
55
|
+
}
|
56
|
+
|
57
|
+
const { fieldKey, direction } = list.sorting.value;
|
58
|
+
if (!fieldKey || !direction) return;
|
59
|
+
|
60
|
+
const key = `sort_${fieldKey}`;
|
61
|
+
|
62
|
+
list.setSearchParam(key, direction, usePrefix);
|
63
|
+
};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { addListener } from '@finsweet/attributes-utils';
|
2
|
+
|
3
|
+
import type { List } from '../components/List';
|
4
|
+
import { hasAttributeValue } from '../utils/selectors';
|
5
|
+
import type { Sorting, SortingDirection } from './types';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Inits sorting on an `HTMLSelectElement`.
|
9
|
+
* @param selectElement The {@link HTMLSelectElement}.
|
10
|
+
* @param list The {@link List} instance.
|
11
|
+
*/
|
12
|
+
export const initHTMLSelect = (selectElement: HTMLSelectElement, list: List) => {
|
13
|
+
const handleSelect = (interacted = false) => {
|
14
|
+
list.sorting.value = getSortingParams(selectElement.value, interacted);
|
15
|
+
};
|
16
|
+
|
17
|
+
// Sort on change
|
18
|
+
const changeCleanup = addListener(selectElement, 'change', () => handleSelect(true));
|
19
|
+
|
20
|
+
// Sort on init
|
21
|
+
handleSelect();
|
22
|
+
|
23
|
+
// Prevent submit events on the form
|
24
|
+
const form = selectElement.closest('form');
|
25
|
+
|
26
|
+
const allowSubmit = hasAttributeValue(selectElement, 'allowsubmit', 'true');
|
27
|
+
|
28
|
+
const submitCleanup = allowSubmit ? addListener(form, 'submit', handleFormSubmit) : undefined;
|
29
|
+
|
30
|
+
return () => {
|
31
|
+
changeCleanup();
|
32
|
+
submitCleanup?.();
|
33
|
+
};
|
34
|
+
};
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Handles `submit` events on the parent form of the `HTMLSelect` element.
|
38
|
+
* @param e The `submit` event.
|
39
|
+
*/
|
40
|
+
const handleFormSubmit = (e: Event) => {
|
41
|
+
e.preventDefault();
|
42
|
+
e.stopImmediatePropagation();
|
43
|
+
return false;
|
44
|
+
};
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Extracts the `sortKey` and `direction` from a Select element value.
|
48
|
+
* @param value The Select element value.
|
49
|
+
* @param interacted Indicates if the user interacted with the select element.
|
50
|
+
*/
|
51
|
+
const getSortingParams = (value: string, interacted = false): Sorting => {
|
52
|
+
let fieldKey: string;
|
53
|
+
let direction: SortingDirection;
|
54
|
+
|
55
|
+
if (value.endsWith('-asc')) {
|
56
|
+
direction = 'asc';
|
57
|
+
fieldKey = value.slice(0, -4);
|
58
|
+
} else if (value.endsWith('-desc')) {
|
59
|
+
direction = 'desc';
|
60
|
+
fieldKey = value.slice(0, -5);
|
61
|
+
} else {
|
62
|
+
direction = 'asc';
|
63
|
+
fieldKey = value;
|
64
|
+
}
|
65
|
+
|
66
|
+
return { fieldKey, direction, interacted };
|
67
|
+
};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import type { ListItem } from '../components/ListItem';
|
2
|
+
import type { Sorting } from './types';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Sorts the items of a `CMSList`.
|
6
|
+
* **Important:** This method mutates the {@link ListItem.items} property.
|
7
|
+
*
|
8
|
+
* @param listInstance The {@link CMSList} instance.
|
9
|
+
* @param direction The direction to sort.
|
10
|
+
* @param sortKey The key of the field to use as sorting reference.
|
11
|
+
*/
|
12
|
+
export const sortListItems = (items: ListItem[], { fieldKey, direction }: Sorting): ListItem[] | undefined => {
|
13
|
+
const validField = !!direction && !!fieldKey && items.some(({ fields }) => fieldKey in fields);
|
14
|
+
if (!validField) return;
|
15
|
+
|
16
|
+
const sorted = [...items].sort((firstItem, secondItem) => {
|
17
|
+
const firstItemProp = firstItem.fields[fieldKey];
|
18
|
+
const secondItemProp = secondItem.fields[fieldKey];
|
19
|
+
|
20
|
+
if (!firstItemProp) return 1;
|
21
|
+
if (!secondItemProp) return -1;
|
22
|
+
|
23
|
+
// Number sorting
|
24
|
+
if (firstItemProp.type === 'number' && secondItemProp.type === 'number') {
|
25
|
+
const firstItemValue = getItemValue(firstItemProp.value);
|
26
|
+
const secondItemValue = getItemValue(secondItemProp.value);
|
27
|
+
|
28
|
+
if (isNaN(firstItemValue)) return 1;
|
29
|
+
if (isNaN(secondItemValue)) return -1;
|
30
|
+
|
31
|
+
if (direction === 'asc') return firstItemValue - secondItemValue;
|
32
|
+
|
33
|
+
return secondItemValue - firstItemValue;
|
34
|
+
}
|
35
|
+
|
36
|
+
// Dates sorting
|
37
|
+
if (firstItemProp.type === 'date' && secondItemProp.type === 'date') {
|
38
|
+
const firstItemValue = getItemValue(firstItemProp.value).getTime();
|
39
|
+
const secondItemValue = getItemValue(secondItemProp.value).getTime();
|
40
|
+
|
41
|
+
if (direction === 'asc') return firstItemValue - secondItemValue;
|
42
|
+
|
43
|
+
return secondItemValue - firstItemValue;
|
44
|
+
}
|
45
|
+
|
46
|
+
// Text sorting
|
47
|
+
if (firstItemProp.type === 'text' && secondItemProp.type === 'text') {
|
48
|
+
const firstItemValue = getItemValue(firstItemProp.value);
|
49
|
+
const secondItemValue = getItemValue(secondItemProp.value);
|
50
|
+
|
51
|
+
const collatorOptions: Intl.CollatorOptions = {
|
52
|
+
numeric: true,
|
53
|
+
sensitivity: 'base',
|
54
|
+
};
|
55
|
+
|
56
|
+
if (direction === 'asc') return firstItemValue.localeCompare(secondItemValue, undefined, collatorOptions);
|
57
|
+
|
58
|
+
return secondItemValue.localeCompare(firstItemValue, undefined, collatorOptions);
|
59
|
+
}
|
60
|
+
|
61
|
+
return 0;
|
62
|
+
});
|
63
|
+
|
64
|
+
return sorted;
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @returns The first value of the array or the value itself.
|
69
|
+
* @param value
|
70
|
+
*/
|
71
|
+
const getItemValue = <
|
72
|
+
Value extends number | string | Date | number[] | string[] | Date[],
|
73
|
+
ReturnValue = Value extends (infer U)[] ? U : Value,
|
74
|
+
>(
|
75
|
+
value: Value
|
76
|
+
) => {
|
77
|
+
const [firstValue] = Array.isArray(value) ? value : [value];
|
78
|
+
return firstValue as ReturnValue;
|
79
|
+
};
|