@hortonstudio/main 1.2.12 → 1.2.14
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/index.js +9 -9
- package/package.json +17 -6
- package/.claude/settings.local.json +0 -21
- package/animations/hero.js +0 -599
- package/animations/text.js +0 -369
- package/animations/transition.js +0 -57
- package/attributes-master/.changeset/README.md +0 -8
- package/attributes-master/.changeset/config.json +0 -11
- package/attributes-master/.gitattributes +0 -2
- package/attributes-master/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
- package/attributes-master/.github/ISSUE_TEMPLATE/feature_request.md +0 -22
- package/attributes-master/.github/workflows/ci.yml +0 -66
- package/attributes-master/.github/workflows/release.yml +0 -40
- package/attributes-master/.prettierignore +0 -3
- package/attributes-master/.prettierrc +0 -8
- package/attributes-master/.vscode/extensions.json +0 -3
- package/attributes-master/.vscode/settings.json +0 -7
- package/attributes-master/CONTRIBUTING.md +0 -72
- package/attributes-master/LICENSE.md +0 -201
- package/attributes-master/README.md +0 -31
- package/attributes-master/eslint.config.js +0 -3
- package/attributes-master/package.json +0 -34
- package/attributes-master/packages/accordion/CHANGELOG.md +0 -89
- package/attributes-master/packages/accordion/README.md +0 -31
- package/attributes-master/packages/accordion/package.json +0 -25
- package/attributes-master/packages/accordion/src/actions/a11y.ts +0 -39
- package/attributes-master/packages/accordion/src/actions/classes.ts +0 -27
- package/attributes-master/packages/accordion/src/actions/content.ts +0 -42
- package/attributes-master/packages/accordion/src/actions/list.ts +0 -36
- package/attributes-master/packages/accordion/src/actions/query.ts +0 -27
- package/attributes-master/packages/accordion/src/actions/settings.ts +0 -61
- package/attributes-master/packages/accordion/src/factory.ts +0 -145
- package/attributes-master/packages/accordion/src/index.ts +0 -3
- package/attributes-master/packages/accordion/src/init.ts +0 -37
- package/attributes-master/packages/accordion/src/utils/constants.ts +0 -62
- package/attributes-master/packages/accordion/src/utils/helpers.ts +0 -5
- package/attributes-master/packages/accordion/src/utils/selectors.ts +0 -12
- package/attributes-master/packages/accordion/src/utils/types.ts +0 -23
- package/attributes-master/packages/accordion/tsconfig.json +0 -3
- package/attributes-master/packages/attributes/CHANGELOG.md +0 -564
- package/attributes-master/packages/attributes/README.md +0 -66
- package/attributes-master/packages/attributes/bin/build.ts +0 -107
- package/attributes-master/packages/attributes/bin/live-reload.js +0 -1
- package/attributes-master/packages/attributes/package.json +0 -77
- package/attributes-master/packages/attributes/playwright.config.ts +0 -89
- package/attributes-master/packages/attributes/src/attributes.ts +0 -153
- package/attributes-master/packages/attributes/src/load.ts +0 -125
- package/attributes-master/packages/attributes/tests/accordion.spec.ts +0 -137
- package/attributes-master/packages/attributes/tests/codehighlight.spec.ts +0 -23
- package/attributes-master/packages/attributes/tests/combobox.spec.ts +0 -321
- package/attributes-master/packages/attributes/tests/copyclip.spec.ts +0 -19
- package/attributes-master/packages/attributes/tests/displayvalues.spec.ts +0 -48
- package/attributes-master/packages/attributes/tests/favcustom.spec.ts +0 -23
- package/attributes-master/packages/attributes/tests/inject.spec.ts +0 -40
- package/attributes-master/packages/attributes/tests/inputactive.spec.ts +0 -77
- package/attributes-master/packages/attributes/tests/inputcounter.spec.ts +0 -83
- package/attributes-master/packages/attributes/tests/list.spec.ts +0 -800
- package/attributes-master/packages/attributes/tests/mirrorclick.spec.ts +0 -22
- package/attributes-master/packages/attributes/tests/mirrorinput.spec.ts +0 -37
- package/attributes-master/packages/attributes/tests/modal.spec.ts +0 -34
- package/attributes-master/packages/attributes/tests/numbercount.spec.ts +0 -40
- package/attributes-master/packages/attributes/tests/readtime.spec.ts +0 -19
- package/attributes-master/packages/attributes/tests/selectcustom.spec.ts +0 -51
- package/attributes-master/packages/attributes/tests/socialshare.spec.ts +0 -54
- package/attributes-master/packages/attributes/tests/starrating.spec.ts +0 -79
- package/attributes-master/packages/attributes/tests/toc.spec.ts +0 -38
- package/attributes-master/packages/attributes/tests/utils/index.ts +0 -16
- package/attributes-master/packages/attributes/tsconfig.json +0 -6
- package/attributes-master/packages/autovideo/CHANGELOG.md +0 -182
- package/attributes-master/packages/autovideo/README.md +0 -31
- package/attributes-master/packages/autovideo/package.json +0 -22
- package/attributes-master/packages/autovideo/src/index.ts +0 -3
- package/attributes-master/packages/autovideo/src/init.ts +0 -52
- package/attributes-master/packages/autovideo/src/types.ts +0 -5
- package/attributes-master/packages/autovideo/src/utils/constants.ts +0 -4
- package/attributes-master/packages/autovideo/tsconfig.json +0 -3
- package/attributes-master/packages/codehighlight/CHANGELOG.md +0 -185
- package/attributes-master/packages/codehighlight/README.md +0 -27
- package/attributes-master/packages/codehighlight/package.json +0 -23
- package/attributes-master/packages/codehighlight/src/actions/import.ts +0 -50
- package/attributes-master/packages/codehighlight/src/index.ts +0 -3
- package/attributes-master/packages/codehighlight/src/init.ts +0 -53
- package/attributes-master/packages/codehighlight/src/utils/constants.ts +0 -24
- package/attributes-master/packages/codehighlight/src/utils/selectors.ts +0 -5
- package/attributes-master/packages/codehighlight/src/utils/themes.ts +0 -202
- package/attributes-master/packages/codehighlight/tsconfig.json +0 -3
- package/attributes-master/packages/combobox/CHANGELOG.md +0 -99
- package/attributes-master/packages/combobox/README.md +0 -27
- package/attributes-master/packages/combobox/package.json +0 -23
- package/attributes-master/packages/combobox/src/actions/a11y.ts +0 -29
- package/attributes-master/packages/combobox/src/actions/body/index.ts +0 -12
- package/attributes-master/packages/combobox/src/actions/clearDropdown/index.ts +0 -37
- package/attributes-master/packages/combobox/src/actions/dropdownList/index.ts +0 -220
- package/attributes-master/packages/combobox/src/actions/dropdownToggle/index.ts +0 -34
- package/attributes-master/packages/combobox/src/actions/events.ts +0 -75
- package/attributes-master/packages/combobox/src/actions/input/index.ts +0 -235
- package/attributes-master/packages/combobox/src/actions/observe.ts +0 -158
- package/attributes-master/packages/combobox/src/actions/populate.ts +0 -97
- package/attributes-master/packages/combobox/src/actions/selectElement/index.ts +0 -23
- package/attributes-master/packages/combobox/src/actions/settings.ts +0 -134
- package/attributes-master/packages/combobox/src/actions/state.ts +0 -34
- package/attributes-master/packages/combobox/src/index.ts +0 -3
- package/attributes-master/packages/combobox/src/init.ts +0 -52
- package/attributes-master/packages/combobox/src/utils/constants.ts +0 -48
- package/attributes-master/packages/combobox/src/utils/dropdowns.ts +0 -120
- package/attributes-master/packages/combobox/src/utils/index.ts +0 -1
- package/attributes-master/packages/combobox/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/combobox/src/utils/types.ts +0 -14
- package/attributes-master/packages/combobox/tsconfig.json +0 -3
- package/attributes-master/packages/copyclip/CHANGELOG.md +0 -213
- package/attributes-master/packages/copyclip/README.md +0 -27
- package/attributes-master/packages/copyclip/package.json +0 -23
- package/attributes-master/packages/copyclip/src/factory.ts +0 -67
- package/attributes-master/packages/copyclip/src/index.ts +0 -3
- package/attributes-master/packages/copyclip/src/init.ts +0 -68
- package/attributes-master/packages/copyclip/src/utils/constants.ts +0 -40
- package/attributes-master/packages/copyclip/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/copyclip/tsconfig.json +0 -3
- package/attributes-master/packages/displayvalues/CHANGELOG.md +0 -164
- package/attributes-master/packages/displayvalues/README.md +0 -27
- package/attributes-master/packages/displayvalues/package.json +0 -22
- package/attributes-master/packages/displayvalues/src/actions/collect.ts +0 -17
- package/attributes-master/packages/displayvalues/src/actions/events.ts +0 -22
- package/attributes-master/packages/displayvalues/src/actions/sync.ts +0 -23
- package/attributes-master/packages/displayvalues/src/index.ts +0 -3
- package/attributes-master/packages/displayvalues/src/init.ts +0 -31
- package/attributes-master/packages/displayvalues/src/utils/constants.ts +0 -20
- package/attributes-master/packages/displayvalues/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/displayvalues/src/utils/stores.ts +0 -3
- package/attributes-master/packages/displayvalues/tsconfig.json +0 -3
- package/attributes-master/packages/docs/CHANGELOG.md +0 -108
- package/attributes-master/packages/docs/README.md +0 -3
- package/attributes-master/packages/docs/bin/build.js +0 -92
- package/attributes-master/packages/docs/bin/live-reload.js +0 -1
- package/attributes-master/packages/docs/package.json +0 -40
- package/attributes-master/packages/docs/src/copy.ts +0 -260
- package/attributes-master/packages/docs/src/x-ray.ts +0 -377
- package/attributes-master/packages/docs/tsconfig.json +0 -3
- package/attributes-master/packages/favcustom/CHANGELOG.md +0 -194
- package/attributes-master/packages/favcustom/README.md +0 -27
- package/attributes-master/packages/favcustom/package.json +0 -22
- package/attributes-master/packages/favcustom/src/index.ts +0 -3
- package/attributes-master/packages/favcustom/src/init.ts +0 -30
- package/attributes-master/packages/favcustom/src/utils/constants.ts +0 -10
- package/attributes-master/packages/favcustom/src/utils/selectors.ts +0 -5
- package/attributes-master/packages/favcustom/tsconfig.json +0 -3
- package/attributes-master/packages/formsubmit/CHANGELOG.md +0 -161
- package/attributes-master/packages/formsubmit/README.md +0 -51
- package/attributes-master/packages/formsubmit/package.json +0 -22
- package/attributes-master/packages/formsubmit/src/actions/redirect.ts +0 -9
- package/attributes-master/packages/formsubmit/src/actions/reset.ts +0 -49
- package/attributes-master/packages/formsubmit/src/actions/submit.ts +0 -34
- package/attributes-master/packages/formsubmit/src/components/Form.ts +0 -231
- package/attributes-master/packages/formsubmit/src/factory.ts +0 -62
- package/attributes-master/packages/formsubmit/src/index.ts +0 -3
- package/attributes-master/packages/formsubmit/src/init.ts +0 -24
- package/attributes-master/packages/formsubmit/src/utils/attributes.ts +0 -19
- package/attributes-master/packages/formsubmit/src/utils/constants.ts +0 -89
- package/attributes-master/packages/formsubmit/src/utils/dom.ts +0 -76
- package/attributes-master/packages/formsubmit/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/formsubmit/src/utils/types.ts +0 -7
- package/attributes-master/packages/formsubmit/tsconfig.json +0 -3
- package/attributes-master/packages/inject/CHANGELOG.md +0 -117
- package/attributes-master/packages/inject/README.md +0 -60
- package/attributes-master/packages/inject/package.json +0 -22
- package/attributes-master/packages/inject/src/actions/collect.ts +0 -125
- package/attributes-master/packages/inject/src/actions/css.ts +0 -27
- package/attributes-master/packages/inject/src/actions/prefetch.ts +0 -44
- package/attributes-master/packages/inject/src/factory.ts +0 -123
- package/attributes-master/packages/inject/src/index.ts +0 -3
- package/attributes-master/packages/inject/src/init.ts +0 -22
- package/attributes-master/packages/inject/src/utils/constants.ts +0 -89
- package/attributes-master/packages/inject/src/utils/helpers.ts +0 -36
- package/attributes-master/packages/inject/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/inject/src/utils/types.ts +0 -16
- package/attributes-master/packages/inject/tsconfig.json +0 -3
- package/attributes-master/packages/inputactive/CHANGELOG.md +0 -58
- package/attributes-master/packages/inputactive/README.md +0 -25
- package/attributes-master/packages/inputactive/package.json +0 -22
- package/attributes-master/packages/inputactive/src/actions/classes.ts +0 -43
- package/attributes-master/packages/inputactive/src/factory.ts +0 -24
- package/attributes-master/packages/inputactive/src/index.ts +0 -3
- package/attributes-master/packages/inputactive/src/init.ts +0 -18
- package/attributes-master/packages/inputactive/src/utils/constants.ts +0 -13
- package/attributes-master/packages/inputactive/src/utils/selectors.ts +0 -5
- package/attributes-master/packages/inputactive/tsconfig.json +0 -3
- package/attributes-master/packages/inputcounter/CHANGELOG.md +0 -110
- package/attributes-master/packages/inputcounter/README.md +0 -25
- package/attributes-master/packages/inputcounter/package.json +0 -22
- package/attributes-master/packages/inputcounter/src/actions/a11y.ts +0 -23
- package/attributes-master/packages/inputcounter/src/actions/buttons.ts +0 -61
- package/attributes-master/packages/inputcounter/src/actions/input.ts +0 -31
- package/attributes-master/packages/inputcounter/src/actions/style.ts +0 -12
- package/attributes-master/packages/inputcounter/src/factory.ts +0 -51
- package/attributes-master/packages/inputcounter/src/index.ts +0 -3
- package/attributes-master/packages/inputcounter/src/init.ts +0 -22
- package/attributes-master/packages/inputcounter/src/utils/constants.ts +0 -59
- package/attributes-master/packages/inputcounter/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/inputcounter/tsconfig.json +0 -3
- package/attributes-master/packages/list/CHANGELOG.md +0 -185
- package/attributes-master/packages/list/README.md +0 -331
- package/attributes-master/packages/list/package.json +0 -37
- package/attributes-master/packages/list/src/combine/index.ts +0 -38
- package/attributes-master/packages/list/src/components/List.ts +0 -861
- package/attributes-master/packages/list/src/components/ListItem.ts +0 -229
- package/attributes-master/packages/list/src/components/index.ts +0 -2
- package/attributes-master/packages/list/src/factory.ts +0 -130
- package/attributes-master/packages/list/src/filter/dynamic/conditions.ts +0 -639
- package/attributes-master/packages/list/src/filter/dynamic/groups.ts +0 -221
- package/attributes-master/packages/list/src/filter/dynamic/index.ts +0 -119
- package/attributes-master/packages/list/src/filter/dynamic/utils.ts +0 -44
- package/attributes-master/packages/list/src/filter/elements.ts +0 -93
- package/attributes-master/packages/list/src/filter/filter.ts +0 -118
- package/attributes-master/packages/list/src/filter/filter.worker.ts +0 -152
- package/attributes-master/packages/list/src/filter/index.ts +0 -94
- package/attributes-master/packages/list/src/filter/standard/conditions.ts +0 -123
- package/attributes-master/packages/list/src/filter/standard/facets.ts +0 -253
- package/attributes-master/packages/list/src/filter/standard/index.ts +0 -176
- package/attributes-master/packages/list/src/filter/standard/query.ts +0 -111
- package/attributes-master/packages/list/src/filter/tags.ts +0 -314
- package/attributes-master/packages/list/src/filter/types.ts +0 -62
- package/attributes-master/packages/list/src/filter/utils.ts +0 -126
- package/attributes-master/packages/list/src/index.ts +0 -4
- package/attributes-master/packages/list/src/init.ts +0 -38
- package/attributes-master/packages/list/src/load/all.ts +0 -27
- package/attributes-master/packages/list/src/load/elements.ts +0 -39
- package/attributes-master/packages/list/src/load/index.ts +0 -63
- package/attributes-master/packages/list/src/load/infinite.ts +0 -79
- package/attributes-master/packages/list/src/load/load.ts +0 -191
- package/attributes-master/packages/list/src/load/more.ts +0 -97
- package/attributes-master/packages/list/src/load/pagination.ts +0 -402
- package/attributes-master/packages/list/src/nest/index.ts +0 -198
- package/attributes-master/packages/list/src/prevnext/index.ts +0 -98
- package/attributes-master/packages/list/src/select/index.ts +0 -56
- package/attributes-master/packages/list/src/slider/index.ts +0 -62
- package/attributes-master/packages/list/src/sort/buttons.ts +0 -96
- package/attributes-master/packages/list/src/sort/dropdown.ts +0 -179
- package/attributes-master/packages/list/src/sort/index.ts +0 -81
- package/attributes-master/packages/list/src/sort/query.ts +0 -63
- package/attributes-master/packages/list/src/sort/select.ts +0 -67
- package/attributes-master/packages/list/src/sort/sort.ts +0 -79
- package/attributes-master/packages/list/src/sort/types.ts +0 -28
- package/attributes-master/packages/list/src/static/index.ts +0 -73
- package/attributes-master/packages/list/src/tabs/index.ts +0 -97
- package/attributes-master/packages/list/src/utils/constants.ts +0 -728
- package/attributes-master/packages/list/src/utils/dom.ts +0 -108
- package/attributes-master/packages/list/src/utils/pagination.ts +0 -14
- package/attributes-master/packages/list/src/utils/selectors.ts +0 -18
- package/attributes-master/packages/list/src/utils/store.ts +0 -5
- package/attributes-master/packages/list/tsconfig.json +0 -3
- package/attributes-master/packages/mirrorclick/CHANGELOG.md +0 -171
- package/attributes-master/packages/mirrorclick/README.md +0 -25
- package/attributes-master/packages/mirrorclick/package.json +0 -22
- package/attributes-master/packages/mirrorclick/src/index.ts +0 -3
- package/attributes-master/packages/mirrorclick/src/init.ts +0 -35
- package/attributes-master/packages/mirrorclick/src/utils/constants.ts +0 -20
- package/attributes-master/packages/mirrorclick/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/mirrorclick/tsconfig.json +0 -3
- package/attributes-master/packages/mirrorinput/CHANGELOG.md +0 -172
- package/attributes-master/packages/mirrorinput/README.md +0 -25
- package/attributes-master/packages/mirrorinput/package.json +0 -22
- package/attributes-master/packages/mirrorinput/src/index.ts +0 -3
- package/attributes-master/packages/mirrorinput/src/init.ts +0 -48
- package/attributes-master/packages/mirrorinput/src/utils/constants.ts +0 -15
- package/attributes-master/packages/mirrorinput/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/mirrorinput/tsconfig.json +0 -3
- package/attributes-master/packages/modal/CHANGELOG.md +0 -94
- package/attributes-master/packages/modal/README.md +0 -29
- package/attributes-master/packages/modal/package.json +0 -23
- package/attributes-master/packages/modal/src/actions/a11y.ts +0 -46
- package/attributes-master/packages/modal/src/actions/modal.ts +0 -164
- package/attributes-master/packages/modal/src/actions/settings.ts +0 -21
- package/attributes-master/packages/modal/src/factory.ts +0 -26
- package/attributes-master/packages/modal/src/index.ts +0 -3
- package/attributes-master/packages/modal/src/init.ts +0 -22
- package/attributes-master/packages/modal/src/utils/constants.ts +0 -54
- package/attributes-master/packages/modal/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/modal/src/utils/types.ts +0 -12
- package/attributes-master/packages/modal/tsconfig.json +0 -3
- package/attributes-master/packages/numbercount/CHANGELOG.md +0 -90
- package/attributes-master/packages/numbercount/README.md +0 -27
- package/attributes-master/packages/numbercount/package.json +0 -23
- package/attributes-master/packages/numbercount/src/actions/a11y.ts +0 -26
- package/attributes-master/packages/numbercount/src/actions/animate.ts +0 -43
- package/attributes-master/packages/numbercount/src/actions/observe.ts +0 -44
- package/attributes-master/packages/numbercount/src/factory.ts +0 -31
- package/attributes-master/packages/numbercount/src/index.ts +0 -3
- package/attributes-master/packages/numbercount/src/init.ts +0 -22
- package/attributes-master/packages/numbercount/src/utils/constants.ts +0 -40
- package/attributes-master/packages/numbercount/src/utils/helpers.ts +0 -31
- package/attributes-master/packages/numbercount/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/numbercount/tsconfig.json +0 -3
- package/attributes-master/packages/queryparam/CHANGELOG.md +0 -118
- package/attributes-master/packages/queryparam/README.md +0 -25
- package/attributes-master/packages/queryparam/package.json +0 -22
- package/attributes-master/packages/queryparam/src/factory.ts +0 -51
- package/attributes-master/packages/queryparam/src/index.ts +0 -3
- package/attributes-master/packages/queryparam/src/init.ts +0 -40
- package/attributes-master/packages/queryparam/src/utils/constants.ts +0 -18
- package/attributes-master/packages/queryparam/src/utils/selectors.ts +0 -5
- package/attributes-master/packages/queryparam/tsconfig.json +0 -3
- package/attributes-master/packages/rangeslider/CHANGELOG.md +0 -236
- package/attributes-master/packages/rangeslider/README.md +0 -95
- package/attributes-master/packages/rangeslider/package.json +0 -23
- package/attributes-master/packages/rangeslider/src/actions/a11y.ts +0 -21
- package/attributes-master/packages/rangeslider/src/actions/events.ts +0 -9
- package/attributes-master/packages/rangeslider/src/actions/settings.ts +0 -97
- package/attributes-master/packages/rangeslider/src/actions/styles.ts +0 -10
- package/attributes-master/packages/rangeslider/src/actions/values.ts +0 -47
- package/attributes-master/packages/rangeslider/src/components/Fill.ts +0 -70
- package/attributes-master/packages/rangeslider/src/components/Handle.ts +0 -281
- package/attributes-master/packages/rangeslider/src/factory.ts +0 -100
- package/attributes-master/packages/rangeslider/src/index.ts +0 -3
- package/attributes-master/packages/rangeslider/src/init.ts +0 -194
- package/attributes-master/packages/rangeslider/src/utils/constants.ts +0 -87
- package/attributes-master/packages/rangeslider/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/rangeslider/src/utils/types.ts +0 -6
- package/attributes-master/packages/rangeslider/tsconfig.json +0 -3
- package/attributes-master/packages/readtime/CHANGELOG.md +0 -108
- package/attributes-master/packages/readtime/README.md +0 -25
- package/attributes-master/packages/readtime/package.json +0 -22
- package/attributes-master/packages/readtime/src/factory.ts +0 -21
- package/attributes-master/packages/readtime/src/index.ts +0 -3
- package/attributes-master/packages/readtime/src/init.ts +0 -19
- package/attributes-master/packages/readtime/src/utils/constants.ts +0 -33
- package/attributes-master/packages/readtime/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/readtime/tsconfig.json +0 -3
- package/attributes-master/packages/removequery/CHANGELOG.md +0 -8
- package/attributes-master/packages/removequery/README.md +0 -25
- package/attributes-master/packages/removequery/package.json +0 -22
- package/attributes-master/packages/removequery/src/index.ts +0 -3
- package/attributes-master/packages/removequery/src/init.ts +0 -18
- package/attributes-master/packages/removequery/src/utils/constants.ts +0 -5
- package/attributes-master/packages/removequery/tsconfig.json +0 -3
- package/attributes-master/packages/scrolldisable/CHANGELOG.md +0 -164
- package/attributes-master/packages/scrolldisable/README.md +0 -29
- package/attributes-master/packages/scrolldisable/package.json +0 -27
- package/attributes-master/packages/scrolldisable/src/click.ts +0 -40
- package/attributes-master/packages/scrolldisable/src/display.ts +0 -117
- package/attributes-master/packages/scrolldisable/src/index.ts +0 -3
- package/attributes-master/packages/scrolldisable/src/init.ts +0 -36
- package/attributes-master/packages/scrolldisable/src/scroll.ts +0 -63
- package/attributes-master/packages/scrolldisable/src/utils/constants.ts +0 -56
- package/attributes-master/packages/scrolldisable/src/utils/selectors.ts +0 -6
- package/attributes-master/packages/scrolldisable/tsconfig.json +0 -3
- package/attributes-master/packages/selectcustom/CHANGELOG.md +0 -242
- package/attributes-master/packages/selectcustom/README.md +0 -25
- package/attributes-master/packages/selectcustom/package.json +0 -23
- package/attributes-master/packages/selectcustom/src/actions/a11y.ts +0 -29
- package/attributes-master/packages/selectcustom/src/actions/events.ts +0 -159
- package/attributes-master/packages/selectcustom/src/actions/observe.ts +0 -83
- package/attributes-master/packages/selectcustom/src/actions/populate.ts +0 -67
- package/attributes-master/packages/selectcustom/src/actions/settings.ts +0 -68
- package/attributes-master/packages/selectcustom/src/actions/state.ts +0 -41
- package/attributes-master/packages/selectcustom/src/index.ts +0 -3
- package/attributes-master/packages/selectcustom/src/init.ts +0 -51
- package/attributes-master/packages/selectcustom/src/utils/constants.ts +0 -34
- package/attributes-master/packages/selectcustom/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/selectcustom/src/utils/types.ts +0 -14
- package/attributes-master/packages/selectcustom/tsconfig.json +0 -3
- package/attributes-master/packages/sliderdots/CHANGELOG.md +0 -220
- package/attributes-master/packages/sliderdots/README.md +0 -27
- package/attributes-master/packages/sliderdots/package.json +0 -22
- package/attributes-master/packages/sliderdots/src/actions/events.ts +0 -26
- package/attributes-master/packages/sliderdots/src/actions/observe.ts +0 -40
- package/attributes-master/packages/sliderdots/src/actions/populate.ts +0 -46
- package/attributes-master/packages/sliderdots/src/actions/sync.ts +0 -28
- package/attributes-master/packages/sliderdots/src/actions/wait.ts +0 -28
- package/attributes-master/packages/sliderdots/src/factory.ts +0 -57
- package/attributes-master/packages/sliderdots/src/index.ts +0 -3
- package/attributes-master/packages/sliderdots/src/init.ts +0 -30
- package/attributes-master/packages/sliderdots/src/utils/constants.ts +0 -33
- package/attributes-master/packages/sliderdots/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/sliderdots/src/utils/types.ts +0 -7
- package/attributes-master/packages/sliderdots/tsconfig.json +0 -3
- package/attributes-master/packages/smartlightbox/CHANGELOG.md +0 -203
- package/attributes-master/packages/smartlightbox/README.md +0 -25
- package/attributes-master/packages/smartlightbox/package.json +0 -22
- package/attributes-master/packages/smartlightbox/src/actions/collect.ts +0 -15
- package/attributes-master/packages/smartlightbox/src/actions/move.ts +0 -25
- package/attributes-master/packages/smartlightbox/src/index.ts +0 -3
- package/attributes-master/packages/smartlightbox/src/init.ts +0 -61
- package/attributes-master/packages/smartlightbox/src/utils/constants.ts +0 -31
- package/attributes-master/packages/smartlightbox/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/smartlightbox/tsconfig.json +0 -3
- package/attributes-master/packages/socialshare/CHANGELOG.md +0 -170
- package/attributes-master/packages/socialshare/README.md +0 -25
- package/attributes-master/packages/socialshare/package.json +0 -25
- package/attributes-master/packages/socialshare/src/actions/collect.ts +0 -93
- package/attributes-master/packages/socialshare/src/actions/share.ts +0 -91
- package/attributes-master/packages/socialshare/src/actions/trigger.ts +0 -46
- package/attributes-master/packages/socialshare/src/factory.ts +0 -149
- package/attributes-master/packages/socialshare/src/index.ts +0 -3
- package/attributes-master/packages/socialshare/src/init.ts +0 -35
- package/attributes-master/packages/socialshare/src/utils/constants.ts +0 -94
- package/attributes-master/packages/socialshare/src/utils/dom.ts +0 -8
- package/attributes-master/packages/socialshare/src/utils/selectors.ts +0 -6
- package/attributes-master/packages/socialshare/src/utils/stores.ts +0 -10
- package/attributes-master/packages/socialshare/src/utils/types.ts +0 -34
- package/attributes-master/packages/socialshare/tsconfig.json +0 -3
- package/attributes-master/packages/starrating/CHANGELOG.md +0 -70
- package/attributes-master/packages/starrating/README.md +0 -25
- package/attributes-master/packages/starrating/package.json +0 -22
- package/attributes-master/packages/starrating/src/actions/classes.ts +0 -41
- package/attributes-master/packages/starrating/src/actions/events.ts +0 -80
- package/attributes-master/packages/starrating/src/factory.ts +0 -24
- package/attributes-master/packages/starrating/src/index.ts +0 -3
- package/attributes-master/packages/starrating/src/init.ts +0 -24
- package/attributes-master/packages/starrating/src/utils/constants.ts +0 -20
- package/attributes-master/packages/starrating/src/utils/helpers.ts +0 -63
- package/attributes-master/packages/starrating/src/utils/selectors.ts +0 -9
- package/attributes-master/packages/starrating/tsconfig.json +0 -3
- package/attributes-master/packages/template/README.md +0 -25
- package/attributes-master/packages/template/package.json +0 -22
- package/attributes-master/packages/template/src/actions/console.ts +0 -4
- package/attributes-master/packages/template/src/index.ts +0 -3
- package/attributes-master/packages/template/src/init.ts +0 -14
- package/attributes-master/packages/template/src/utils/constants.ts +0 -18
- package/attributes-master/packages/template/src/utils/selectors.ts +0 -5
- package/attributes-master/packages/template/tsconfig.json +0 -3
- package/attributes-master/packages/toc/CHANGELOG.md +0 -192
- package/attributes-master/packages/toc/README.md +0 -25
- package/attributes-master/packages/toc/package.json +0 -23
- package/attributes-master/packages/toc/src/actions/collect.ts +0 -136
- package/attributes-master/packages/toc/src/actions/create.ts +0 -44
- package/attributes-master/packages/toc/src/actions/events.ts +0 -29
- package/attributes-master/packages/toc/src/actions/observe.ts +0 -31
- package/attributes-master/packages/toc/src/actions/populate.ts +0 -68
- package/attributes-master/packages/toc/src/actions/prepare.ts +0 -25
- package/attributes-master/packages/toc/src/actions/scroll.ts +0 -33
- package/attributes-master/packages/toc/src/components/TOCItem.ts +0 -88
- package/attributes-master/packages/toc/src/factory.ts +0 -47
- package/attributes-master/packages/toc/src/index.ts +0 -3
- package/attributes-master/packages/toc/src/init.ts +0 -37
- package/attributes-master/packages/toc/src/utils/constants.ts +0 -55
- package/attributes-master/packages/toc/src/utils/helpers.ts +0 -23
- package/attributes-master/packages/toc/src/utils/selectors.ts +0 -6
- package/attributes-master/packages/toc/src/utils/types.ts +0 -21
- package/attributes-master/packages/toc/tsconfig.json +0 -3
- package/attributes-master/packages/utils/CHANGELOG.md +0 -43
- package/attributes-master/packages/utils/package.json +0 -27
- package/attributes-master/packages/utils/src/animations/factory.ts +0 -100
- package/attributes-master/packages/utils/src/animations/index.ts +0 -73
- package/attributes-master/packages/utils/src/animations/types.ts +0 -37
- package/attributes-master/packages/utils/src/components/Interaction.ts +0 -79
- package/attributes-master/packages/utils/src/components/Renderer.ts +0 -59
- package/attributes-master/packages/utils/src/components/index.ts +0 -2
- package/attributes-master/packages/utils/src/constants/a11y.ts +0 -50
- package/attributes-master/packages/utils/src/constants/attributes.ts +0 -57
- package/attributes-master/packages/utils/src/constants/index.ts +0 -5
- package/attributes-master/packages/utils/src/constants/keyboard.ts +0 -10
- package/attributes-master/packages/utils/src/constants/webflow.ts +0 -74
- package/attributes-master/packages/utils/src/helpers/dates.ts +0 -17
- package/attributes-master/packages/utils/src/helpers/dom.ts +0 -82
- package/attributes-master/packages/utils/src/helpers/events.ts +0 -59
- package/attributes-master/packages/utils/src/helpers/fetch.ts +0 -217
- package/attributes-master/packages/utils/src/helpers/forms.ts +0 -238
- package/attributes-master/packages/utils/src/helpers/guards.ts +0 -138
- package/attributes-master/packages/utils/src/helpers/index.ts +0 -11
- package/attributes-master/packages/utils/src/helpers/numbers.ts +0 -86
- package/attributes-master/packages/utils/src/helpers/selectors.ts +0 -249
- package/attributes-master/packages/utils/src/helpers/strings.ts +0 -19
- package/attributes-master/packages/utils/src/helpers/wait.ts +0 -36
- package/attributes-master/packages/utils/src/helpers/webflow.ts +0 -117
- package/attributes-master/packages/utils/src/index.ts +0 -5
- package/attributes-master/packages/utils/src/types/core.ts +0 -100
- package/attributes-master/packages/utils/src/types/dom.ts +0 -31
- package/attributes-master/packages/utils/src/types/index.ts +0 -4
- package/attributes-master/packages/utils/src/types/utils.ts +0 -20
- package/attributes-master/packages/utils/src/types/webflow.ts +0 -147
- package/attributes-master/packages/utils/tsconfig.json +0 -3
- package/attributes-master/packages/videohls/CHANGELOG.md +0 -76
- package/attributes-master/packages/videohls/README.md +0 -27
- package/attributes-master/packages/videohls/package.json +0 -26
- package/attributes-master/packages/videohls/src/actions/list.ts +0 -23
- package/attributes-master/packages/videohls/src/actions/video.ts +0 -44
- package/attributes-master/packages/videohls/src/index.ts +0 -3
- package/attributes-master/packages/videohls/src/init.ts +0 -28
- package/attributes-master/packages/videohls/src/utils/constants.ts +0 -12
- package/attributes-master/packages/videohls/src/utils/selectors.ts +0 -5
- package/attributes-master/packages/videohls/src/utils/stores.ts +0 -3
- package/attributes-master/packages/videohls/tsconfig.json +0 -3
- package/attributes-master/pnpm-lock.yaml +0 -3317
- package/attributes-master/pnpm-workspace.yaml +0 -3
- package/attributes-master/tsconfig.json +0 -6
- package/autoInit/smooth-scroll.js +0 -89
- package/debug-version.html +0 -37
- package/utils/navbar.js +0 -214
- package/utils/scroll-progress.js +0 -29
- package/utils/toc.js +0 -77
@@ -1,136 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
ALLOWED_HEADINGS_SELECTOR,
|
3
|
-
ANCHOR_SELECTOR,
|
4
|
-
CUSTOM_HEADING_REGEXP,
|
5
|
-
DEFAULT_INITIAL_HEADING_LEVEL,
|
6
|
-
OMIT_HEADING_REGEXP,
|
7
|
-
} from '../utils/constants';
|
8
|
-
import { extractHeadingLevel } from '../utils/helpers';
|
9
|
-
import { getElementSelector } from '../utils/selectors';
|
10
|
-
import type { HeadingData, LinkData } from '../utils/types';
|
11
|
-
import { createHeadingWrapper } from './create';
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Collects the {@link HeadingData} of all heading elements.
|
15
|
-
* @param contentsElement The element that holds all the contents.
|
16
|
-
*
|
17
|
-
* @returns A {@link HeadingData} array
|
18
|
-
*/
|
19
|
-
export const collectHeadingsData = ({ children }: HTMLElement) => {
|
20
|
-
const headingsData: HeadingData[] = [];
|
21
|
-
|
22
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
23
|
-
const child = children[i];
|
24
|
-
if (!child) continue;
|
25
|
-
|
26
|
-
const headingElement = child.closest<HTMLParagraphElement>(ALLOWED_HEADINGS_SELECTOR);
|
27
|
-
if (!headingElement) continue;
|
28
|
-
|
29
|
-
const { tagName, textContent } = headingElement;
|
30
|
-
if (!textContent) continue;
|
31
|
-
|
32
|
-
const omit = textContent.match(OMIT_HEADING_REGEXP);
|
33
|
-
if (omit) {
|
34
|
-
headingElement.textContent = textContent.replace(OMIT_HEADING_REGEXP, '').trim();
|
35
|
-
continue;
|
36
|
-
}
|
37
|
-
|
38
|
-
const [customTag] = textContent.match(CUSTOM_HEADING_REGEXP) || [];
|
39
|
-
if (customTag) headingElement.textContent = textContent.replace(CUSTOM_HEADING_REGEXP, '').trim();
|
40
|
-
|
41
|
-
const level = extractHeadingLevel(customTag || tagName);
|
42
|
-
if (!level) continue;
|
43
|
-
|
44
|
-
const headingWrapper = createHeadingWrapper(headingElement);
|
45
|
-
if (!headingWrapper) continue;
|
46
|
-
|
47
|
-
const { id } = headingWrapper;
|
48
|
-
|
49
|
-
// Create a placeholder level memo when a heading level has been skipped
|
50
|
-
// Example: the user added an <h5> after an <h3>, he skipped the <h4> level
|
51
|
-
const [previousHeadingData] = headingsData;
|
52
|
-
|
53
|
-
if (previousHeadingData?.level) {
|
54
|
-
const correspondingLevel = previousHeadingData.level - 1;
|
55
|
-
|
56
|
-
if (level < correspondingLevel) {
|
57
|
-
for (let i = 1; i <= correspondingLevel - level; i++) {
|
58
|
-
headingsData.unshift({ level: previousHeadingData.level - i });
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
// Render the wrapper
|
64
|
-
headingElement.insertAdjacentElement('beforebegin', headingWrapper);
|
65
|
-
|
66
|
-
// Group all lower elements under the wrapper
|
67
|
-
const nextHeading = headingsData.find((headingData) => headingData.level <= level);
|
68
|
-
const childrenSlice = Array.from(children).slice(i + 1);
|
69
|
-
|
70
|
-
for (const element of childrenSlice) {
|
71
|
-
if (element === nextHeading?.headingWrapper) break;
|
72
|
-
|
73
|
-
headingWrapper.append(element);
|
74
|
-
}
|
75
|
-
|
76
|
-
// Store the data
|
77
|
-
headingsData.unshift({
|
78
|
-
level,
|
79
|
-
headingElement,
|
80
|
-
headingWrapper,
|
81
|
-
id,
|
82
|
-
});
|
83
|
-
}
|
84
|
-
|
85
|
-
return headingsData;
|
86
|
-
};
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Collects the template links data.
|
90
|
-
* @param firstLinkTemplate
|
91
|
-
* @returns A {@link LinkData} array.
|
92
|
-
*/
|
93
|
-
export const collectLinksData = (firstLinkTemplate: Element) => {
|
94
|
-
const linksData: LinkData[] = [];
|
95
|
-
|
96
|
-
const collectLinkData = (referenceNode: Element) => {
|
97
|
-
// Query elements
|
98
|
-
const linkElement = referenceNode.closest('a');
|
99
|
-
if (!linkElement) return;
|
100
|
-
|
101
|
-
const component = linkElement.parentElement;
|
102
|
-
if (!component) return;
|
103
|
-
|
104
|
-
// Get the link level
|
105
|
-
const previousLevel = linksData[linksData.length - 1]?.level;
|
106
|
-
const level = previousLevel ? previousLevel + 1 : DEFAULT_INITIAL_HEADING_LEVEL;
|
107
|
-
|
108
|
-
linksData.push({
|
109
|
-
linkElement,
|
110
|
-
level,
|
111
|
-
component,
|
112
|
-
});
|
113
|
-
|
114
|
-
// Get next link component
|
115
|
-
const followingTextNodes = [...component.querySelectorAll(`* ${getElementSelector('link')}`)];
|
116
|
-
const followingTextNode = followingTextNodes.find((node) => node !== referenceNode);
|
117
|
-
|
118
|
-
if (!followingTextNode) return component;
|
119
|
-
|
120
|
-
const followingComponent = collectLinkData(followingTextNode);
|
121
|
-
|
122
|
-
// Place the anchor
|
123
|
-
if (followingComponent) {
|
124
|
-
const anchor = new Comment(ANCHOR_SELECTOR);
|
125
|
-
component.insertBefore(anchor, followingComponent);
|
126
|
-
followingComponent.remove();
|
127
|
-
}
|
128
|
-
|
129
|
-
return component;
|
130
|
-
};
|
131
|
-
|
132
|
-
// Init collection
|
133
|
-
collectLinkData(firstLinkTemplate);
|
134
|
-
|
135
|
-
return linksData;
|
136
|
-
};
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import slugify from 'slugify';
|
2
|
-
|
3
|
-
import { ZERO_WIDTH_CHARS_REGEXP } from '../utils/constants';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Creates a wrapper element for a heading and identifies it.
|
7
|
-
* @param headingElement
|
8
|
-
* @returns The new wrapper element.
|
9
|
-
*/
|
10
|
-
export const createHeadingWrapper = (headingElement: HTMLHeadingElement) => {
|
11
|
-
const headingWrapper = document.createElement('div');
|
12
|
-
|
13
|
-
const { id, textContent } = headingElement;
|
14
|
-
const trimmedTextContent = textContent?.trim().replace(ZERO_WIDTH_CHARS_REGEXP, '');
|
15
|
-
|
16
|
-
if (!id && !trimmedTextContent) return;
|
17
|
-
|
18
|
-
if (id) {
|
19
|
-
headingElement.removeAttribute('id');
|
20
|
-
headingWrapper.id = ensureUniqueId(id);
|
21
|
-
} else if (trimmedTextContent) {
|
22
|
-
const slugified = slugify(trimmedTextContent, { lower: true, strict: true });
|
23
|
-
headingWrapper.id = ensureUniqueId(slugified);
|
24
|
-
}
|
25
|
-
|
26
|
-
return headingWrapper;
|
27
|
-
};
|
28
|
-
|
29
|
-
/**
|
30
|
-
* Ensures that an element ID is unique on the page by adding an index suffix if necessary.
|
31
|
-
* @param requestedId
|
32
|
-
* @returns The unique ID.
|
33
|
-
*/
|
34
|
-
const ensureUniqueId = (requestedId: string) => {
|
35
|
-
let proposedId = requestedId;
|
36
|
-
let index = 2;
|
37
|
-
|
38
|
-
while (document.getElementById(proposedId)) {
|
39
|
-
proposedId = `${requestedId}-${index}`;
|
40
|
-
index += 1;
|
41
|
-
}
|
42
|
-
|
43
|
-
return proposedId;
|
44
|
-
};
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { addListener, isElement } from '@finsweet/attributes-utils';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Prevents the TOC links from adding the hash in the URL.
|
5
|
-
* @param tocWrapper
|
6
|
-
* @param hideURLHash Defines if the URL hash should be hidden after clicking the links.
|
7
|
-
*
|
8
|
-
* @returns A callback to remove the event listener.
|
9
|
-
*/
|
10
|
-
export const listenTOCLinkClicks = (tocWrapper: HTMLElement, hideURLHash?: boolean) => {
|
11
|
-
const clickCleanup = addListener(tocWrapper, 'click', (e) => {
|
12
|
-
if (!isElement(e.target)) return;
|
13
|
-
|
14
|
-
const link = e.target.closest('a');
|
15
|
-
if (!link) return;
|
16
|
-
|
17
|
-
e.stopPropagation();
|
18
|
-
|
19
|
-
if (!hideURLHash) return;
|
20
|
-
|
21
|
-
window.setTimeout(() => {
|
22
|
-
const { origin, pathname, search } = window.location;
|
23
|
-
|
24
|
-
history.replaceState('', document.title, origin + pathname + search);
|
25
|
-
});
|
26
|
-
});
|
27
|
-
|
28
|
-
return clickCleanup;
|
29
|
-
};
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import { isHTMLAnchorElement } from '@finsweet/attributes-utils';
|
2
|
-
|
3
|
-
import type { TOCItem } from '../components/TOCItem';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Observes when the TOC links' state changes.
|
7
|
-
* @param tocWrapper
|
8
|
-
* @param tocItems
|
9
|
-
*
|
10
|
-
* @returns The MutationObserver.
|
11
|
-
*/
|
12
|
-
export const observeLinksState = (tocWrapper: HTMLElement, tocItems: TOCItem[]) => {
|
13
|
-
const observer = new MutationObserver((mutations) => {
|
14
|
-
for (const { target } of mutations) {
|
15
|
-
if (!isHTMLAnchorElement(target)) continue;
|
16
|
-
|
17
|
-
const tocItem = tocItems.find(({ linkElement }) => linkElement === target);
|
18
|
-
if (!tocItem) continue;
|
19
|
-
|
20
|
-
tocItem.updateState();
|
21
|
-
}
|
22
|
-
});
|
23
|
-
|
24
|
-
observer.observe(tocWrapper, {
|
25
|
-
attributes: true,
|
26
|
-
subtree: true,
|
27
|
-
attributeFilter: ['class'],
|
28
|
-
});
|
29
|
-
|
30
|
-
return observer;
|
31
|
-
};
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { cloneNode } from '@finsweet/attributes-utils';
|
2
|
-
|
3
|
-
import { TOCItem } from '../components/TOCItem';
|
4
|
-
import { ANCHOR_SELECTOR } from '../utils/constants';
|
5
|
-
import { getElementSelector, queryElement } from '../utils/selectors';
|
6
|
-
import type { HeadingData, LinkData } from '../utils/types';
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Populates all links using the headings data.
|
10
|
-
* @param headingsData
|
11
|
-
* @param linksData
|
12
|
-
* @param tocWrapper
|
13
|
-
*/
|
14
|
-
export const populateLinks = (headingsData: HeadingData[], linksData: LinkData[], tocWrapper: HTMLElement) => {
|
15
|
-
const tocItems: TOCItem[] = [];
|
16
|
-
const levelsMemo: TOCItem[] = [];
|
17
|
-
|
18
|
-
for (const headingData of headingsData) {
|
19
|
-
// Get the corresponding link data
|
20
|
-
const linkData = linksData.find((data) => data.level === headingData.level);
|
21
|
-
if (!linkData) continue;
|
22
|
-
|
23
|
-
// Get the level memo
|
24
|
-
for (let i = levelsMemo.length - 1; i >= 0; i--) {
|
25
|
-
if (headingData.level > levelsMemo[i].level) break;
|
26
|
-
|
27
|
-
levelsMemo.pop();
|
28
|
-
}
|
29
|
-
|
30
|
-
const levelMemo = levelsMemo[levelsMemo.length - 1];
|
31
|
-
|
32
|
-
// Create the component
|
33
|
-
const linkWrapper = levelMemo?.component || tocWrapper;
|
34
|
-
const component = cloneNode(linkData.component);
|
35
|
-
|
36
|
-
const referenceNode = queryElement('link', { scope: component });
|
37
|
-
if (!referenceNode) continue;
|
38
|
-
|
39
|
-
const linkElement = referenceNode.closest('a');
|
40
|
-
if (!linkElement) continue;
|
41
|
-
|
42
|
-
const anchor = [...linkWrapper.childNodes].find(
|
43
|
-
({ nodeType, nodeValue }) => nodeType === 8 && nodeValue === ANCHOR_SELECTOR
|
44
|
-
);
|
45
|
-
if (!anchor) continue;
|
46
|
-
|
47
|
-
const ixTrigger = component.querySelector<HTMLElement>(`:scope > ${getElementSelector('ix-trigger')}`);
|
48
|
-
|
49
|
-
const tocItem = new TOCItem({
|
50
|
-
linkWrapper,
|
51
|
-
component,
|
52
|
-
referenceNode,
|
53
|
-
linkElement,
|
54
|
-
ixTrigger,
|
55
|
-
anchor,
|
56
|
-
...headingData,
|
57
|
-
});
|
58
|
-
|
59
|
-
// Store the new level memo
|
60
|
-
if (!levelMemo || headingData.level > levelMemo.level) {
|
61
|
-
levelsMemo.push(tocItem);
|
62
|
-
}
|
63
|
-
|
64
|
-
tocItems.push(tocItem);
|
65
|
-
}
|
66
|
-
|
67
|
-
return tocItems;
|
68
|
-
};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { ANCHOR_SELECTOR } from '../utils/constants';
|
2
|
-
import { queryElement } from '../utils/selectors';
|
3
|
-
import type { LinkData } from '../utils/types';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Queries the TOC wrapper and replaces the template links for an anchor placeholder.
|
7
|
-
* @param linksData
|
8
|
-
* @param instance
|
9
|
-
*
|
10
|
-
* @returns The TOC wrapper element.
|
11
|
-
*/
|
12
|
-
export const prepareTOC = ([{ component: firstLinkComponent }]: LinkData[], instance: string | null) => {
|
13
|
-
const tocWrapper = queryElement('table', { instance }) || firstLinkComponent.parentElement;
|
14
|
-
if (!tocWrapper) return;
|
15
|
-
|
16
|
-
const anchor = new Comment(ANCHOR_SELECTOR);
|
17
|
-
const isDirectChild = firstLinkComponent.parentElement === tocWrapper;
|
18
|
-
|
19
|
-
if (isDirectChild) tocWrapper.insertBefore(anchor, firstLinkComponent);
|
20
|
-
else tocWrapper.append(anchor);
|
21
|
-
|
22
|
-
firstLinkComponent.remove();
|
23
|
-
|
24
|
-
return tocWrapper;
|
25
|
-
};
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { TOCItem } from '../components/TOCItem';
|
2
|
-
import { getElementSelector } from '../utils/selectors';
|
3
|
-
import type { ScrollOffsetStyles } from '../utils/types';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Sets scroll offset to all headings using CSS scroll-margin.
|
7
|
-
* @param tocWrapper
|
8
|
-
* @param tocItems
|
9
|
-
* @param offsets
|
10
|
-
*
|
11
|
-
*/
|
12
|
-
export const setScrollOffsets = (tocItems: TOCItem[], offsets: ScrollOffsetStyles) => {
|
13
|
-
if (!Object.values(offsets).some(Boolean)) return;
|
14
|
-
|
15
|
-
document.documentElement.style.scrollBehavior = 'smooth';
|
16
|
-
|
17
|
-
for (const tocItem of tocItems) {
|
18
|
-
tocItem.setScrollOffset(offsets);
|
19
|
-
}
|
20
|
-
};
|
21
|
-
|
22
|
-
/**
|
23
|
-
* Scrolls into view the currently active hash anchor in the URL, only if it's part of the table of contents.
|
24
|
-
*/
|
25
|
-
export const scrollToAnchor = () => {
|
26
|
-
const { hash } = window.location;
|
27
|
-
if (!hash) return;
|
28
|
-
|
29
|
-
const id = hash.replace('#', '');
|
30
|
-
const headingWrapper = document.querySelector(`${getElementSelector('contents')} [id="${id}"]`);
|
31
|
-
|
32
|
-
if (headingWrapper) headingWrapper.scrollIntoView({ behavior: 'smooth' });
|
33
|
-
};
|
@@ -1,88 +0,0 @@
|
|
1
|
-
import { CURRENT_CSS_CLASS, Interaction } from '@finsweet/attributes-utils';
|
2
|
-
|
3
|
-
import type { ScrollOffsetStyles, TOCData } from '../utils/types';
|
4
|
-
|
5
|
-
export class TOCItem implements TOCData {
|
6
|
-
public readonly level: number;
|
7
|
-
public readonly linkWrapper: HTMLElement;
|
8
|
-
public readonly referenceNode: Element;
|
9
|
-
public readonly anchor: Node;
|
10
|
-
public readonly component: HTMLElement;
|
11
|
-
public readonly linkElement: HTMLAnchorElement;
|
12
|
-
public readonly headingElement?: HTMLHeadingElement;
|
13
|
-
public readonly headingWrapper?: HTMLDivElement;
|
14
|
-
public readonly id?: string;
|
15
|
-
public readonly ixTrigger: HTMLElement | null;
|
16
|
-
|
17
|
-
private readonly interaction?: Interaction;
|
18
|
-
|
19
|
-
private currentState?: boolean;
|
20
|
-
|
21
|
-
constructor({
|
22
|
-
level,
|
23
|
-
component,
|
24
|
-
linkElement,
|
25
|
-
linkWrapper,
|
26
|
-
headingElement,
|
27
|
-
headingWrapper,
|
28
|
-
id,
|
29
|
-
ixTrigger,
|
30
|
-
referenceNode,
|
31
|
-
anchor,
|
32
|
-
}: TOCData) {
|
33
|
-
this.level = level;
|
34
|
-
this.linkWrapper = linkWrapper;
|
35
|
-
this.referenceNode = referenceNode;
|
36
|
-
this.anchor = anchor;
|
37
|
-
this.component = component;
|
38
|
-
this.linkElement = linkElement;
|
39
|
-
this.headingElement = headingElement;
|
40
|
-
this.headingWrapper = headingWrapper;
|
41
|
-
this.id = id;
|
42
|
-
this.ixTrigger = ixTrigger;
|
43
|
-
this.interaction = ixTrigger ? new Interaction({ element: ixTrigger }) : undefined;
|
44
|
-
|
45
|
-
this.#render();
|
46
|
-
}
|
47
|
-
|
48
|
-
/**
|
49
|
-
* Populates and the link in the TOC.
|
50
|
-
*/
|
51
|
-
#render() {
|
52
|
-
const { headingElement, id, referenceNode, linkElement, linkWrapper, component, anchor } = this;
|
53
|
-
|
54
|
-
if (headingElement && id) {
|
55
|
-
referenceNode.textContent = headingElement.textContent;
|
56
|
-
linkElement.href = `#${id}`;
|
57
|
-
} else {
|
58
|
-
linkElement.remove();
|
59
|
-
}
|
60
|
-
|
61
|
-
linkWrapper.insertBefore(component, anchor);
|
62
|
-
}
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Sets scroll offset to the heading using CSS scroll-margin.
|
66
|
-
* @param offsets
|
67
|
-
*/
|
68
|
-
public setScrollOffset(offsets: ScrollOffsetStyles) {
|
69
|
-
const { headingWrapper } = this;
|
70
|
-
|
71
|
-
if (headingWrapper) Object.assign(headingWrapper.style, offsets);
|
72
|
-
}
|
73
|
-
|
74
|
-
/**
|
75
|
-
* Updates the `active` state of the link and triggers the correspondent interaction, if existing.
|
76
|
-
*/
|
77
|
-
public updateState() {
|
78
|
-
const { linkElement, interaction, currentState } = this;
|
79
|
-
|
80
|
-
const isActive = linkElement.classList.contains(CURRENT_CSS_CLASS);
|
81
|
-
|
82
|
-
if (isActive === currentState) return;
|
83
|
-
|
84
|
-
interaction?.trigger(isActive ? 'first' : 'second');
|
85
|
-
|
86
|
-
this.currentState = isActive;
|
87
|
-
}
|
88
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import { collectHeadingsData, collectLinksData } from './actions/collect';
|
2
|
-
import { listenTOCLinkClicks } from './actions/events';
|
3
|
-
import { observeLinksState } from './actions/observe';
|
4
|
-
import { populateLinks } from './actions/populate';
|
5
|
-
import { prepareTOC } from './actions/prepare';
|
6
|
-
import { setScrollOffsets } from './actions/scroll';
|
7
|
-
import { getAttribute, getInstance, hasAttributeValue, queryElement } from './utils/selectors';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* Inits a TOC instance.
|
11
|
-
* @param contentsElement
|
12
|
-
* @returns
|
13
|
-
*/
|
14
|
-
export const initTOCInstance = (contentsElement: HTMLElement) => {
|
15
|
-
const instance = getInstance(contentsElement);
|
16
|
-
|
17
|
-
const linkTemplate = queryElement('link', { instance });
|
18
|
-
if (!linkTemplate) return;
|
19
|
-
|
20
|
-
const headingsData = collectHeadingsData(contentsElement);
|
21
|
-
const linksData = collectLinksData(linkTemplate) || [];
|
22
|
-
|
23
|
-
if (!headingsData.length || !linksData.length) return;
|
24
|
-
|
25
|
-
const tocWrapper = prepareTOC(linksData, instance);
|
26
|
-
if (!tocWrapper) return;
|
27
|
-
|
28
|
-
const tocItems = populateLinks(headingsData, linksData, tocWrapper);
|
29
|
-
|
30
|
-
// Scroll offset
|
31
|
-
const scrollMarginTop = getAttribute(contentsElement, 'offsettop');
|
32
|
-
const scrollMarginBottom = getAttribute(contentsElement, 'offsetbottom');
|
33
|
-
|
34
|
-
setScrollOffsets(tocItems, { scrollMarginTop, scrollMarginBottom });
|
35
|
-
|
36
|
-
// Handle TOC link clicks
|
37
|
-
const hideURLHash = hasAttributeValue(contentsElement, 'hideurlhash', 'true');
|
38
|
-
const removeListener = listenTOCLinkClicks(tocWrapper, hideURLHash);
|
39
|
-
|
40
|
-
// Link States
|
41
|
-
const observer = observeLinksState(tocWrapper, tocItems);
|
42
|
-
|
43
|
-
return () => {
|
44
|
-
removeListener();
|
45
|
-
observer.disconnect();
|
46
|
-
};
|
47
|
-
};
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
type FinsweetAttributeInit,
|
3
|
-
isNotEmpty,
|
4
|
-
restartWebflow,
|
5
|
-
waitAttributeLoaded,
|
6
|
-
waitWebflowReady,
|
7
|
-
} from '@finsweet/attributes-utils';
|
8
|
-
|
9
|
-
import { scrollToAnchor } from './actions/scroll';
|
10
|
-
import { initTOCInstance } from './factory';
|
11
|
-
import { queryAllElements } from './utils/selectors';
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Inits the attribute.
|
15
|
-
*/
|
16
|
-
export const init: FinsweetAttributeInit = async () => {
|
17
|
-
await waitWebflowReady();
|
18
|
-
await waitAttributeLoaded('inject');
|
19
|
-
|
20
|
-
const contentsElements = queryAllElements('contents');
|
21
|
-
|
22
|
-
const cleanups = contentsElements.map(initTOCInstance).filter(isNotEmpty);
|
23
|
-
|
24
|
-
// URL hash Anchor
|
25
|
-
scrollToAnchor();
|
26
|
-
|
27
|
-
if (cleanups.length) {
|
28
|
-
await restartWebflow();
|
29
|
-
}
|
30
|
-
|
31
|
-
// TODO: Finish API
|
32
|
-
return {
|
33
|
-
destroy() {
|
34
|
-
for (const cleanup of cleanups) cleanup();
|
35
|
-
},
|
36
|
-
};
|
37
|
-
};
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import { type AttributeElements, type AttributeSettings, TOC_ATTRIBUTE } from '@finsweet/attributes-utils';
|
2
|
-
|
3
|
-
export const ELEMENTS = [
|
4
|
-
/**
|
5
|
-
* Defines the contents to use as the table source.
|
6
|
-
*/
|
7
|
-
'contents',
|
8
|
-
|
9
|
-
/**
|
10
|
-
* OPTIONAL. Defines the wrapper element that will hold all the TOC links.
|
11
|
-
* If not defined, the library will use the immediate parent of the link template elements.
|
12
|
-
*/
|
13
|
-
'table',
|
14
|
-
|
15
|
-
/**
|
16
|
-
* Defines a link template element.
|
17
|
-
* If the attribute is set to a non-link element, the library will look up for the first parent element that is a link.
|
18
|
-
*/
|
19
|
-
'link',
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Defines an interaction trigger.
|
23
|
-
* This attribute must be added to a hidden div and place it inside the correspondent link wrapper.
|
24
|
-
* When the link is active, it will trigger the "First Click" interaction. When the link is unactive, it will trigger the "Second Click" interaction.
|
25
|
-
*/
|
26
|
-
'ix-trigger',
|
27
|
-
] as const satisfies AttributeElements;
|
28
|
-
|
29
|
-
export const SETTINGS = {
|
30
|
-
/**
|
31
|
-
* Defines a [scroll-margin-top](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-top) value for the headers.
|
32
|
-
*/
|
33
|
-
offsettop: { key: 'offsettop' },
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Defines a [scroll-margin-bottom](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-bottom) value for the headers.
|
37
|
-
*/
|
38
|
-
offsetbottom: { key: 'offsetbottom' },
|
39
|
-
|
40
|
-
/**
|
41
|
-
* Defines if the links hash should be removed from the URL.
|
42
|
-
*/
|
43
|
-
hideurlhash: { key: 'hideurlhash', values: ['true'] },
|
44
|
-
} as const satisfies AttributeSettings;
|
45
|
-
|
46
|
-
export const DEFAULT_INITIAL_HEADING_LEVEL = 2;
|
47
|
-
export const ANCHOR_SELECTOR = `fs-${TOC_ATTRIBUTE}-anchor`;
|
48
|
-
|
49
|
-
const ALLOWED_HEADINGS_REGEX = '[2-6]';
|
50
|
-
export const ALLOWED_HEADINGS_SELECTOR = 'h2, h3, h4, h5, h6';
|
51
|
-
|
52
|
-
export const OMIT_HEADING_REGEXP = new RegExp(`^\\[fs-${TOC_ATTRIBUTE}-omit\\]`, 'i');
|
53
|
-
export const CUSTOM_HEADING_REGEXP = new RegExp(`^\\[fs-${TOC_ATTRIBUTE}-h${ALLOWED_HEADINGS_REGEX}\\]`, 'i');
|
54
|
-
export const HEADING_LEVEL_REGEXP = new RegExp(ALLOWED_HEADINGS_REGEX);
|
55
|
-
export const ZERO_WIDTH_CHARS_REGEXP = /[\u200B-\u200D\uFEFF]/g;
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import { HEADING_LEVEL_REGEXP } from './constants';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Extracts the heading level from a heading tag.
|
5
|
-
* @param value The heading tag.
|
6
|
-
*
|
7
|
-
* @example ```
|
8
|
-
* extractHeadingLevel('h2') // 2
|
9
|
-
* extractHeadingLevel('h5') // 5
|
10
|
-
* extractHeadingLevel('5') // 5
|
11
|
-
* extractHeadingLevel('hh') // undefined
|
12
|
-
* ```
|
13
|
-
*
|
14
|
-
*/
|
15
|
-
export const extractHeadingLevel = (value: string) => {
|
16
|
-
const rawLevel = value.match(HEADING_LEVEL_REGEXP)?.[0];
|
17
|
-
if (!rawLevel) return;
|
18
|
-
|
19
|
-
const level = parseInt(rawLevel);
|
20
|
-
if (isNaN(level)) return;
|
21
|
-
|
22
|
-
return level;
|
23
|
-
};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { generateSelectors, TOC_ATTRIBUTE } from '@finsweet/attributes-utils';
|
2
|
-
|
3
|
-
import { ELEMENTS, SETTINGS } from './constants';
|
4
|
-
|
5
|
-
export const { getElementSelector, queryElement, getInstance, getAttribute, hasAttributeValue, queryAllElements } =
|
6
|
-
generateSelectors(TOC_ATTRIBUTE, ELEMENTS, SETTINGS);
|
@@ -1,21 +0,0 @@
|
|
1
|
-
export interface HeadingData {
|
2
|
-
level: number;
|
3
|
-
headingElement?: HTMLHeadingElement;
|
4
|
-
id?: string;
|
5
|
-
headingWrapper?: HTMLDivElement;
|
6
|
-
}
|
7
|
-
|
8
|
-
export interface LinkData {
|
9
|
-
level: number;
|
10
|
-
linkElement: HTMLAnchorElement;
|
11
|
-
component: HTMLElement;
|
12
|
-
}
|
13
|
-
|
14
|
-
export interface TOCData extends HeadingData, LinkData {
|
15
|
-
referenceNode: Element;
|
16
|
-
linkWrapper: HTMLElement;
|
17
|
-
ixTrigger: HTMLElement | null;
|
18
|
-
anchor: Node;
|
19
|
-
}
|
20
|
-
|
21
|
-
export type ScrollOffsetStyles = Partial<Pick<HTMLElement['style'], 'scrollMarginTop' | 'scrollMarginBottom'>>;
|