@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,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS string to be injected into the head of the document.
|
|
3
|
+
*/
|
|
4
|
+
const cssString = `
|
|
5
|
+
.copied-text::before {
|
|
6
|
+
content: "";
|
|
7
|
+
color: black;
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: -1.8rem;
|
|
10
|
+
visibility: hidden;
|
|
11
|
+
opacity: 0;
|
|
12
|
+
background-color: white;
|
|
13
|
+
padding: 0rem 0.2rem;
|
|
14
|
+
border-radius: 0.15rem;
|
|
15
|
+
left: 50%;
|
|
16
|
+
transform: translate(-50%, 0);
|
|
17
|
+
font-size: 0.8rem;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.copied-text.copied-visible::before {
|
|
23
|
+
visibility: visible;
|
|
24
|
+
opacity: 1;
|
|
25
|
+
content: "Copied!";
|
|
26
|
+
transition-delay: 0s;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.copied-text{
|
|
30
|
+
position: relative;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Injects the specified CSS into the head of the document.
|
|
36
|
+
* @param cssString - The CSS string to be injected.
|
|
37
|
+
*/
|
|
38
|
+
const injectCSS = (cssString: string): void => {
|
|
39
|
+
const style = document.createElement('style');
|
|
40
|
+
|
|
41
|
+
style.setAttribute('type', 'text/css');
|
|
42
|
+
style.innerHTML = cssString;
|
|
43
|
+
|
|
44
|
+
document.head.appendChild(style);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Enable an element by setting its pointer events to auto and toggle the copied text.
|
|
49
|
+
* @param element - The element to enable.
|
|
50
|
+
* @param textToShow - The text to show after copying.
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
const enableElement = (element: HTMLElement, textToShow = '') => {
|
|
54
|
+
const { textContent } = element;
|
|
55
|
+
|
|
56
|
+
if (textToShow) {
|
|
57
|
+
const buttonText = element.querySelector('.button_text');
|
|
58
|
+
|
|
59
|
+
if (buttonText) buttonText.textContent = textToShow;
|
|
60
|
+
else element.textContent = textToShow;
|
|
61
|
+
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
if (buttonText) buttonText.textContent = textContent;
|
|
64
|
+
else element.textContent = textContent;
|
|
65
|
+
|
|
66
|
+
element.style.pointerEvents = 'auto';
|
|
67
|
+
}, 1000);
|
|
68
|
+
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
element.style.pointerEvents = 'auto';
|
|
73
|
+
element.classList.add('copied-visible');
|
|
74
|
+
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
element.classList.remove('copied-visible');
|
|
77
|
+
element.style.pointerEvents = 'auto';
|
|
78
|
+
}, 1000);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Disable an element by setting its pointer events to none.
|
|
83
|
+
* @param element - The element to disable.
|
|
84
|
+
*/
|
|
85
|
+
const disableElement = (element: HTMLElement) => {
|
|
86
|
+
element.style.pointerEvents = 'none';
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Copy the text to the clipboard.
|
|
91
|
+
* @param text - The text to copy.
|
|
92
|
+
* @param element - The element to enable after copying.
|
|
93
|
+
* @param textToShow - The text to show after copying.
|
|
94
|
+
*/
|
|
95
|
+
const copy = (text: string, element: HTMLElement, textToShow = '') => {
|
|
96
|
+
navigator.clipboard
|
|
97
|
+
.writeText(text)
|
|
98
|
+
.then(() => {
|
|
99
|
+
enableElement(element, textToShow);
|
|
100
|
+
})
|
|
101
|
+
.catch((err) => {
|
|
102
|
+
console.error('Failed to copy text: ', err);
|
|
103
|
+
enableElement(element, textToShow);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Copy the Finsweet Attributes Script to the clipboard.
|
|
109
|
+
* @param element - trigger element
|
|
110
|
+
* @param scriptString - script string
|
|
111
|
+
* @param textToShow - text to show after copying
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
const copyScript = (scriptString: string | null, element: HTMLElement, textToShow = '') => {
|
|
115
|
+
if (!navigator.clipboard || !scriptString) {
|
|
116
|
+
console.error('Clipboard API not available.');
|
|
117
|
+
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const attributes = extractAttributes(scriptString);
|
|
122
|
+
disableElement(element);
|
|
123
|
+
|
|
124
|
+
const text = `<!-- Finsweet Attributes -->\n<script async type="module"${attributes}\n></script>`;
|
|
125
|
+
|
|
126
|
+
// copy
|
|
127
|
+
copy(text, element, textToShow);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Copy the Finsweet Attributes Text to the clipboard.
|
|
132
|
+
* @param content - attribute name or value
|
|
133
|
+
* @param element - trigger element
|
|
134
|
+
* @param textToShow - text to show after copying
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
const copyText = (content: string, element: HTMLElement, textToShow = '') => {
|
|
138
|
+
if (!navigator.clipboard || !content) {
|
|
139
|
+
console.error('Clipboard API not available.');
|
|
140
|
+
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
disableElement(element);
|
|
145
|
+
|
|
146
|
+
// copy
|
|
147
|
+
copy(content.trim(), element, textToShow);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Reformat a script tag string with each attribute on a new line using DOMParser.
|
|
152
|
+
* @param scriptString - The script tag as a string.
|
|
153
|
+
* @returns The reformatted attributes.
|
|
154
|
+
*/
|
|
155
|
+
const extractAttributes = (scriptString: string): string => {
|
|
156
|
+
const parser = new DOMParser();
|
|
157
|
+
|
|
158
|
+
const doc = parser.parseFromString(scriptString, 'text/html');
|
|
159
|
+
const scriptElement = doc.querySelector('script');
|
|
160
|
+
|
|
161
|
+
if (!scriptElement) return '';
|
|
162
|
+
|
|
163
|
+
let attributes = ``;
|
|
164
|
+
|
|
165
|
+
// handle 'src' or any other attributes on new lines
|
|
166
|
+
const otherAttributes = Array.from(scriptElement.attributes).filter((attr) => !['async', 'type'].includes(attr.name));
|
|
167
|
+
|
|
168
|
+
for (const attr of otherAttributes) {
|
|
169
|
+
attributes += `\n${attr.name}`;
|
|
170
|
+
if (attr.value) {
|
|
171
|
+
attributes += `="${attr.value.trim()}"`;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return attributes;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Find the closest target element
|
|
180
|
+
* @param element
|
|
181
|
+
* @returns
|
|
182
|
+
*/
|
|
183
|
+
const findClosestTarget = (element: HTMLElement): HTMLElement | null => {
|
|
184
|
+
let currentNode: HTMLElement | null = element;
|
|
185
|
+
|
|
186
|
+
while (currentNode) {
|
|
187
|
+
// Check all children of current node for target
|
|
188
|
+
const target = currentNode.querySelector<HTMLElement>('[fs-docs-copy="target"]');
|
|
189
|
+
if (target) return target;
|
|
190
|
+
|
|
191
|
+
// Move up to parent node
|
|
192
|
+
currentNode = currentNode.parentElement;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return null;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Handle the trigger element click event.
|
|
200
|
+
* @param element - The trigger element that was clicked
|
|
201
|
+
* @returns void
|
|
202
|
+
*/
|
|
203
|
+
const handleTrigger = (element: HTMLElement): void => {
|
|
204
|
+
const instance = element.getAttribute('fs-docs-instance');
|
|
205
|
+
let target: HTMLElement | null = null;
|
|
206
|
+
|
|
207
|
+
if (instance) {
|
|
208
|
+
target = document.querySelector<HTMLElement>(`[fs-docs-copy="target"][fs-docs-instance="${instance}"]`);
|
|
209
|
+
} else {
|
|
210
|
+
// If no instance match, look up the DOM tree and find closest target
|
|
211
|
+
target = findClosestTarget(element);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (!target) return;
|
|
215
|
+
|
|
216
|
+
const { textContent } = target;
|
|
217
|
+
|
|
218
|
+
if (!textContent) return;
|
|
219
|
+
|
|
220
|
+
// if script tag, check for 'src' attribute
|
|
221
|
+
if (textContent.includes('script') && textContent.includes('src="')) {
|
|
222
|
+
copyScript(textContent, element, 'Copied');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
copyText(textContent, element, 'Copied');
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Add click event listener to elements.
|
|
231
|
+
* @param elements
|
|
232
|
+
* @param callback
|
|
233
|
+
*/
|
|
234
|
+
const addClickListener = (elements: NodeListOf<HTMLElement>, callback: (el: HTMLElement) => void) => {
|
|
235
|
+
elements.forEach((el) => {
|
|
236
|
+
el.classList.add('copied-text');
|
|
237
|
+
|
|
238
|
+
el.addEventListener('click', (e) => {
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
e.stopPropagation();
|
|
241
|
+
callback(el);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// DOM content loaded
|
|
247
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
248
|
+
// Inject the CSS into the <head>
|
|
249
|
+
injectCSS(cssString);
|
|
250
|
+
|
|
251
|
+
// Get all trigger elements
|
|
252
|
+
const triggers = document.querySelectorAll<HTMLElement>('[fs-docs-copy="trigger"]');
|
|
253
|
+
addClickListener(triggers, handleTrigger);
|
|
254
|
+
|
|
255
|
+
// Get all text content triggers
|
|
256
|
+
const textContentTriggers = document.querySelectorAll<HTMLElement>('[fs-docs-copy="text-content"]');
|
|
257
|
+
addClickListener(textContentTriggers, (el) => {
|
|
258
|
+
if (el.textContent) copyText(el.textContent, el);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { animations, type Easings } from '@finsweet/attributes-utils';
|
|
2
|
+
import { computePosition, flip, offset, shift } from '@floating-ui/dom';
|
|
3
|
+
import debounce from 'just-debounce';
|
|
4
|
+
|
|
5
|
+
const voidElements = new Set([
|
|
6
|
+
'area',
|
|
7
|
+
'base',
|
|
8
|
+
'br',
|
|
9
|
+
'col',
|
|
10
|
+
'embed',
|
|
11
|
+
'hr',
|
|
12
|
+
'img',
|
|
13
|
+
'input',
|
|
14
|
+
'link',
|
|
15
|
+
'meta',
|
|
16
|
+
'param',
|
|
17
|
+
'source',
|
|
18
|
+
'track',
|
|
19
|
+
'wbr',
|
|
20
|
+
'select',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* X-ray mode active state.
|
|
25
|
+
*/
|
|
26
|
+
let xrayActive = true;
|
|
27
|
+
/**
|
|
28
|
+
* Tooltip element.
|
|
29
|
+
*/
|
|
30
|
+
let tooltip: HTMLElement | null;
|
|
31
|
+
/**
|
|
32
|
+
* Store for elements with 'x-ray' attribute.
|
|
33
|
+
*/
|
|
34
|
+
let xrayElements: HTMLElement[] = [];
|
|
35
|
+
/**
|
|
36
|
+
* Store xray active element
|
|
37
|
+
*/
|
|
38
|
+
let xrayActiveElement: HTMLElement | null;
|
|
39
|
+
/**
|
|
40
|
+
* Default values for x-ray mode.
|
|
41
|
+
*/
|
|
42
|
+
let textColor = '#003238';
|
|
43
|
+
let backgroundColor = '#00e4ff';
|
|
44
|
+
let animation: keyof typeof animations = 'fade';
|
|
45
|
+
let easing: Easings[number] = 'ease-in-out';
|
|
46
|
+
let duration = 150;
|
|
47
|
+
let keyCode = '?';
|
|
48
|
+
let targetClass = 'x-ray';
|
|
49
|
+
|
|
50
|
+
const altTags = ['INPUT'];
|
|
51
|
+
const script = document.currentScript as HTMLScriptElement;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Searches for the closest element up the DOM tree that has any attribute starting with 'fs-'.
|
|
55
|
+
* @param element - The starting HTMLElement to check.
|
|
56
|
+
* @returns The found element with 'fs-' attributes or null if none found.
|
|
57
|
+
*/
|
|
58
|
+
const findElementWithFsAttributes = (element: HTMLElement): HTMLElement | null => {
|
|
59
|
+
// 1. Check the current element
|
|
60
|
+
if (Array.from(element.attributes).some((attr) => attr.name.startsWith('fs-'))) {
|
|
61
|
+
return element;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 2. Check children of the parent element if they have 'fs-' attributes
|
|
65
|
+
const { parentElement } = element;
|
|
66
|
+
if (parentElement) {
|
|
67
|
+
// check its children
|
|
68
|
+
for (const child of Array.from(parentElement.children) as HTMLElement[]) {
|
|
69
|
+
if (Array.from(child.attributes).some((attr) => attr.name.startsWith('fs-'))) {
|
|
70
|
+
return child;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 3. Traverse parents and return the closest one with an 'fs-' attribute
|
|
75
|
+
let ancestor: HTMLElement | null = element;
|
|
76
|
+
while (ancestor) {
|
|
77
|
+
if (Array.from(ancestor.attributes).some((attr) => attr.name.startsWith('fs-'))) {
|
|
78
|
+
return ancestor;
|
|
79
|
+
}
|
|
80
|
+
ancestor = ancestor.parentElement;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Checks if the given element is a void element and returns the parent to apply styles.
|
|
89
|
+
* @param element - The HTMLElement to check.
|
|
90
|
+
* @returns The element to apply the xray outline styles to.
|
|
91
|
+
*/
|
|
92
|
+
const getValidElementForPseudo = (element: HTMLElement): HTMLElement | null | undefined => {
|
|
93
|
+
if (voidElements.has(element.tagName.toLowerCase())) {
|
|
94
|
+
// going 2 levels up seems the perfect approach :)
|
|
95
|
+
// like checkboxes and radios have some 2-3 elements wrapping them
|
|
96
|
+
return element.parentElement?.parentElement || element;
|
|
97
|
+
}
|
|
98
|
+
return element;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Updates the position of the tooltip element relative to the target element.
|
|
103
|
+
* @param element - The target element.
|
|
104
|
+
* @param tooltip - The tooltip element.
|
|
105
|
+
*/
|
|
106
|
+
const updateTooltipPosition = () => {
|
|
107
|
+
if (!tooltip || !xrayActiveElement) return;
|
|
108
|
+
|
|
109
|
+
computePosition(xrayActiveElement, tooltip, {
|
|
110
|
+
placement: 'top',
|
|
111
|
+
middleware: [
|
|
112
|
+
offset(10),
|
|
113
|
+
flip({
|
|
114
|
+
fallbackPlacements: ['top', 'left-start', 'right-start'],
|
|
115
|
+
}),
|
|
116
|
+
shift({ padding: 5 }),
|
|
117
|
+
],
|
|
118
|
+
}).then(({ x, y }) => {
|
|
119
|
+
if (!tooltip) return;
|
|
120
|
+
|
|
121
|
+
Object.assign(tooltip.style, {
|
|
122
|
+
left: `${x}px`,
|
|
123
|
+
top: `${y}px`,
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Creates a tooltip element and appends it to the DOM.
|
|
129
|
+
* @param element
|
|
130
|
+
* @param content
|
|
131
|
+
*/
|
|
132
|
+
const showTooltipElement = async (element: HTMLElement, content: string) => {
|
|
133
|
+
if (!tooltip) {
|
|
134
|
+
tooltip = document.createElement('div');
|
|
135
|
+
tooltip.id = 'tooltip-xray';
|
|
136
|
+
tooltip.style.position = 'absolute';
|
|
137
|
+
tooltip.style.zIndex = '9999';
|
|
138
|
+
tooltip.style.backgroundColor = backgroundColor;
|
|
139
|
+
tooltip.style.color = textColor;
|
|
140
|
+
tooltip.style.borderRadius = '.25rem';
|
|
141
|
+
tooltip.style.padding = '.2rem .5rem';
|
|
142
|
+
tooltip.style.margin = '0';
|
|
143
|
+
tooltip.style.fontSize = '.85rem';
|
|
144
|
+
tooltip.style.fontFamily = 'monospace';
|
|
145
|
+
tooltip.style.width = 'max-content';
|
|
146
|
+
|
|
147
|
+
document.body.appendChild(tooltip);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
tooltip.innerHTML = content;
|
|
151
|
+
|
|
152
|
+
// update xray active element state
|
|
153
|
+
xrayActiveElement = element;
|
|
154
|
+
|
|
155
|
+
// update tooltip position
|
|
156
|
+
updateTooltipPosition();
|
|
157
|
+
|
|
158
|
+
// animate
|
|
159
|
+
await animations[animation].animateIn(tooltip, { duration, easing, display: 'block' });
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Removes the tooltip element from the DOM.
|
|
164
|
+
*/
|
|
165
|
+
const removeTooltip = () => {
|
|
166
|
+
const tooltip = document.getElementById('tooltip-xray');
|
|
167
|
+
|
|
168
|
+
if (tooltip) {
|
|
169
|
+
tooltip.remove();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Checks if the element has an 'x-ray' attribute set to 'ignore' and disables x-ray mode for that element.
|
|
175
|
+
* @param element - The element to check.
|
|
176
|
+
* @returns true if the element was ignored, otherwise false.
|
|
177
|
+
*/
|
|
178
|
+
const checkAndIgnoreElement = (element: Element | null): boolean => {
|
|
179
|
+
if (element?.getAttribute('x-ray') === 'ignore') {
|
|
180
|
+
const closestIgnore = element.closest('[x-ray="ignore"]');
|
|
181
|
+
// handle closest parent with x-ray ignore
|
|
182
|
+
if (closestIgnore) {
|
|
183
|
+
closestIgnore.classList.remove(targetClass);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// handle element itself
|
|
187
|
+
element.classList.remove(targetClass);
|
|
188
|
+
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return false;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Debounced mousemove event listener to show tooltips on elements with 'fs-' attributes.
|
|
197
|
+
*/
|
|
198
|
+
const debouncedMouseMove = debounce(async (event: MouseEvent) => {
|
|
199
|
+
if (!xrayActive) return;
|
|
200
|
+
|
|
201
|
+
tooltip = document.querySelector<HTMLElement>('#tooltip-xray');
|
|
202
|
+
|
|
203
|
+
if (tooltip) {
|
|
204
|
+
await animations[animation].animateOut(tooltip, { display: 'none', duration, easing });
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const target = event.target as HTMLElement;
|
|
208
|
+
|
|
209
|
+
const fsElement = findElementWithFsAttributes(target);
|
|
210
|
+
|
|
211
|
+
if (!fsElement) {
|
|
212
|
+
removeTooltip();
|
|
213
|
+
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const fsAttributes = Array.from(fsElement.attributes)
|
|
218
|
+
.filter((attr) => attr.name.startsWith('fs-'))
|
|
219
|
+
.filter(({ name }) => name.split('-').length === 3);
|
|
220
|
+
|
|
221
|
+
const elementToStyle = getValidElementForPseudo(target);
|
|
222
|
+
|
|
223
|
+
if (!xrayActive || !elementToStyle) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (fsAttributes.length > 0) {
|
|
228
|
+
if (checkAndIgnoreElement(elementToStyle) || checkAndIgnoreElement(fsElement)) return;
|
|
229
|
+
|
|
230
|
+
const list = fsAttributes
|
|
231
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
232
|
+
.map(
|
|
233
|
+
(attr) =>
|
|
234
|
+
`<span style="font-weight:bold;">${attr.name}</span><span style="opacity:0.5">=</span><span style="opacity:0.5">"</span><span style="font-weight:bold;">${attr.value}</span><span style="opacity:0.5">"</span>`
|
|
235
|
+
)
|
|
236
|
+
.join('<br/>');
|
|
237
|
+
|
|
238
|
+
showTooltipElement(fsElement, list);
|
|
239
|
+
}
|
|
240
|
+
}, 150);
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Query all elements that have attributes starting with 'fs-'.
|
|
244
|
+
* @returns An array of HTMLElements that have attributes starting with 'fs-'.
|
|
245
|
+
*/
|
|
246
|
+
const queryElementsWithFsAttributes = () => {
|
|
247
|
+
// Get all elements in the document
|
|
248
|
+
const allElements = document.querySelectorAll<HTMLElement>('*');
|
|
249
|
+
// get all elements with x-ray class
|
|
250
|
+
const xrayElements = document.querySelectorAll<HTMLElement>(targetClass);
|
|
251
|
+
|
|
252
|
+
if (xrayElements.length > 0 && !xrayActive) {
|
|
253
|
+
xrayElements.forEach((element) => {
|
|
254
|
+
element.classList.remove(targetClass);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Filter elements that have at least one attribute starting with 'fs-'
|
|
259
|
+
const elementsWithFsAttributes = Array.from(allElements).filter((element) =>
|
|
260
|
+
Array.from(element.attributes).some((attr) => attr.name.startsWith('fs-'))
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
// if element is void element, return the parent element
|
|
264
|
+
const elements = elementsWithFsAttributes.map((element) => {
|
|
265
|
+
if (
|
|
266
|
+
altTags.includes(element.tagName) &&
|
|
267
|
+
(element.getAttribute('type') === 'checkbox' || element.getAttribute('type') === 'radio')
|
|
268
|
+
) {
|
|
269
|
+
return element.closest('label') || element;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return element;
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return elements;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Set or update the tooltip style in the head of the document.
|
|
280
|
+
*/
|
|
281
|
+
const updateTooltipStyle = () => {
|
|
282
|
+
let style = document.getElementById('tooltip-xray-style');
|
|
283
|
+
|
|
284
|
+
if (!style) {
|
|
285
|
+
style = document.createElement('style');
|
|
286
|
+
style.setAttribute('id', 'tooltip-xray-style');
|
|
287
|
+
|
|
288
|
+
document.head.appendChild(style);
|
|
289
|
+
}
|
|
290
|
+
style.innerHTML = `
|
|
291
|
+
.${targetClass}, .${targetClass}:hover {
|
|
292
|
+
outline-color: ${backgroundColor} !important;
|
|
293
|
+
outline-offset: 3px !important;
|
|
294
|
+
outline-width: 1px !important;
|
|
295
|
+
outline-style: solid !important;
|
|
296
|
+
border-radius: 0.25rem !important;
|
|
297
|
+
}
|
|
298
|
+
`;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Initialize the mouseover event listener for elements with 'fs-' attributes.
|
|
303
|
+
*/
|
|
304
|
+
const xrayInit = (): void => {
|
|
305
|
+
textColor = script?.getAttribute('text-color') || '#003238';
|
|
306
|
+
backgroundColor = script?.getAttribute('background-color') || '#00e4ff';
|
|
307
|
+
animation = (script?.getAttribute('animation') as keyof typeof animations) || 'fade';
|
|
308
|
+
easing = (script?.getAttribute('easing') as Easings[number]) || 'ease-in-out';
|
|
309
|
+
duration = Number(script?.getAttribute('duration')) || 150;
|
|
310
|
+
keyCode = script?.getAttribute('key') || '?';
|
|
311
|
+
targetClass = script?.getAttribute('target-class') || 'x-ray';
|
|
312
|
+
|
|
313
|
+
updateTooltipStyle();
|
|
314
|
+
|
|
315
|
+
const xrayDefaultElements = document.querySelectorAll('.helper');
|
|
316
|
+
|
|
317
|
+
// clear any existing helper classes that were added in webflow so that script can manage it.
|
|
318
|
+
if (xrayDefaultElements.length > 0) {
|
|
319
|
+
xrayDefaultElements.forEach((xray) => {
|
|
320
|
+
xray.classList.remove('helper');
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
xrayElements = queryElementsWithFsAttributes();
|
|
325
|
+
|
|
326
|
+
xrayElements.forEach((element) => {
|
|
327
|
+
if (checkAndIgnoreElement(element)) return;
|
|
328
|
+
|
|
329
|
+
element.classList.toggle(targetClass, xrayActive);
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Handle the keydown event to toggle the x-ray mode.
|
|
335
|
+
* @param e
|
|
336
|
+
*/
|
|
337
|
+
const handleKeydown = (e: KeyboardEvent) => {
|
|
338
|
+
if (e.key === keyCode) {
|
|
339
|
+
xrayActive = !xrayActive;
|
|
340
|
+
|
|
341
|
+
if (!xrayActive) {
|
|
342
|
+
removeTooltip();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
xrayElements.forEach((element) => {
|
|
346
|
+
if (checkAndIgnoreElement(element)) return;
|
|
347
|
+
|
|
348
|
+
element.classList.toggle(targetClass, xrayActive);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Handle the scroll event to update the tooltip position.
|
|
355
|
+
*/
|
|
356
|
+
const handleScroll = () => {
|
|
357
|
+
if (xrayActiveElement) {
|
|
358
|
+
updateTooltipPosition();
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// dom ready
|
|
363
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
364
|
+
document.addEventListener('mouseover', debouncedMouseMove);
|
|
365
|
+
document.addEventListener('keydown', handleKeydown);
|
|
366
|
+
document.addEventListener('scroll', handleScroll, { passive: true });
|
|
367
|
+
window.addEventListener('resize', updateTooltipPosition);
|
|
368
|
+
|
|
369
|
+
const config: MutationObserverInit = {
|
|
370
|
+
attributes: true,
|
|
371
|
+
subtree: true,
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
const debouncedCallback = debounce(xrayInit, 150);
|
|
375
|
+
const observer = new MutationObserver(debouncedCallback);
|
|
376
|
+
observer.observe(document.body, config);
|
|
377
|
+
});
|