@studiometa/js-toolkit 4.0.0-alpha.1 → 4.0.0-alpha.3
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/README.md +10 -0
- package/dist/Base.d.ts +0 -2
- package/dist/Base.js +1 -2
- package/dist/Base.js.map +1 -1
- package/dist/attribute-namespaces.d.ts +0 -2
- package/dist/attribute-namespaces.js +1 -2
- package/dist/attributes.d.ts +0 -2
- package/dist/attributes.js +1 -2
- package/dist/children-watchers.d.ts +0 -2
- package/dist/children-watchers.js +1 -2
- package/dist/component-brand.d.ts +0 -2
- package/dist/component-brand.js +1 -2
- package/dist/component-declarations.d.ts +0 -2
- package/dist/component-declarations.js +1 -2
- package/dist/context-subscription.d.ts +0 -2
- package/dist/context-subscription.js +1 -2
- package/dist/context.d.ts +0 -2
- package/dist/context.js +1 -2
- package/dist/decorators.d.ts +0 -2
- package/dist/decorators.js +1 -2
- package/dist/diagnostic-contract.d.ts +0 -2
- package/dist/diagnostic-contract.js +1 -2
- package/dist/diagnostics.d.ts +0 -2
- package/dist/diagnostics.js +1 -2
- package/dist/document-order.d.ts +0 -2
- package/dist/document-order.js +1 -2
- package/dist/dom-mutations.d.ts +0 -2
- package/dist/dom-mutations.js +1 -2
- package/dist/events.d.ts +0 -2
- package/dist/events.js +1 -2
- package/dist/group.d.ts +0 -2
- package/dist/group.js +1 -2
- package/dist/instances.d.ts +0 -2
- package/dist/instances.js +1 -2
- package/dist/manifest.d.ts +0 -2
- package/dist/manifest.js +1 -2
- package/dist/mount-strategies.d.ts +0 -2
- package/dist/mount-strategies.js +1 -2
- package/dist/negotiated-events.d.ts +0 -2
- package/dist/negotiated-events.js +1 -2
- package/dist/protocol-symbols.d.ts +0 -2
- package/dist/protocol-symbols.js +1 -2
- package/dist/registry.d.ts +0 -2
- package/dist/registry.js +1 -2
- package/dist/responsive-options.d.ts +0 -2
- package/dist/responsive-options.js +1 -2
- package/dist/scheduler.d.ts +0 -2
- package/dist/scheduler.js +1 -2
- package/dist/scheduler.js.map +1 -1
- package/dist/services/breakpoint.d.ts +0 -2
- package/dist/services/breakpoint.js +1 -2
- package/dist/services/drag.d.ts +0 -2
- package/dist/services/drag.js +1 -2
- package/dist/services/in-view.d.ts +0 -2
- package/dist/services/in-view.js +1 -2
- package/dist/services/key.d.ts +0 -2
- package/dist/services/key.js +1 -2
- package/dist/services/media.d.ts +0 -2
- package/dist/services/media.js +1 -2
- package/dist/services/mixin.d.ts +0 -2
- package/dist/services/mixin.js +1 -2
- package/dist/services/mutation.d.ts +0 -2
- package/dist/services/mutation.js +1 -2
- package/dist/services/pointer.d.ts +0 -2
- package/dist/services/pointer.js +1 -2
- package/dist/services/raf.d.ts +0 -2
- package/dist/services/raf.js +1 -2
- package/dist/services/resize.d.ts +0 -2
- package/dist/services/resize.js +1 -2
- package/dist/services/scroll-progress-offset.d.ts +0 -2
- package/dist/services/scroll-progress-offset.js +1 -2
- package/dist/services/scroll-progress.d.ts +0 -2
- package/dist/services/scroll-progress.js +1 -2
- package/dist/services/scroll.d.ts +0 -2
- package/dist/services/scroll.js +1 -2
- package/dist/services/service.d.ts +0 -2
- package/dist/services/service.js +1 -2
- package/dist/services/toggle.d.ts +0 -2
- package/dist/services/toggle.js +1 -2
- package/dist/services/until.d.ts +0 -2
- package/dist/services/until.js +1 -2
- package/dist/shared-runtime.d.ts +0 -2
- package/dist/shared-runtime.js +1 -2
- package/dist/storage/createStorage.d.ts +0 -2
- package/dist/storage/createStorage.js +1 -2
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +1 -2
- package/dist/storage/providers.d.ts +0 -2
- package/dist/storage/providers.js +1 -2
- package/dist/storage/serializers.d.ts +0 -2
- package/dist/storage/serializers.js +1 -2
- package/dist/storage/sync.d.ts +0 -2
- package/dist/storage/sync.js +1 -2
- package/dist/storage/types.d.ts +0 -2
- package/dist/subpaths/BREAKPOINTS.js +1 -2
- package/dist/subpaths/Base.js +1 -2
- package/dist/subpaths/DIAGNOSTICS.js +1 -2
- package/dist/subpaths/DRAG_MODES.js +1 -2
- package/dist/subpaths/EVENTS.js +1 -2
- package/dist/subpaths/MOUNT_ATTRIBUTE.js +1 -2
- package/dist/subpaths/SWAP_MODES.js +1 -2
- package/dist/subpaths/children.js +1 -2
- package/dist/subpaths/component.js +1 -2
- package/dist/subpaths/createContext.js +1 -2
- package/dist/subpaths/createFallbackProvider.js +1 -2
- package/dist/subpaths/createGroup.js +1 -2
- package/dist/subpaths/createLocalStorage.js +1 -2
- package/dist/subpaths/createMemoryStorageProvider.js +1 -2
- package/dist/subpaths/createService.js +1 -2
- package/dist/subpaths/createServiceMixin.js +1 -2
- package/dist/subpaths/createSessionStorage.js +1 -2
- package/dist/subpaths/createStorage.js +1 -2
- package/dist/subpaths/createUrlSearchParamsInHashProvider.js +1 -2
- package/dist/subpaths/createUrlSearchParamsInHashStorage.js +1 -2
- package/dist/subpaths/createUrlSearchParamsProvider.js +1 -2
- package/dist/subpaths/createUrlSearchParamsStorage.js +1 -2
- package/dist/subpaths/defaultScheduler.js +1 -2
- package/dist/subpaths/defineManifest.js +1 -2
- package/dist/subpaths/domUpdate.js +1 -2
- package/dist/subpaths/emitExtendable.js +1 -2
- package/dist/subpaths/fromMetaGlob.js +1 -2
- package/dist/subpaths/fromWebpackContext.js +1 -2
- package/dist/subpaths/getBreakpoints.js +1 -2
- package/dist/subpaths/getInstance.js +1 -2
- package/dist/subpaths/getInstances.js +1 -2
- package/dist/subpaths/getMountedInstances.js +1 -2
- package/dist/subpaths/getUnmountedInstances.js +1 -2
- package/dist/subpaths/inject.js +1 -2
- package/dist/subpaths/injectContext.js +1 -2
- package/dist/subpaths/injectContextSync.js +1 -2
- package/dist/subpaths/jsonSerializer.js +1 -2
- package/dist/subpaths/localStorageProvider.js +1 -2
- package/dist/subpaths/memoryStorageProvider.js +1 -2
- package/dist/subpaths/namespaceQualifier.js +1 -2
- package/dist/subpaths/nextFrame.js +1 -2
- package/dist/subpaths/on.js +1 -2
- package/dist/subpaths/perTarget.js +1 -2
- package/dist/subpaths/provide.js +1 -2
- package/dist/subpaths/provideContext.js +1 -2
- package/dist/subpaths/provideRootContext.js +1 -2
- package/dist/subpaths/read.js +1 -2
- package/dist/subpaths/registerComponent.js +1 -2
- package/dist/subpaths/registerComponents.js +1 -2
- package/dist/subpaths/registerManifest.js +1 -2
- package/dist/subpaths/reportDiagnostic.js +1 -2
- package/dist/subpaths/sessionStorageProvider.js +1 -2
- package/dist/subpaths/setBreakpoints.js +1 -2
- package/dist/subpaths/signal.js +1 -2
- package/dist/subpaths/subscribeContext.js +1 -2
- package/dist/subpaths/swap.js +1 -2
- package/dist/subpaths/toggle.js +1 -2
- package/dist/subpaths/until.js +1 -2
- package/dist/subpaths/urlSearchParamsInHashProvider.js +1 -2
- package/dist/subpaths/urlSearchParamsProvider.js +1 -2
- package/dist/subpaths/useBreakpoint.js +1 -2
- package/dist/subpaths/useDrag.js +1 -2
- package/dist/subpaths/useInView.js +1 -2
- package/dist/subpaths/useKey.js +1 -2
- package/dist/subpaths/useMediaQuery.js +1 -2
- package/dist/subpaths/useMutation.js +1 -2
- package/dist/subpaths/usePointer.js +1 -2
- package/dist/subpaths/usePrefersReducedMotion.js +1 -2
- package/dist/subpaths/useRaf.js +1 -2
- package/dist/subpaths/useResize.js +1 -2
- package/dist/subpaths/useScroll.js +1 -2
- package/dist/subpaths/useScrollProgress.js +1 -2
- package/dist/subpaths/useWindowScroll.js +1 -2
- package/dist/subpaths/useWindowSize.js +1 -2
- package/dist/subpaths/utils/DEFAULT_DAMP_FACTOR.js +1 -2
- package/dist/subpaths/utils/INERTIA_FRAME.js +1 -2
- package/dist/subpaths/utils/MAX_SPRING_RATIO.js +1 -2
- package/dist/subpaths/utils/SCROLL_ALIGNMENTS.js +1 -2
- package/dist/subpaths/utils/SCROLL_AXES.js +1 -2
- package/dist/subpaths/utils/TRANSFORM_PROPS.js +1 -2
- package/dist/subpaths/utils/TRANSITION_OPTIONS.js +1 -2
- package/dist/subpaths/utils/camelCase.js +1 -2
- package/dist/subpaths/utils/capitalize.js +1 -2
- package/dist/subpaths/utils/clamp.js +1 -2
- package/dist/subpaths/utils/clamp01.js +1 -2
- package/dist/subpaths/utils/clampDampFactor.js +1 -2
- package/dist/subpaths/utils/createEaseInOut.js +1 -2
- package/dist/subpaths/utils/createEaseOut.js +1 -2
- package/dist/subpaths/utils/createElement.js +1 -2
- package/dist/subpaths/utils/createRange.js +1 -2
- package/dist/subpaths/utils/damp.js +1 -2
- package/dist/subpaths/utils/debounce.js +1 -2
- package/dist/subpaths/utils/decayOver.js +1 -2
- package/dist/subpaths/utils/deepmerge.js +1 -2
- package/dist/subpaths/utils/easeInCirc.js +1 -2
- package/dist/subpaths/utils/easeInCubic.js +1 -2
- package/dist/subpaths/utils/easeInExpo.js +1 -2
- package/dist/subpaths/utils/easeInOutCirc.js +1 -2
- package/dist/subpaths/utils/easeInOutCubic.js +1 -2
- package/dist/subpaths/utils/easeInOutExpo.js +1 -2
- package/dist/subpaths/utils/easeInOutQuad.js +1 -2
- package/dist/subpaths/utils/easeInOutQuart.js +1 -2
- package/dist/subpaths/utils/easeInOutQuint.js +1 -2
- package/dist/subpaths/utils/easeInOutSine.js +1 -2
- package/dist/subpaths/utils/easeInQuad.js +1 -2
- package/dist/subpaths/utils/easeInQuart.js +1 -2
- package/dist/subpaths/utils/easeInQuint.js +1 -2
- package/dist/subpaths/utils/easeInSine.js +1 -2
- package/dist/subpaths/utils/easeLinear.js +1 -2
- package/dist/subpaths/utils/easeOutCirc.js +1 -2
- package/dist/subpaths/utils/easeOutCubic.js +1 -2
- package/dist/subpaths/utils/easeOutExpo.js +1 -2
- package/dist/subpaths/utils/easeOutQuad.js +1 -2
- package/dist/subpaths/utils/easeOutQuart.js +1 -2
- package/dist/subpaths/utils/easeOutQuint.js +1 -2
- package/dist/subpaths/utils/easeOutSine.js +1 -2
- package/dist/subpaths/utils/enterTransition.js +1 -2
- package/dist/subpaths/utils/fold.js +1 -2
- package/dist/subpaths/utils/getOffsetSizes.js +1 -2
- package/dist/subpaths/utils/historyPush.js +1 -2
- package/dist/subpaths/utils/historyReplace.js +1 -2
- package/dist/subpaths/utils/inertiaDecay.js +1 -2
- package/dist/subpaths/utils/inertiaFinalValue.js +1 -2
- package/dist/subpaths/utils/inertiaStep.js +1 -2
- package/dist/subpaths/utils/inertiaTimeConstant.js +1 -2
- package/dist/subpaths/utils/isBoolean.js +1 -2
- package/dist/subpaths/utils/isDefined.js +1 -2
- package/dist/subpaths/utils/isFunction.js +1 -2
- package/dist/subpaths/utils/isNull.js +1 -2
- package/dist/subpaths/utils/isNumber.js +1 -2
- package/dist/subpaths/utils/isObject.js +1 -2
- package/dist/subpaths/utils/isString.js +1 -2
- package/dist/subpaths/utils/kebabCase.js +1 -2
- package/dist/subpaths/utils/leaveTransition.js +1 -2
- package/dist/subpaths/utils/lerp.js +1 -2
- package/dist/subpaths/utils/loadImage.js +1 -2
- package/dist/subpaths/utils/loadLink.js +1 -2
- package/dist/subpaths/utils/loadScript.js +1 -2
- package/dist/subpaths/utils/lockScroll.js +1 -2
- package/dist/subpaths/utils/lowerCase.js +1 -2
- package/dist/subpaths/utils/map.js +1 -2
- package/dist/subpaths/utils/matrix.js +1 -2
- package/dist/subpaths/utils/mean.js +1 -2
- package/dist/subpaths/utils/memo.js +1 -2
- package/dist/subpaths/utils/noop.js +1 -2
- package/dist/subpaths/utils/noopValue.js +1 -2
- package/dist/subpaths/utils/objectToURLSearchParams.js +1 -2
- package/dist/subpaths/utils/pascalCase.js +1 -2
- package/dist/subpaths/utils/random.js +1 -2
- package/dist/subpaths/utils/randomInt.js +1 -2
- package/dist/subpaths/utils/randomItem.js +1 -2
- package/dist/subpaths/utils/round.js +1 -2
- package/dist/subpaths/utils/saveActiveElement.js +1 -2
- package/dist/subpaths/utils/scrollPosition.js +1 -2
- package/dist/subpaths/utils/scrollTo.js +1 -2
- package/dist/subpaths/utils/selectorFor.js +1 -2
- package/dist/subpaths/utils/setClassesOrStyles.js +1 -2
- package/dist/subpaths/utils/smoothTo.js +1 -2
- package/dist/subpaths/utils/snakeCase.js +1 -2
- package/dist/subpaths/utils/spring.js +1 -2
- package/dist/subpaths/utils/throttle.js +1 -2
- package/dist/subpaths/utils/transform.js +1 -2
- package/dist/subpaths/utils/transition.js +1 -2
- package/dist/subpaths/utils/trapFocus.js +1 -2
- package/dist/subpaths/utils/untrapFocus.js +1 -2
- package/dist/subpaths/utils/upperCase.js +1 -2
- package/dist/subpaths/utils/wait.js +1 -2
- package/dist/subpaths/utils/withLeadingCharacters.js +1 -2
- package/dist/subpaths/utils/withLeadingSlash.js +1 -2
- package/dist/subpaths/utils/withTrailingCharacters.js +1 -2
- package/dist/subpaths/utils/withTrailingSlash.js +1 -2
- package/dist/subpaths/utils/withoutLeadingCharacters.js +1 -2
- package/dist/subpaths/utils/withoutLeadingCharactersRecursive.js +1 -2
- package/dist/subpaths/utils/withoutLeadingSlash.js +1 -2
- package/dist/subpaths/utils/withoutTrailingCharacters.js +1 -2
- package/dist/subpaths/utils/withoutTrailingCharactersRecursive.js +1 -2
- package/dist/subpaths/utils/withoutTrailingSlash.js +1 -2
- package/dist/subpaths/utils/wrap.js +1 -2
- package/dist/subpaths/viewTransition.js +1 -2
- package/dist/subpaths/warn.js +1 -2
- package/dist/subpaths/watchAttributeNamespace.js +1 -2
- package/dist/subpaths/watchAttributes.js +1 -2
- package/dist/subpaths/whenDOMSettled.js +1 -2
- package/dist/subpaths/withDrag.js +1 -2
- package/dist/subpaths/withInView.js +1 -2
- package/dist/subpaths/withKey.js +1 -2
- package/dist/subpaths/withMutation.js +1 -2
- package/dist/subpaths/withPointer.js +1 -2
- package/dist/subpaths/withRaf.js +1 -2
- package/dist/subpaths/withResize.js +1 -2
- package/dist/subpaths/withScroll.js +1 -2
- package/dist/subpaths/withScrollProgress.js +1 -2
- package/dist/subpaths/write.js +1 -2
- package/dist/swap.d.ts +0 -2
- package/dist/swap.js +1 -2
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.js +1 -2
- package/dist/utils/deepmerge.d.ts +0 -2
- package/dist/utils/deepmerge.js +1 -2
- package/dist/utils/dom.d.ts +0 -2
- package/dist/utils/dom.js +1 -2
- package/dist/utils/easings.d.ts +0 -2
- package/dist/utils/easings.js +1 -2
- package/dist/utils/focus.d.ts +0 -2
- package/dist/utils/focus.js +1 -2
- package/dist/utils/history.d.ts +0 -2
- package/dist/utils/history.js +1 -2
- package/dist/utils/is.d.ts +0 -2
- package/dist/utils/is.js +1 -2
- package/dist/utils/load.d.ts +0 -2
- package/dist/utils/load.js +1 -2
- package/dist/utils/maths.d.ts +0 -2
- package/dist/utils/maths.js +1 -2
- package/dist/utils/memo.d.ts +0 -2
- package/dist/utils/memo.js +1 -2
- package/dist/utils/noop.d.ts +0 -2
- package/dist/utils/noop.js +1 -2
- package/dist/utils/random.d.ts +0 -2
- package/dist/utils/random.js +1 -2
- package/dist/utils/scroll-lock.d.ts +0 -2
- package/dist/utils/scroll-lock.js +1 -2
- package/dist/utils/scrollTo.d.ts +0 -2
- package/dist/utils/scrollTo.js +1 -2
- package/dist/utils/selectors.d.ts +0 -2
- package/dist/utils/selectors.js +1 -2
- package/dist/utils/smoothTo.d.ts +0 -2
- package/dist/utils/smoothTo.js +1 -2
- package/dist/utils/strings.d.ts +0 -2
- package/dist/utils/strings.js +1 -2
- package/dist/utils/timing.d.ts +0 -2
- package/dist/utils/timing.js +1 -2
- package/dist/utils/transform.d.ts +0 -2
- package/dist/utils/transform.js +1 -2
- package/dist/utils/transition.d.ts +0 -2
- package/dist/utils/transition.js +1 -2
- package/dist/viewTransition.d.ts +0 -2
- package/dist/viewTransition.js +1 -2
- package/package.json +6 -3
- package/skills/studiometa-js-toolkit/SKILL.md +87 -0
- package/skills/studiometa-js-toolkit/references/api/configuration.md +169 -0
- package/skills/studiometa-js-toolkit/references/api/context/createContext.md +46 -0
- package/skills/studiometa-js-toolkit/references/api/context/createGroup.md +67 -0
- package/skills/studiometa-js-toolkit/references/api/context/index.md +69 -0
- package/skills/studiometa-js-toolkit/references/api/context/injectContext.md +58 -0
- package/skills/studiometa-js-toolkit/references/api/context/injectContextSync.md +44 -0
- package/skills/studiometa-js-toolkit/references/api/context/provideContext.md +61 -0
- package/skills/studiometa-js-toolkit/references/api/context/provideRootContext.md +42 -0
- package/skills/studiometa-js-toolkit/references/api/context/signal.md +85 -0
- package/skills/studiometa-js-toolkit/references/api/context/subscribeContext.md +71 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/children.md +92 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/component.md +75 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/index.md +41 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/inject.md +73 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/on.md +149 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/provide.md +77 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/read-write.md +93 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/DIAGNOSTICS.md +137 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/EVENTS.md +45 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/index.md +58 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/reportDiagnostic.md +67 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/warn.md +54 -0
- package/skills/studiometa-js-toolkit/references/api/dom/breakpoints.md +81 -0
- package/skills/studiometa-js-toolkit/references/api/dom/domUpdate.md +70 -0
- package/skills/studiometa-js-toolkit/references/api/dom/emitExtendable.md +68 -0
- package/skills/studiometa-js-toolkit/references/api/dom/index.md +26 -0
- package/skills/studiometa-js-toolkit/references/api/dom/swap.md +105 -0
- package/skills/studiometa-js-toolkit/references/api/dom/watchAttributeNamespace.md +96 -0
- package/skills/studiometa-js-toolkit/references/api/dom/watchAttributes.md +56 -0
- package/skills/studiometa-js-toolkit/references/api/dom/whenDOMSettled.md +41 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-component.md +105 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-mount.md +69 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-option.md +106 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-ref.md +63 -0
- package/skills/studiometa-js-toolkit/references/api/html/index.md +32 -0
- package/skills/studiometa-js-toolkit/references/api/index.md +73 -0
- package/skills/studiometa-js-toolkit/references/api/instance-events.md +75 -0
- package/skills/studiometa-js-toolkit/references/api/instance-methods.md +267 -0
- package/skills/studiometa-js-toolkit/references/api/instance-properties.md +90 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-events.md +149 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-lifecycle.md +90 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-options.md +96 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-services.md +164 -0
- package/skills/studiometa-js-toolkit/references/api/registry/defineManifest.md +57 -0
- package/skills/studiometa-js-toolkit/references/api/registry/fromMetaGlob.md +33 -0
- package/skills/studiometa-js-toolkit/references/api/registry/fromWebpackContext.md +37 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getInstance.md +52 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getInstances.md +48 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getMountedInstances.md +39 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getUnmountedInstances.md +46 -0
- package/skills/studiometa-js-toolkit/references/api/registry/index.md +49 -0
- package/skills/studiometa-js-toolkit/references/api/registry/registerComponent.md +93 -0
- package/skills/studiometa-js-toolkit/references/api/registry/registerComponents.md +37 -0
- package/skills/studiometa-js-toolkit/references/api/registry/registerManifest.md +72 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/defaultScheduler.md +104 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/index.md +27 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/nextFrame.md +31 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/viewTransition.md +53 -0
- package/skills/studiometa-js-toolkit/references/api/services/createService.md +95 -0
- package/skills/studiometa-js-toolkit/references/api/services/createServiceMixin.md +81 -0
- package/skills/studiometa-js-toolkit/references/api/services/index.md +94 -0
- package/skills/studiometa-js-toolkit/references/api/services/mixins.md +148 -0
- package/skills/studiometa-js-toolkit/references/api/services/perTarget.md +65 -0
- package/skills/studiometa-js-toolkit/references/api/services/toggle.md +80 -0
- package/skills/studiometa-js-toolkit/references/api/services/until.md +44 -0
- package/skills/studiometa-js-toolkit/references/api/services/useBreakpoint.md +42 -0
- package/skills/studiometa-js-toolkit/references/api/services/useDrag.md +119 -0
- package/skills/studiometa-js-toolkit/references/api/services/useInView.md +64 -0
- package/skills/studiometa-js-toolkit/references/api/services/useKey.md +105 -0
- package/skills/studiometa-js-toolkit/references/api/services/useMediaQuery.md +45 -0
- package/skills/studiometa-js-toolkit/references/api/services/useMutation.md +69 -0
- package/skills/studiometa-js-toolkit/references/api/services/usePointer.md +91 -0
- package/skills/studiometa-js-toolkit/references/api/services/usePrefersReducedMotion.md +42 -0
- package/skills/studiometa-js-toolkit/references/api/services/useRaf.md +91 -0
- package/skills/studiometa-js-toolkit/references/api/services/useResize.md +60 -0
- package/skills/studiometa-js-toolkit/references/api/services/useScroll.md +88 -0
- package/skills/studiometa-js-toolkit/references/api/services/useScrollProgress.md +88 -0
- package/skills/studiometa-js-toolkit/references/api/services/useWindowScroll.md +25 -0
- package/skills/studiometa-js-toolkit/references/api/services/useWindowSize.md +25 -0
- package/skills/studiometa-js-toolkit/references/api/storage/createStorage.md +126 -0
- package/skills/studiometa-js-toolkit/references/api/storage/index.md +33 -0
- package/skills/studiometa-js-toolkit/references/api/storage/presets.md +58 -0
- package/skills/studiometa-js-toolkit/references/api/storage/providers.md +109 -0
- package/skills/studiometa-js-toolkit/references/api/test/index.md +214 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/attribute-grammar.md +93 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/mutation-engine.md +71 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/philosophy.md +78 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/the-registry.md +110 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/autoloading.md +104 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/handling-diagnostics.md +104 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/mount-strategies.md +95 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/scheduling-work.md +124 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/sharing-state.md +218 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/swapping-content.md +92 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/testing-components.md +137 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/typing-components.md +190 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/using-decorators.md +168 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/using-storage.md +125 -0
- package/skills/studiometa-js-toolkit/references/guide/index.md +163 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/installation.md +144 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/lifecycle-hooks.md +174 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/managing-components.md +229 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/managing-options.md +235 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/managing-refs.md +174 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/using-services.md +218 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/working-with-events.md +251 -0
- package/skills/studiometa-js-toolkit/references/guide/migration/v3-to-v4.md +373 -0
- package/skills/studiometa-js-toolkit/references/utils/css.md +98 -0
- package/skills/studiometa-js-toolkit/references/utils/dom.md +54 -0
- package/skills/studiometa-js-toolkit/references/utils/easings.md +217 -0
- package/skills/studiometa-js-toolkit/references/utils/focus.md +84 -0
- package/skills/studiometa-js-toolkit/references/utils/history.md +69 -0
- package/skills/studiometa-js-toolkit/references/utils/index.md +53 -0
- package/skills/studiometa-js-toolkit/references/utils/is.md +84 -0
- package/skills/studiometa-js-toolkit/references/utils/load.md +59 -0
- package/skills/studiometa-js-toolkit/references/utils/math.md +129 -0
- package/skills/studiometa-js-toolkit/references/utils/motion.md +218 -0
- package/skills/studiometa-js-toolkit/references/utils/objects.md +68 -0
- package/skills/studiometa-js-toolkit/references/utils/scroll.md +128 -0
- package/skills/studiometa-js-toolkit/references/utils/strings.md +176 -0
- package/skills/studiometa-js-toolkit/references/utils/timing.md +111 -0
- package/skills/studiometa-js-toolkit/references/utils/transitions.md +122 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# CSS
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import { matrix, transform } from '@studiometa/js-toolkit/utils';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## Transforms
|
|
8
|
+
|
|
9
|
+
### transform
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
transform(props: TransformProps): string
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { transform } from '@studiometa/js-toolkit/utils';
|
|
17
|
+
|
|
18
|
+
transform({ x: 10, y: 20, scale: 1.5, rotate: 45 });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Builds a `transform` value from named parts, so a component composes a transform instead of assembling a string. `TransformProps` takes `x`, `y`, `z`, `rotate`, `rotateX`, `rotateY`, `rotateZ`, `scale`, `scaleX`, `scaleY`, `scaleZ`, `skew` and the rest of the family.
|
|
22
|
+
|
|
23
|
+
**The order is fixed by `TRANSFORM_PROPS`, not by the object.** Transform functions do not commute, so two components building "the same" transform from differently-ordered literals must still get the same matrix.
|
|
24
|
+
|
|
25
|
+
### matrix
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
matrix(props?: MatrixProps): string
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import { matrix } from '@studiometa/js-toolkit/utils';
|
|
33
|
+
|
|
34
|
+
matrix({ scaleX: 2, translateX: 10 });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A `matrix()` string. Reach for it when a value has to be interpolated as a matrix rather than as separate functions.
|
|
38
|
+
|
|
39
|
+
### TRANSFORM_PROPS
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const TRANSFORM_PROPS: readonly (keyof TransformProps)[];
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The ordered list of keys `transform()` reads.
|
|
46
|
+
|
|
47
|
+
## Measuring
|
|
48
|
+
|
|
49
|
+
### getOffsetSizes
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
getOffsetSizes(element: HTMLElement): { x, y, width, height, top, right, bottom, left }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { getOffsetSizes } from '@studiometa/js-toolkit/utils';
|
|
57
|
+
|
|
58
|
+
const box = getOffsetSizes(document.body);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The element's box from its **offset** properties rather than from `getBoundingClientRect()` — so a transform the component itself applied does not move the measurement.
|
|
62
|
+
|
|
63
|
+
That is exactly what a drag or a tilt needs: the layout box is the frame of reference, and the transform is the output.
|
|
64
|
+
|
|
65
|
+
**It is a layout read**
|
|
66
|
+
|
|
67
|
+
Call it from the `read` phase — [`$read()`](../api/instance-methods.md#read-and-write) — so it batches with every other measurement of the frame.
|
|
68
|
+
|
|
69
|
+
## Applying
|
|
70
|
+
|
|
71
|
+
### setClassesOrStyles
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
setClassesOrStyles(
|
|
75
|
+
el: HTMLElement,
|
|
76
|
+
value: string | string[] | Partial<CSSStyleDeclaration> | undefined,
|
|
77
|
+
method?: 'add' | 'remove',
|
|
78
|
+
): void
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import { setClassesOrStyles } from '@studiometa/js-toolkit/utils';
|
|
83
|
+
|
|
84
|
+
const el = document.body;
|
|
85
|
+
|
|
86
|
+
setClassesOrStyles(el, 'is-active'); // a class
|
|
87
|
+
setClassesOrStyles(el, ['is-active', 'is-open']); // several
|
|
88
|
+
setClassesOrStyles(el, { opacity: '0' }); // inline styles
|
|
89
|
+
setClassesOrStyles(el, 'is-active', 'remove'); // undo it
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Applies a value that may be **either** classes or inline styles, which is what lets [`transition()`](transitions.md) take one option in both forms.
|
|
93
|
+
|
|
94
|
+
An `undefined` value does nothing, so a caller with an optional state does not have to branch.
|
|
95
|
+
|
|
96
|
+
## What is not here
|
|
97
|
+
|
|
98
|
+
`addClass`, `removeClass`, `toggleClass`, `addStyle`, `removeStyle` and `animate` are not shipped. `el.classList` and `el.style` say the first five, and time-based playback belongs to the separate `ui-animation` package.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# DOM
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import { createElement, selectorFor } from '@studiometa/js-toolkit/utils';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## createElement
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
createElement(tag?, children?): HTMLElement
|
|
11
|
+
createElement(tag?, attributes?, children?): HTMLElement
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import { createElement } from '@studiometa/js-toolkit/utils';
|
|
16
|
+
|
|
17
|
+
createElement('div');
|
|
18
|
+
createElement('p', 'Hello');
|
|
19
|
+
createElement('ul', [createElement('li', 'One'), createElement('li', 'Two')]);
|
|
20
|
+
createElement('button', { class: 'btn', data: { component: 'Action' } }, 'Send');
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Parameters**
|
|
24
|
+
|
|
25
|
+
- `tag` — defaults to `'div'`, and the return type follows it: `createElement('input')` gives an `HTMLInputElement`.
|
|
26
|
+
- `attributes` — plain attributes, plus a `data` object whose keys become `data-*`.
|
|
27
|
+
- `children` — a string, a `Node`, or an array of either.
|
|
28
|
+
|
|
29
|
+
The `data` key is why this exists rather than three lines of `document.createElement`: building an element that carries `data-component` and a few `data-option-*` is the common case, and spelling each `setAttribute()` out loses the shape.
|
|
30
|
+
|
|
31
|
+
## selectorFor
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
selectorFor(name: string): string
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { selectorFor } from '@studiometa/js-toolkit/utils';
|
|
39
|
+
|
|
40
|
+
selectorFor('Dialog');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The CSS selector that matches every element declaring a component name — **including the responsive `data-component:<breakpoint>` spellings**.
|
|
44
|
+
|
|
45
|
+
It is the **one place** that writes the name-to-selector contract, which is why it is public: a consumer that queries for components must match what the registry matches, and a hand-written `[data-component="X"]` misses the scoped declarations.
|
|
46
|
+
|
|
47
|
+
**It over-matches on purpose**
|
|
48
|
+
|
|
49
|
+
A responsive declaration that is not active still matches the selector. That is why the four [instance lookups](../api/registry/getInstances.md) read the element's instance map afterwards: **a matching element with no instance is skipped, and that is the whole narrowing.**
|
|
50
|
+
|
|
51
|
+
## See also
|
|
52
|
+
|
|
53
|
+
- [CSS](css.md) — `getOffsetSizes`, `transform`, `matrix`
|
|
54
|
+
- [`swap()`](../api/dom/swap.md) — replacing content, with the framework waiting
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Easings
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import { easeInOutCubic, easeOutQuad } from '@studiometa/js-toolkit/utils';
|
|
5
|
+
|
|
6
|
+
easeOutQuad(0.5); // 0.75
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
An `EasingFunction` takes a `0 → 1` progress and returns a shaped `0 → 1` value.
|
|
10
|
+
|
|
11
|
+
## Choosing one
|
|
12
|
+
|
|
13
|
+
Eight curves, three directions each. Every `out` and `in-out` is derived from its `in`.
|
|
14
|
+
|
|
15
|
+
| Curve | In | Out | In-out |
|
|
16
|
+
| ------ | ----------------------------- | ------------------------------- | ----------------------------------- |
|
|
17
|
+
| linear | [`easeLinear`](#easelinear) | — | — |
|
|
18
|
+
| quad | [`easeInQuad`](#easeinquad) | [`easeOutQuad`](#easeoutquad) | [`easeInOutQuad`](#easeinoutquad) |
|
|
19
|
+
| cubic | [`easeInCubic`](#easeincubic) | [`easeOutCubic`](#easeoutcubic) | [`easeInOutCubic`](#easeinoutcubic) |
|
|
20
|
+
| quart | [`easeInQuart`](#easeinquart) | [`easeOutQuart`](#easeoutquart) | [`easeInOutQuart`](#easeinoutquart) |
|
|
21
|
+
| quint | [`easeInQuint`](#easeinquint) | [`easeOutQuint`](#easeoutquint) | [`easeInOutQuint`](#easeinoutquint) |
|
|
22
|
+
| sine | [`easeInSine`](#easeinsine) | [`easeOutSine`](#easeoutsine) | [`easeInOutSine`](#easeinoutsine) |
|
|
23
|
+
| circ | [`easeInCirc`](#easeincirc) | [`easeOutCirc`](#easeoutcirc) | [`easeInOutCirc`](#easeinoutcirc) |
|
|
24
|
+
| expo | [`easeInExpo`](#easeinexpo) | [`easeOutExpo`](#easeoutexpo) | [`easeInOutExpo`](#easeinoutexpo) |
|
|
25
|
+
|
|
26
|
+
## Deriving one
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
createEaseOut(easeIn: EasingFunction): EasingFunction
|
|
30
|
+
createEaseInOut(easeIn: EasingFunction): EasingFunction
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Every `out` and `in-out` above is one of these applied to its `in`. Which means a custom curve gets its whole family for two lines:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { createEaseInOut, createEaseOut, type EasingFunction } from '@studiometa/js-toolkit/utils';
|
|
37
|
+
|
|
38
|
+
const easeInBack: EasingFunction = (progress) => progress * progress * (2.7 * progress - 1.7);
|
|
39
|
+
|
|
40
|
+
const easeOutBack = createEaseOut(easeInBack);
|
|
41
|
+
const easeInOutBack = createEaseInOut(easeInBack);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
That is why only the eight `in` functions are written out and the other sixteen are derived: an `out` is an `in` run backwards, and writing it twice is how the two drift apart.
|
|
45
|
+
|
|
46
|
+
### createEaseOut
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
createEaseOut(easeIn: EasingFunction): EasingFunction
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Mirror an `in` curve into its `out`.
|
|
53
|
+
|
|
54
|
+
### createEaseInOut
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
createEaseInOut(easeIn: EasingFunction): EasingFunction
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Compose an `in` curve into its symmetric `in-out`.
|
|
61
|
+
|
|
62
|
+
## Using one
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import { easeOutCubic, lerp } from '@studiometa/js-toolkit/utils';
|
|
66
|
+
|
|
67
|
+
function positionAt(progress) {
|
|
68
|
+
return lerp(0, 400, easeOutCubic(progress));
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
An easing shapes a **progress**, so it pairs with a value that already runs `0 → 1`: a [`useScrollProgress()`](../api/services/useScrollProgress.md) subscriber, or a `map()` of anything else.
|
|
73
|
+
|
|
74
|
+
## They do not animate
|
|
75
|
+
|
|
76
|
+
There is no clock here — an easing is a pure function of a progress you already have.
|
|
77
|
+
|
|
78
|
+
- For a value chasing a target frame by frame, use [`damp()` or `smoothTo()`](motion.md).
|
|
79
|
+
- For time-based playback, stagger and sequencing, that is the separate `ui-animation` package. `tween` and `animate` are not shipped.
|
|
80
|
+
|
|
81
|
+
## The functions
|
|
82
|
+
|
|
83
|
+
Each takes a `0 → 1` progress and returns the shaped value.
|
|
84
|
+
|
|
85
|
+
### easeLinear
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
easeLinear(progress: number): number
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The identity. It exists so a call site can name "no easing" rather than branch on `undefined`.
|
|
92
|
+
|
|
93
|
+
### easeInQuad
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
easeInQuad(progress: number): number
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### easeOutQuad
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
easeOutQuad(progress: number): number
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### easeInOutQuad
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
easeInOutQuad(progress: number): number
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### easeInCubic
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
easeInCubic(progress: number): number
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### easeOutCubic
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
easeOutCubic(progress: number): number
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### easeInOutCubic
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
easeInOutCubic(progress: number): number
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### easeInQuart
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
easeInQuart(progress: number): number
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### easeOutQuart
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
easeOutQuart(progress: number): number
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### easeInOutQuart
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
easeInOutQuart(progress: number): number
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### easeInQuint
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
easeInQuint(progress: number): number
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### easeOutQuint
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
easeOutQuint(progress: number): number
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### easeInOutQuint
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
easeInOutQuint(progress: number): number
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### easeInSine
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
easeInSine(progress: number): number
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### easeOutSine
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
easeOutSine(progress: number): number
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### easeInOutSine
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
easeInOutSine(progress: number): number
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### easeInCirc
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
easeInCirc(progress: number): number
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### easeOutCirc
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
easeOutCirc(progress: number): number
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### easeInOutCirc
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
easeInOutCirc(progress: number): number
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### easeInExpo
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
easeInExpo(progress: number): number
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### easeOutExpo
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
easeOutExpo(progress: number): number
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### easeInOutExpo
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
easeInOutExpo(progress: number): number
|
|
217
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Focus
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import { saveActiveElement, trapFocus, untrapFocus } from '@studiometa/js-toolkit/utils';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The three calls a modal surface needs.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
`trapFocus()` takes **the keyboard event**, so it is called from a key handler rather than installing a listener of its own:
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
15
|
+
import { saveActiveElement, trapFocus, untrapFocus } from '@studiometa/js-toolkit/utils';
|
|
16
|
+
|
|
17
|
+
class Dialog extends Base {
|
|
18
|
+
static config = { name: 'Dialog' };
|
|
19
|
+
|
|
20
|
+
open() {
|
|
21
|
+
saveActiveElement();
|
|
22
|
+
this.$el.removeAttribute('hidden');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
close() {
|
|
26
|
+
this.$el.setAttribute('hidden', '');
|
|
27
|
+
untrapFocus();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onKeydown(event) {
|
|
31
|
+
trapFocus(this.$el, event);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
With [`useKey()`](../api/services/useKey.md) the event is in the props:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
mounted() {
|
|
40
|
+
return useKey(this.$el).subscribe(({ event, TAB, isDown }) => {
|
|
41
|
+
if (TAB && isDown && event) trapFocus(this.$el, event);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**This is why the key listeners are not passive**
|
|
47
|
+
|
|
48
|
+
`trapFocus()` calls `preventDefault()` on the event it is handed, and a passive listener cannot. See [`useKey()`](../api/services/useKey.md#the-listeners-are-neither-passive-nor-capturing).
|
|
49
|
+
|
|
50
|
+
## The three
|
|
51
|
+
|
|
52
|
+
### saveActiveElement
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
saveActiveElement(): void
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Remembers what had focus, so `untrapFocus()` can give it back.
|
|
59
|
+
|
|
60
|
+
### trapFocus
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
trapFocus(el: HTMLElement, event: KeyboardEvent): void
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Keeps `Tab` and `Shift+Tab` inside `el`.
|
|
67
|
+
|
|
68
|
+
### untrapFocus
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
untrapFocus(): void
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Releases the trap and restores focus to the saved element.
|
|
75
|
+
|
|
76
|
+
## The saved element is shared across copies
|
|
77
|
+
|
|
78
|
+
Through the shared runtime, for the same reason the scroll lock counts: **there is one focus per document**. Two independently evaluated copies of the package must not each think they own it.
|
|
79
|
+
|
|
80
|
+
## `<dialog>` already does some of this
|
|
81
|
+
|
|
82
|
+
`showModal()` gives the top layer, the backdrop, a focus trap and `Escape`. What it does **not** do is stop the page behind it from scrolling — see [`lockScroll()`](scroll.md#lockscroll).
|
|
83
|
+
|
|
84
|
+
Reach for these three when the surface is not a native `<dialog>`.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# History
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import { historyPush, historyReplace, objectToURLSearchParams } from '@studiometa/js-toolkit/utils';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## Writing the URL
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { historyPush, historyReplace } from '@studiometa/js-toolkit/utils';
|
|
11
|
+
|
|
12
|
+
historyPush({ path: '/products', search: { page: 2, sort: 'price' } });
|
|
13
|
+
historyReplace({ search: { page: 3 } });
|
|
14
|
+
historyPush({ hash: 'section-2' });
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
interface HistoryOptions {
|
|
19
|
+
path?: string;
|
|
20
|
+
search?: URLSearchParams | Record<string, SearchParamInput>;
|
|
21
|
+
hash?: string;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Each part is optional, and an omitted part is kept.** `historyReplace({ search })` keeps the path and the hash; `historyPush({ hash })` keeps the path and the query string.
|
|
26
|
+
|
|
27
|
+
That is the whole reason these exist over `history.pushState()`: rebuilding a URL from `location` by hand is where a filter update loses the hash, or a hash update drops the query string.
|
|
28
|
+
|
|
29
|
+
### historyPush
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
historyPush(options: HistoryOptions, data?: unknown, title?: string): void
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Adds a history entry. This is what makes a state navigable with the back button.
|
|
36
|
+
|
|
37
|
+
### historyReplace
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
historyReplace(options: HistoryOptions, data?: unknown, title?: string): void
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Replaces the current entry. This is what keeps a scroll position or a tab index out of the history.
|
|
44
|
+
|
|
45
|
+
## Building the query string
|
|
46
|
+
|
|
47
|
+
### objectToURLSearchParams
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
objectToURLSearchParams(
|
|
51
|
+
object: Record<string, SearchParamInput>,
|
|
52
|
+
defaultSearch?: string,
|
|
53
|
+
): URLSearchParams
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { objectToURLSearchParams } from '@studiometa/js-toolkit/utils';
|
|
58
|
+
|
|
59
|
+
objectToURLSearchParams({ page: 2, tags: ['a', 'b'], open: true });
|
|
60
|
+
objectToURLSearchParams({ page: 2 }, location.search);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`SearchParamInput` accepts a string, a number, a boolean, `null`, `undefined`, an array of those, or a nested object of those — so a filter state serializes without being flattened first.
|
|
64
|
+
|
|
65
|
+
`defaultSearch` is the starting point, so the result **merges into** an existing query string instead of replacing it.
|
|
66
|
+
|
|
67
|
+
## See also
|
|
68
|
+
|
|
69
|
+
For a URL that is also a store you can read, write and observe, use [`createUrlSearchParamsStorage()`](../api/storage/presets.md) — it is these functions behind a typed key-value surface, with `popstate` wired up.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Utils
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import { clamp, damp } from '@studiometa/js-toolkit/utils';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Every one of them also has a subpath of its own:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { clamp } from '@studiometa/js-toolkit/utils/clamp';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
With a bundler, prefer the barrel — tree-shaking removes what you do not import. From an ESM CDN with no build step, prefer the subpath: there is no bundler to shake the graph.
|
|
14
|
+
|
|
15
|
+
## The categories
|
|
16
|
+
|
|
17
|
+
| Category | Contents |
|
|
18
|
+
| ---------------------------------- | ---------------------------------------------------------------------- |
|
|
19
|
+
| [Type guards](is.md) | `isString`, `isNumber`, `isObject`, `isDefined`, … |
|
|
20
|
+
| [Strings](strings.md) | case conversion, leading and trailing characters |
|
|
21
|
+
| [Math](math.md) | `clamp`, `lerp`, `map`, `wrap`, `fold`, `round`, `mean`, `createRange` |
|
|
22
|
+
| [Easings](easings.md) | the 24 easing functions, `createEaseOut`, `createEaseInOut` |
|
|
23
|
+
| [Motion](motion.md) | `damp`, `spring`, `smoothTo`, the inertia family |
|
|
24
|
+
| [CSS](css.md) | `transform`, `matrix`, `getOffsetSizes`, `setClassesOrStyles` |
|
|
25
|
+
| [Transitions](transitions.md) | `transition`, `enterTransition`, `leaveTransition` |
|
|
26
|
+
| [DOM](dom.md) | `createElement`, `selectorFor` |
|
|
27
|
+
| [Focus](focus.md) | `trapFocus`, `untrapFocus`, `saveActiveElement` |
|
|
28
|
+
| [Scroll](scroll.md) | `scrollTo`, `scrollPosition`, `lockScroll` |
|
|
29
|
+
| [History](history.md) | `historyPush`, `historyReplace`, `objectToURLSearchParams` |
|
|
30
|
+
| [Loading](load.md) | `loadImage`, `loadScript`, `loadLink` |
|
|
31
|
+
| [Timing](timing.md) | `debounce`, `throttle`, `wait`, `memo`, `noop` |
|
|
32
|
+
| [Objects & random](objects.md) | `deepmerge`, `random`, `randomInt`, `randomItem` |
|
|
33
|
+
|
|
34
|
+
## What v3 shipped and v4 does not
|
|
35
|
+
|
|
36
|
+
| Removed | Because |
|
|
37
|
+
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
38
|
+
| `tween`, `animate` | time-based playback moves to a separate `ui-animation` package |
|
|
39
|
+
| `domScheduler`, `useScheduler` | [one scheduler](../api/scheduler/index.md) is the clock |
|
|
40
|
+
| `Queue`, `SmartQueue` | the scheduler's lanes replace them |
|
|
41
|
+
| the collision helpers | not ported |
|
|
42
|
+
| `keyCodes` | [`useKey()`](../api/services/useKey.md) delivers named booleans, so nothing is left to compare against |
|
|
43
|
+
| `nextTick`, `nextMicrotask` | `await Promise.resolve()` and `queueMicrotask()` say it |
|
|
44
|
+
| `isEmpty`, `isEmptyString`, `isArray`, `isDev` | the platform or a one-liner says it |
|
|
45
|
+
| `cache`, `memoize` | [`memo`](timing.md#memo) covers the one case core needed |
|
|
46
|
+
| `addClass`, `removeClass`, `toggleClass`, `addStyle`, `removeStyle` | `classList` and `style` say it |
|
|
47
|
+
| `loadIframe`, `loadElement` | not ported |
|
|
48
|
+
|
|
49
|
+
## How a utility earns its place
|
|
50
|
+
|
|
51
|
+
**It is judged by consumer need, not by core's own use.** Some of these are not called anywhere in core — they ship because a component author would otherwise write them again, and getting them wrong is easy. `deepmerge` is the clearest case.
|
|
52
|
+
|
|
53
|
+
The reverse also holds: a function core happens to use internally is not public for that reason alone.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Type guards
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import { isDefined, isNumber, isObject, isString } from '@studiometa/js-toolkit/utils';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Each one narrows the type.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { isDefined, isObject, isString } from '@studiometa/js-toolkit/utils';
|
|
13
|
+
|
|
14
|
+
function label(value: unknown): string {
|
|
15
|
+
if (isString(value)) return value; // string
|
|
16
|
+
if (isObject(value)) return JSON.stringify(value); // Record<string, unknown>
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function first<T>(items: (T | undefined)[]): T[] {
|
|
21
|
+
return items.filter(isDefined); // T[]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`isDefined` as a `filter` predicate is the case that earns the export: it is the one narrowing TypeScript will not do from a truthiness check.
|
|
26
|
+
|
|
27
|
+
## The guards
|
|
28
|
+
|
|
29
|
+
### isNull
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
isNull(value: unknown): value is null
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### isDefined
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
isDefined<T>(value: T | undefined): value is T
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Narrows `T | undefined` to `T`. Passing it by reference to `filter` is what it is for.
|
|
42
|
+
|
|
43
|
+
### isString
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
isString(value: unknown): value is string
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### isNumber
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
isNumber(value: unknown): value is number
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**It rejects `NaN`**, because a `NaN` that passes a number check is a bug that surfaces three functions later.
|
|
56
|
+
|
|
57
|
+
### isBoolean
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
isBoolean(value: unknown): value is boolean
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### isFunction
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
isFunction(value: unknown): value is (...args: unknown[]) => unknown
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### isObject
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
isObject(value: unknown): value is Record<string, unknown>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## What is not here
|
|
76
|
+
|
|
77
|
+
| Not shipped | Write |
|
|
78
|
+
| --------------- | ----------------------------------- |
|
|
79
|
+
| `isArray` | `Array.isArray(value)` |
|
|
80
|
+
| `isEmpty` | the check the caller actually means |
|
|
81
|
+
| `isEmptyString` | `value === ''` |
|
|
82
|
+
| `isDev` | your bundler's own flag |
|
|
83
|
+
|
|
84
|
+
A guard earns its place by narrowing something the platform does not, or by being a predicate you pass by reference.
|