@teamturing/react-kit 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Button/index.d.ts +1 -1
- package/dist/core/Dialog/index.d.ts +16 -0
- package/dist/core/DialogHandler/index.d.ts +13 -0
- package/dist/core/GradientText/index.d.ts +11 -12
- package/dist/core/Grid/index.d.ts +2 -2
- package/dist/core/IconButton/index.d.ts +1 -1
- package/dist/core/ItemList/index.d.ts +2 -2
- package/dist/core/MotionView/index.d.ts +3 -0
- package/dist/core/Spinner/index.d.ts +116 -116
- package/dist/core/Stack/index.d.ts +2 -2
- package/dist/core/TextInput/index.d.ts +39 -0
- package/dist/core/Textarea/index.d.ts +9 -0
- package/dist/hook/useDialogHandler.d.ts +6 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10732 -593
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/isFunction.d.ts +1 -0
- package/esm/_virtual/index.js +3 -0
- package/esm/_virtual/react-is.development.js +3 -0
- package/esm/_virtual/react-is.production.min.js +3 -0
- package/esm/core/Dialog/index.js +188 -0
- package/esm/core/DialogHandler/index.js +33 -0
- package/esm/core/MotionView/index.js +6 -0
- package/esm/core/TextInput/index.js +220 -0
- package/esm/core/Textarea/index.js +158 -0
- package/esm/hook/useDialogHandler.js +14 -0
- package/esm/index.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/animation/animators/instant.js +40 -0
- package/esm/node_modules/framer-motion/dist/es/animation/animators/js/driver-frameloop.js +16 -0
- package/esm/node_modules/framer-motion/dist/es/animation/animators/js/index.js +303 -0
- package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/create-accelerated-animation.js +199 -0
- package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/easing.js +31 -0
- package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/index.js +23 -0
- package/esm/node_modules/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/animation/generators/inertia.js +87 -0
- package/esm/node_modules/framer-motion/dist/es/animation/generators/keyframes.js +51 -0
- package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/find.js +89 -0
- package/esm/node_modules/framer-motion/dist/es/animation/generators/spring/index.js +129 -0
- package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/calc-duration.js +17 -0
- package/esm/node_modules/framer-motion/dist/es/animation/generators/utils/velocity.js +9 -0
- package/esm/node_modules/framer-motion/dist/es/animation/interfaces/motion-value.js +101 -0
- package/esm/node_modules/framer-motion/dist/es/animation/interfaces/single-value.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-target.js +71 -0
- package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element-variant.js +63 -0
- package/esm/node_modules/framer-motion/dist/es/animation/interfaces/visual-element.js +24 -0
- package/esm/node_modules/framer-motion/dist/es/animation/optimized-appear/data-id.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/animation/utils/default-transitions.js +40 -0
- package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animatable.js +30 -0
- package/esm/node_modules/framer-motion/dist/es/animation/utils/is-animation-controls.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/animation/utils/is-keyframes-target.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/animation/utils/is-none.js +12 -0
- package/esm/node_modules/framer-motion/dist/es/animation/utils/keyframes.js +45 -0
- package/esm/node_modules/framer-motion/dist/es/animation/utils/transitions.js +13 -0
- package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.js +71 -0
- package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.js +56 -0
- package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/index.js +158 -0
- package/esm/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.js +40 -0
- package/esm/node_modules/framer-motion/dist/es/context/LayoutGroupContext.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/context/LazyContext.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/context/MotionConfigContext.js +12 -0
- package/esm/node_modules/framer-motion/dist/es/context/MotionContext/create.js +13 -0
- package/esm/node_modules/framer-motion/dist/es/context/MotionContext/index.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/context/MotionContext/utils.js +17 -0
- package/esm/node_modules/framer-motion/dist/es/context/PresenceContext.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/context/SwitchLayoutGroupContext.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/debug/record.js +7 -0
- package/esm/node_modules/framer-motion/dist/es/easing/anticipate.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/easing/back.js +9 -0
- package/esm/node_modules/framer-motion/dist/es/easing/circ.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/easing/cubic-bezier.js +51 -0
- package/esm/node_modules/framer-motion/dist/es/easing/ease.js +7 -0
- package/esm/node_modules/framer-motion/dist/es/easing/modifiers/mirror.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/easing/modifiers/reverse.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/easing/utils/is-bezier-definition.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/easing/utils/is-easing-array.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/easing/utils/map.js +37 -0
- package/esm/node_modules/framer-motion/dist/es/events/add-dom-event.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/events/add-pointer-event.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/events/event-info.js +15 -0
- package/esm/node_modules/framer-motion/dist/es/events/utils/is-primary-pointer.js +18 -0
- package/esm/node_modules/framer-motion/dist/es/frameloop/batcher.js +60 -0
- package/esm/node_modules/framer-motion/dist/es/frameloop/frame.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/frameloop/render-step.js +104 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/drag/VisualElementDragControls.js +457 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/drag/index.js +27 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/constraints.js +125 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/drag/utils/lock.js +53 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/focus.js +41 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/hover.js +32 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/pan/PanSession.js +148 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/pan/index.js +46 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/press.js +120 -0
- package/esm/node_modules/framer-motion/dist/es/gestures/utils/is-node-or-child.js +20 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/Feature.js +9 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/animation/exit.js +31 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/animation/index.js +38 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/animations.js +13 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/definitions.js +28 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/drag.js +17 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/gestures.js +21 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.js +131 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/layout.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/load-features.js +12 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/index.js +72 -0
- package/esm/node_modules/framer-motion/dist/es/motion/features/viewport/observers.js +49 -0
- package/esm/node_modules/framer-motion/dist/es/motion/index.js +79 -0
- package/esm/node_modules/framer-motion/dist/es/motion/utils/is-forced-motion-value.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/motion/utils/symbol.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.js +33 -0
- package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-element.js +75 -0
- package/esm/node_modules/framer-motion/dist/es/motion/utils/use-visual-state.js +81 -0
- package/esm/node_modules/framer-motion/dist/es/motion/utils/valid-prop.js +59 -0
- package/esm/node_modules/framer-motion/dist/es/projection/animation/mix-values.js +93 -0
- package/esm/node_modules/framer-motion/dist/es/projection/geometry/conversion.js +33 -0
- package/esm/node_modules/framer-motion/dist/es/projection/geometry/copy.js +20 -0
- package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-apply.js +122 -0
- package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-calc.js +41 -0
- package/esm/node_modules/framer-motion/dist/es/projection/geometry/delta-remove.js +54 -0
- package/esm/node_modules/framer-motion/dist/es/projection/geometry/models.js +17 -0
- package/esm/node_modules/framer-motion/dist/es/projection/geometry/utils.js +25 -0
- package/esm/node_modules/framer-motion/dist/es/projection/node/DocumentProjectionNode.js +13 -0
- package/esm/node_modules/framer-motion/dist/es/projection/node/HTMLProjectionNode.js +27 -0
- package/esm/node_modules/framer-motion/dist/es/projection/node/create-projection-node.js +1494 -0
- package/esm/node_modules/framer-motion/dist/es/projection/node/state.js +19 -0
- package/esm/node_modules/framer-motion/dist/es/projection/shared/stack.js +112 -0
- package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-border-radius.js +41 -0
- package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-box-shadow.js +35 -0
- package/esm/node_modules/framer-motion/dist/es/projection/styles/scale-correction.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/projection/styles/transform.js +42 -0
- package/esm/node_modules/framer-motion/dist/es/projection/utils/each-axis.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/projection/utils/has-transform.js +24 -0
- package/esm/node_modules/framer-motion/dist/es/projection/utils/measure.js +17 -0
- package/esm/node_modules/framer-motion/dist/es/render/VisualElement.js +507 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/DOMVisualElement.js +48 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/create-visual-element.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/motion-proxy.js +47 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/motion.js +23 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/use-render.js +35 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/camel-to-dash.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/create-config.js +19 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/css-variables-conversion.js +89 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/filter-props.js +57 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-css-variable.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-component.js +30 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/is-svg-element.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/parse-dom-variant.js +15 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/utils/unit-conversion.js +230 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/animatable-none.js +15 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/defaults.js +30 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/dimensions.js +15 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/find.js +15 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/get-as-type.js +10 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/number.js +72 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/test.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-auto.js +9 -0
- package/esm/node_modules/framer-motion/dist/es/render/dom/value-types/type-int.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/HTMLVisualElement.js +55 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/config-motion.js +12 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/use-props.js +57 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-styles.js +74 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/utils/build-transform.js +45 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/utils/create-render-state.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/utils/render.js +9 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/utils/scrape-motion-values.js +17 -0
- package/esm/node_modules/framer-motion/dist/es/render/html/utils/transform.js +28 -0
- package/esm/node_modules/framer-motion/dist/es/render/store.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/SVGVisualElement.js +46 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/config-motion.js +40 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/lowercase-elements.js +33 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/use-props.js +24 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/build-attrs.js +52 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/camel-case-attrs.js +30 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/create-render-state.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/is-svg-tag.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/path.js +32 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/render.js +12 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/scrape-motion-values.js +18 -0
- package/esm/node_modules/framer-motion/dist/es/render/svg/utils/transform-origin.js +18 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/animation-state.js +319 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/compare-by-depth.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/flat-tree.js +24 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/is-controlling-variants.js +13 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/is-variant-label.js +8 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/motion-values.js +63 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-dynamic-variants.js +24 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/resolve-variants.js +26 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/setters.js +101 -0
- package/esm/node_modules/framer-motion/dist/es/render/utils/variant-props.js +12 -0
- package/esm/node_modules/framer-motion/dist/es/utils/array.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/utils/clamp.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/utils/delay.js +19 -0
- package/esm/node_modules/framer-motion/dist/es/utils/distance.js +9 -0
- package/esm/node_modules/framer-motion/dist/es/utils/errors.js +18 -0
- package/esm/node_modules/framer-motion/dist/es/utils/hsla-to-rgba.js +42 -0
- package/esm/node_modules/framer-motion/dist/es/utils/interpolate.js +92 -0
- package/esm/node_modules/framer-motion/dist/es/utils/is-browser.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/utils/is-numerical-string.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/utils/is-ref-object.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/utils/is-zero-value-string.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/utils/memo.js +10 -0
- package/esm/node_modules/framer-motion/dist/es/utils/mix-color.js +40 -0
- package/esm/node_modules/framer-motion/dist/es/utils/mix-complex.js +64 -0
- package/esm/node_modules/framer-motion/dist/es/utils/mix.js +24 -0
- package/esm/node_modules/framer-motion/dist/es/utils/noop.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/utils/offsets/default.js +9 -0
- package/esm/node_modules/framer-motion/dist/es/utils/offsets/fill.js +12 -0
- package/esm/node_modules/framer-motion/dist/es/utils/offsets/time.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/utils/pipe.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/utils/progress.js +18 -0
- package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/index.js +19 -0
- package/esm/node_modules/framer-motion/dist/es/utils/reduced-motion/state.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/utils/resolve-value.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/utils/shallow-compare.js +14 -0
- package/esm/node_modules/framer-motion/dist/es/utils/subscription-manager.js +40 -0
- package/esm/node_modules/framer-motion/dist/es/utils/time-conversion.js +10 -0
- package/esm/node_modules/framer-motion/dist/es/utils/use-constant.js +18 -0
- package/esm/node_modules/framer-motion/dist/es/utils/use-force-update.js +19 -0
- package/esm/node_modules/framer-motion/dist/es/utils/use-instant-transition-state.js +5 -0
- package/esm/node_modules/framer-motion/dist/es/utils/use-is-mounted.js +15 -0
- package/esm/node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.js +6 -0
- package/esm/node_modules/framer-motion/dist/es/utils/use-unmount-effect.js +7 -0
- package/esm/node_modules/framer-motion/dist/es/utils/velocity-per-second.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/utils/warn-once.js +11 -0
- package/esm/node_modules/framer-motion/dist/es/value/index.js +331 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/color/hex.js +40 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/color/hsla.js +22 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/color/index.js +28 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/color/rgba.js +25 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/color/utils.js +23 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/complex/filter.js +30 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/complex/index.js +92 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/numbers/index.js +17 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/numbers/units.js +19 -0
- package/esm/node_modules/framer-motion/dist/es/value/types/utils.js +15 -0
- package/esm/node_modules/framer-motion/dist/es/value/use-will-change/is.js +7 -0
- package/esm/node_modules/framer-motion/dist/es/value/utils/is-motion-value.js +3 -0
- package/esm/node_modules/framer-motion/dist/es/value/utils/resolve-motion-value.js +16 -0
- package/esm/node_modules/react-is/cjs/react-is.development.js +211 -0
- package/esm/node_modules/react-is/cjs/react-is.production.min.js +123 -0
- package/esm/node_modules/react-is/index.js +12 -0
- package/esm/packages/icons/esm/Close.js +17 -0
- package/esm/packages/token-studio/esm/token/elevation/index.js +5 -1
- package/esm/utils/isFunction.js +3 -0
- package/package.json +5 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Adapted from https://gist.github.com/mjackson/5311256
|
|
2
|
+
function hueToRgb(p, q, t) {
|
|
3
|
+
if (t < 0)
|
|
4
|
+
t += 1;
|
|
5
|
+
if (t > 1)
|
|
6
|
+
t -= 1;
|
|
7
|
+
if (t < 1 / 6)
|
|
8
|
+
return p + (q - p) * 6 * t;
|
|
9
|
+
if (t < 1 / 2)
|
|
10
|
+
return q;
|
|
11
|
+
if (t < 2 / 3)
|
|
12
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
13
|
+
return p;
|
|
14
|
+
}
|
|
15
|
+
function hslaToRgba({ hue, saturation, lightness, alpha }) {
|
|
16
|
+
hue /= 360;
|
|
17
|
+
saturation /= 100;
|
|
18
|
+
lightness /= 100;
|
|
19
|
+
let red = 0;
|
|
20
|
+
let green = 0;
|
|
21
|
+
let blue = 0;
|
|
22
|
+
if (!saturation) {
|
|
23
|
+
red = green = blue = lightness;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const q = lightness < 0.5
|
|
27
|
+
? lightness * (1 + saturation)
|
|
28
|
+
: lightness + saturation - lightness * saturation;
|
|
29
|
+
const p = 2 * lightness - q;
|
|
30
|
+
red = hueToRgb(p, q, hue + 1 / 3);
|
|
31
|
+
green = hueToRgb(p, q, hue);
|
|
32
|
+
blue = hueToRgb(p, q, hue - 1 / 3);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
red: Math.round(red * 255),
|
|
36
|
+
green: Math.round(green * 255),
|
|
37
|
+
blue: Math.round(blue * 255),
|
|
38
|
+
alpha,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { hslaToRgba };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { invariant } from './errors.js';
|
|
2
|
+
import { color } from '../value/types/color/index.js';
|
|
3
|
+
import { clamp } from './clamp.js';
|
|
4
|
+
import { mix } from './mix.js';
|
|
5
|
+
import { mixColor } from './mix-color.js';
|
|
6
|
+
import { mixComplex, mixArray, mixObject } from './mix-complex.js';
|
|
7
|
+
import { pipe } from './pipe.js';
|
|
8
|
+
import { progress } from './progress.js';
|
|
9
|
+
import { noop } from './noop.js';
|
|
10
|
+
|
|
11
|
+
const mixNumber = (from, to) => (p) => mix(from, to, p);
|
|
12
|
+
function detectMixerFactory(v) {
|
|
13
|
+
if (typeof v === "number") {
|
|
14
|
+
return mixNumber;
|
|
15
|
+
}
|
|
16
|
+
else if (typeof v === "string") {
|
|
17
|
+
return color.test(v) ? mixColor : mixComplex;
|
|
18
|
+
}
|
|
19
|
+
else if (Array.isArray(v)) {
|
|
20
|
+
return mixArray;
|
|
21
|
+
}
|
|
22
|
+
else if (typeof v === "object") {
|
|
23
|
+
return mixObject;
|
|
24
|
+
}
|
|
25
|
+
return mixNumber;
|
|
26
|
+
}
|
|
27
|
+
function createMixers(output, ease, customMixer) {
|
|
28
|
+
const mixers = [];
|
|
29
|
+
const mixerFactory = customMixer || detectMixerFactory(output[0]);
|
|
30
|
+
const numMixers = output.length - 1;
|
|
31
|
+
for (let i = 0; i < numMixers; i++) {
|
|
32
|
+
let mixer = mixerFactory(output[i], output[i + 1]);
|
|
33
|
+
if (ease) {
|
|
34
|
+
const easingFunction = Array.isArray(ease) ? ease[i] || noop : ease;
|
|
35
|
+
mixer = pipe(easingFunction, mixer);
|
|
36
|
+
}
|
|
37
|
+
mixers.push(mixer);
|
|
38
|
+
}
|
|
39
|
+
return mixers;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a function that maps from a numerical input array to a generic output array.
|
|
43
|
+
*
|
|
44
|
+
* Accepts:
|
|
45
|
+
* - Numbers
|
|
46
|
+
* - Colors (hex, hsl, hsla, rgb, rgba)
|
|
47
|
+
* - Complex (combinations of one or more numbers or strings)
|
|
48
|
+
*
|
|
49
|
+
* ```jsx
|
|
50
|
+
* const mixColor = interpolate([0, 1], ['#fff', '#000'])
|
|
51
|
+
*
|
|
52
|
+
* mixColor(0.5) // 'rgba(128, 128, 128, 1)'
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* TODO Revist this approach once we've moved to data models for values,
|
|
56
|
+
* probably not needed to pregenerate mixer functions.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {}) {
|
|
61
|
+
const inputLength = input.length;
|
|
62
|
+
invariant(inputLength === output.length, "Both input and output ranges must be the same length");
|
|
63
|
+
/**
|
|
64
|
+
* If we're only provided a single input, we can just make a function
|
|
65
|
+
* that returns the output.
|
|
66
|
+
*/
|
|
67
|
+
if (inputLength === 1)
|
|
68
|
+
return () => output[0];
|
|
69
|
+
// If input runs highest -> lowest, reverse both arrays
|
|
70
|
+
if (input[0] > input[inputLength - 1]) {
|
|
71
|
+
input = [...input].reverse();
|
|
72
|
+
output = [...output].reverse();
|
|
73
|
+
}
|
|
74
|
+
const mixers = createMixers(output, ease, mixer);
|
|
75
|
+
const numMixers = mixers.length;
|
|
76
|
+
const interpolator = (v) => {
|
|
77
|
+
let i = 0;
|
|
78
|
+
if (numMixers > 1) {
|
|
79
|
+
for (; i < input.length - 2; i++) {
|
|
80
|
+
if (v < input[i + 1])
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const progressInRange = progress(input[i], input[i + 1], v);
|
|
85
|
+
return mixers[i](progressInRange);
|
|
86
|
+
};
|
|
87
|
+
return isClamp
|
|
88
|
+
? (v) => interpolator(clamp(input[0], input[inputLength - 1], v))
|
|
89
|
+
: interpolator;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { interpolate };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mix } from './mix.js';
|
|
2
|
+
import { invariant } from './errors.js';
|
|
3
|
+
import { hslaToRgba } from './hsla-to-rgba.js';
|
|
4
|
+
import { hex } from '../value/types/color/hex.js';
|
|
5
|
+
import { rgba } from '../value/types/color/rgba.js';
|
|
6
|
+
import { hsla } from '../value/types/color/hsla.js';
|
|
7
|
+
|
|
8
|
+
// Linear color space blending
|
|
9
|
+
// Explained https://www.youtube.com/watch?v=LKnqECcg6Gw
|
|
10
|
+
// Demonstrated http://codepen.io/osublake/pen/xGVVaN
|
|
11
|
+
const mixLinearColor = (from, to, v) => {
|
|
12
|
+
const fromExpo = from * from;
|
|
13
|
+
return Math.sqrt(Math.max(0, v * (to * to - fromExpo) + fromExpo));
|
|
14
|
+
};
|
|
15
|
+
const colorTypes = [hex, rgba, hsla];
|
|
16
|
+
const getColorType = (v) => colorTypes.find((type) => type.test(v));
|
|
17
|
+
function asRGBA(color) {
|
|
18
|
+
const type = getColorType(color);
|
|
19
|
+
invariant(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
|
|
20
|
+
let model = type.parse(color);
|
|
21
|
+
if (type === hsla) {
|
|
22
|
+
// TODO Remove this cast - needed since Framer Motion's stricter typing
|
|
23
|
+
model = hslaToRgba(model);
|
|
24
|
+
}
|
|
25
|
+
return model;
|
|
26
|
+
}
|
|
27
|
+
const mixColor = (from, to) => {
|
|
28
|
+
const fromRGBA = asRGBA(from);
|
|
29
|
+
const toRGBA = asRGBA(to);
|
|
30
|
+
const blended = { ...fromRGBA };
|
|
31
|
+
return (v) => {
|
|
32
|
+
blended.red = mixLinearColor(fromRGBA.red, toRGBA.red, v);
|
|
33
|
+
blended.green = mixLinearColor(fromRGBA.green, toRGBA.green, v);
|
|
34
|
+
blended.blue = mixLinearColor(fromRGBA.blue, toRGBA.blue, v);
|
|
35
|
+
blended.alpha = mix(fromRGBA.alpha, toRGBA.alpha, v);
|
|
36
|
+
return rgba.transform(blended);
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { mixColor, mixLinearColor };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { mix } from './mix.js';
|
|
2
|
+
import { mixColor } from './mix-color.js';
|
|
3
|
+
import { pipe } from './pipe.js';
|
|
4
|
+
import { warning } from './errors.js';
|
|
5
|
+
import { color } from '../value/types/color/index.js';
|
|
6
|
+
import { complex, analyseComplexValue } from '../value/types/complex/index.js';
|
|
7
|
+
|
|
8
|
+
const mixImmediate = (origin, target) => (p) => `${p > 0 ? target : origin}`;
|
|
9
|
+
function getMixer(origin, target) {
|
|
10
|
+
if (typeof origin === "number") {
|
|
11
|
+
return (v) => mix(origin, target, v);
|
|
12
|
+
}
|
|
13
|
+
else if (color.test(origin)) {
|
|
14
|
+
return mixColor(origin, target);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return origin.startsWith("var(")
|
|
18
|
+
? mixImmediate(origin, target)
|
|
19
|
+
: mixComplex(origin, target);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const mixArray = (from, to) => {
|
|
23
|
+
const output = [...from];
|
|
24
|
+
const numValues = output.length;
|
|
25
|
+
const blendValue = from.map((fromThis, i) => getMixer(fromThis, to[i]));
|
|
26
|
+
return (v) => {
|
|
27
|
+
for (let i = 0; i < numValues; i++) {
|
|
28
|
+
output[i] = blendValue[i](v);
|
|
29
|
+
}
|
|
30
|
+
return output;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const mixObject = (origin, target) => {
|
|
34
|
+
const output = { ...origin, ...target };
|
|
35
|
+
const blendValue = {};
|
|
36
|
+
for (const key in output) {
|
|
37
|
+
if (origin[key] !== undefined && target[key] !== undefined) {
|
|
38
|
+
blendValue[key] = getMixer(origin[key], target[key]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return (v) => {
|
|
42
|
+
for (const key in blendValue) {
|
|
43
|
+
output[key] = blendValue[key](v);
|
|
44
|
+
}
|
|
45
|
+
return output;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const mixComplex = (origin, target) => {
|
|
49
|
+
const template = complex.createTransformer(target);
|
|
50
|
+
const originStats = analyseComplexValue(origin);
|
|
51
|
+
const targetStats = analyseComplexValue(target);
|
|
52
|
+
const canInterpolate = originStats.numVars === targetStats.numVars &&
|
|
53
|
+
originStats.numColors === targetStats.numColors &&
|
|
54
|
+
originStats.numNumbers >= targetStats.numNumbers;
|
|
55
|
+
if (canInterpolate) {
|
|
56
|
+
return pipe(mixArray(originStats.values, targetStats.values), template);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
|
|
60
|
+
return mixImmediate(origin, target);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { mixArray, mixComplex, mixObject };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Value in range from progress
|
|
3
|
+
|
|
4
|
+
Given a lower limit and an upper limit, we return the value within
|
|
5
|
+
that range as expressed by progress (usually a number from 0 to 1)
|
|
6
|
+
|
|
7
|
+
So progress = 0.5 would change
|
|
8
|
+
|
|
9
|
+
from -------- to
|
|
10
|
+
|
|
11
|
+
to
|
|
12
|
+
|
|
13
|
+
from ---- to
|
|
14
|
+
|
|
15
|
+
E.g. from = 10, to = 20, progress = 0.5 => 15
|
|
16
|
+
|
|
17
|
+
@param [number]: Lower limit of range
|
|
18
|
+
@param [number]: Upper limit of range
|
|
19
|
+
@param [number]: The progress between lower and upper limits expressed 0-1
|
|
20
|
+
@return [number]: Value as calculated from progress within range (not limited within range)
|
|
21
|
+
*/
|
|
22
|
+
const mix = (from, to, progress) => -progress * from + progress * to + from;
|
|
23
|
+
|
|
24
|
+
export { mix };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mix } from '../mix.js';
|
|
2
|
+
import { progress } from '../progress.js';
|
|
3
|
+
|
|
4
|
+
function fillOffset(offset, remaining) {
|
|
5
|
+
const min = offset[offset.length - 1];
|
|
6
|
+
for (let i = 1; i <= remaining; i++) {
|
|
7
|
+
const offsetProgress = progress(0, remaining, i);
|
|
8
|
+
offset.push(mix(min, 1, offsetProgress));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { fillOffset };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipe
|
|
3
|
+
* Compose other transformers to run linearily
|
|
4
|
+
* pipe(min(20), max(40))
|
|
5
|
+
* @param {...functions} transformers
|
|
6
|
+
* @return {function}
|
|
7
|
+
*/
|
|
8
|
+
const combineFunctions = (a, b) => (v) => b(a(v));
|
|
9
|
+
const pipe = (...transformers) => transformers.reduce(combineFunctions);
|
|
10
|
+
|
|
11
|
+
export { pipe };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Progress within given range
|
|
3
|
+
|
|
4
|
+
Given a lower limit and an upper limit, we return the progress
|
|
5
|
+
(expressed as a number 0-1) represented by the given value, and
|
|
6
|
+
limit that progress to within 0-1.
|
|
7
|
+
|
|
8
|
+
@param [number]: Lower limit
|
|
9
|
+
@param [number]: Upper limit
|
|
10
|
+
@param [number]: Value to find progress within given range
|
|
11
|
+
@return [number]: Progress of value within range as expressed 0-1
|
|
12
|
+
*/
|
|
13
|
+
const progress = (from, to, value) => {
|
|
14
|
+
const toFromDifference = to - from;
|
|
15
|
+
return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { progress };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isBrowser } from '../is-browser.js';
|
|
2
|
+
import { hasReducedMotionListener, prefersReducedMotion } from './state.js';
|
|
3
|
+
|
|
4
|
+
function initPrefersReducedMotion() {
|
|
5
|
+
hasReducedMotionListener.current = true;
|
|
6
|
+
if (!isBrowser)
|
|
7
|
+
return;
|
|
8
|
+
if (window.matchMedia) {
|
|
9
|
+
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
10
|
+
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
11
|
+
motionMediaQuery.addListener(setReducedMotionPreferences);
|
|
12
|
+
setReducedMotionPreferences();
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
prefersReducedMotion.current = false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { initPrefersReducedMotion };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isKeyframesTarget } from '../animation/utils/is-keyframes-target.js';
|
|
2
|
+
|
|
3
|
+
const isCustomValue = (v) => {
|
|
4
|
+
return Boolean(v && typeof v === "object" && v.mix && v.toValue);
|
|
5
|
+
};
|
|
6
|
+
const resolveFinalValueInKeyframes = (v) => {
|
|
7
|
+
// TODO maybe throw if v.length - 1 is placeholder token?
|
|
8
|
+
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { isCustomValue, resolveFinalValueInKeyframes };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function shallowCompare(next, prev) {
|
|
2
|
+
if (!Array.isArray(prev))
|
|
3
|
+
return false;
|
|
4
|
+
const prevLength = prev.length;
|
|
5
|
+
if (prevLength !== next.length)
|
|
6
|
+
return false;
|
|
7
|
+
for (let i = 0; i < prevLength; i++) {
|
|
8
|
+
if (prev[i] !== next[i])
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { shallowCompare };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { addUniqueItem, removeItem } from './array.js';
|
|
2
|
+
|
|
3
|
+
class SubscriptionManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.subscriptions = [];
|
|
6
|
+
}
|
|
7
|
+
add(handler) {
|
|
8
|
+
addUniqueItem(this.subscriptions, handler);
|
|
9
|
+
return () => removeItem(this.subscriptions, handler);
|
|
10
|
+
}
|
|
11
|
+
notify(a, b, c) {
|
|
12
|
+
const numSubscriptions = this.subscriptions.length;
|
|
13
|
+
if (!numSubscriptions)
|
|
14
|
+
return;
|
|
15
|
+
if (numSubscriptions === 1) {
|
|
16
|
+
/**
|
|
17
|
+
* If there's only a single handler we can just call it without invoking a loop.
|
|
18
|
+
*/
|
|
19
|
+
this.subscriptions[0](a, b, c);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
for (let i = 0; i < numSubscriptions; i++) {
|
|
23
|
+
/**
|
|
24
|
+
* Check whether the handler exists before firing as it's possible
|
|
25
|
+
* the subscriptions were modified during this loop running.
|
|
26
|
+
*/
|
|
27
|
+
const handler = this.subscriptions[i];
|
|
28
|
+
handler && handler(a, b, c);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
getSize() {
|
|
33
|
+
return this.subscriptions.length;
|
|
34
|
+
}
|
|
35
|
+
clear() {
|
|
36
|
+
this.subscriptions.length = 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { SubscriptionManager };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts seconds to milliseconds
|
|
3
|
+
*
|
|
4
|
+
* @param seconds - Time in seconds.
|
|
5
|
+
* @return milliseconds - Converted time in milliseconds.
|
|
6
|
+
*/
|
|
7
|
+
const secondsToMilliseconds = (seconds) => seconds * 1000;
|
|
8
|
+
const millisecondsToSeconds = (milliseconds) => milliseconds / 1000;
|
|
9
|
+
|
|
10
|
+
export { millisecondsToSeconds, secondsToMilliseconds };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a constant value over the lifecycle of a component.
|
|
5
|
+
*
|
|
6
|
+
* Even if `useMemo` is provided an empty array as its final argument, it doesn't offer
|
|
7
|
+
* a guarantee that it won't re-run for performance reasons later on. By using `useConstant`
|
|
8
|
+
* you can ensure that initialisers don't execute twice or more.
|
|
9
|
+
*/
|
|
10
|
+
function useConstant(init) {
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
if (ref.current === null) {
|
|
13
|
+
ref.current = init();
|
|
14
|
+
}
|
|
15
|
+
return ref.current;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { useConstant };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useIsMounted } from './use-is-mounted.js';
|
|
3
|
+
import { frame } from '../frameloop/frame.js';
|
|
4
|
+
|
|
5
|
+
function useForceUpdate() {
|
|
6
|
+
const isMounted = useIsMounted();
|
|
7
|
+
const [forcedRenderCount, setForcedRenderCount] = useState(0);
|
|
8
|
+
const forceRender = useCallback(() => {
|
|
9
|
+
isMounted.current && setForcedRenderCount(forcedRenderCount + 1);
|
|
10
|
+
}, [forcedRenderCount]);
|
|
11
|
+
/**
|
|
12
|
+
* Defer this to the end of the next animation frame in case there are multiple
|
|
13
|
+
* synchronous calls.
|
|
14
|
+
*/
|
|
15
|
+
const deferredForceRender = useCallback(() => frame.postRender(forceRender), [forceRender]);
|
|
16
|
+
return [deferredForceRender, forcedRenderCount];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { useForceUpdate };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useIsomorphicLayoutEffect } from './use-isomorphic-effect.js';
|
|
3
|
+
|
|
4
|
+
function useIsMounted() {
|
|
5
|
+
const isMounted = useRef(false);
|
|
6
|
+
useIsomorphicLayoutEffect(() => {
|
|
7
|
+
isMounted.current = true;
|
|
8
|
+
return () => {
|
|
9
|
+
isMounted.current = false;
|
|
10
|
+
};
|
|
11
|
+
}, []);
|
|
12
|
+
return isMounted;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useIsMounted };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Convert velocity into velocity per second
|
|
3
|
+
|
|
4
|
+
@param [number]: Unit per frame
|
|
5
|
+
@param [number]: Frame duration in ms
|
|
6
|
+
*/
|
|
7
|
+
function velocityPerSecond(velocity, frameDuration) {
|
|
8
|
+
return frameDuration ? velocity * (1000 / frameDuration) : 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { velocityPerSecond };
|