@teamturing/react-kit 2.4.0 → 2.5.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/Dialog/index.d.ts +16 -0
- package/dist/core/DialogHandler/index.d.ts +13 -0
- package/dist/core/Grid/index.d.ts +2 -2
- package/dist/core/MotionView/index.d.ts +3 -0
- package/dist/core/Stack/index.d.ts +2 -2
- package/dist/hook/useDialogHandler.d.ts +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9762 -323
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/isFunction.d.ts +1 -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/hook/useDialogHandler.js +14 -0
- package/esm/index.js +3 -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/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 +3 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isSVGComponent } from './is-svg-component.js';
|
|
2
|
+
import { createUseRender } from '../use-render.js';
|
|
3
|
+
import { svgMotionConfig } from '../../svg/config-motion.js';
|
|
4
|
+
import { htmlMotionConfig } from '../../html/config-motion.js';
|
|
5
|
+
|
|
6
|
+
function createDomMotionConfig(Component, { forwardMotionProps = false }, preloadedFeatures, createVisualElement) {
|
|
7
|
+
const baseConfig = isSVGComponent(Component)
|
|
8
|
+
? svgMotionConfig
|
|
9
|
+
: htmlMotionConfig;
|
|
10
|
+
return {
|
|
11
|
+
...baseConfig,
|
|
12
|
+
preloadedFeatures,
|
|
13
|
+
useRender: createUseRender(forwardMotionProps),
|
|
14
|
+
createVisualElement,
|
|
15
|
+
Component,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { createDomMotionConfig };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { invariant } from '../../../utils/errors.js';
|
|
2
|
+
import { isNumericalString } from '../../../utils/is-numerical-string.js';
|
|
3
|
+
import { isCSSVariableToken } from './is-css-variable.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse Framer's special CSS variable format into a CSS token and a fallback.
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* `var(--foo, #fff)` => [`--foo`, '#fff']
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param current
|
|
13
|
+
*/
|
|
14
|
+
const splitCSSVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;
|
|
15
|
+
function parseCSSVariable(current) {
|
|
16
|
+
const match = splitCSSVariableRegex.exec(current);
|
|
17
|
+
if (!match)
|
|
18
|
+
return [,];
|
|
19
|
+
const [, token, fallback] = match;
|
|
20
|
+
return [token, fallback];
|
|
21
|
+
}
|
|
22
|
+
const maxDepth = 4;
|
|
23
|
+
function getVariableValue(current, element, depth = 1) {
|
|
24
|
+
invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
|
|
25
|
+
const [token, fallback] = parseCSSVariable(current);
|
|
26
|
+
// No CSS variable detected
|
|
27
|
+
if (!token)
|
|
28
|
+
return;
|
|
29
|
+
// Attempt to read this CSS variable off the element
|
|
30
|
+
const resolved = window.getComputedStyle(element).getPropertyValue(token);
|
|
31
|
+
if (resolved) {
|
|
32
|
+
const trimmed = resolved.trim();
|
|
33
|
+
return isNumericalString(trimmed) ? parseFloat(trimmed) : trimmed;
|
|
34
|
+
}
|
|
35
|
+
else if (isCSSVariableToken(fallback)) {
|
|
36
|
+
// The fallback might itself be a CSS variable, in which case we attempt to resolve it too.
|
|
37
|
+
return getVariableValue(fallback, element, depth + 1);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return fallback;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve CSS variables from
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
function resolveCSSVariables(visualElement, { ...target }, transitionEnd) {
|
|
49
|
+
const element = visualElement.current;
|
|
50
|
+
if (!(element instanceof Element))
|
|
51
|
+
return { target, transitionEnd };
|
|
52
|
+
// If `transitionEnd` isn't `undefined`, clone it. We could clone `target` and `transitionEnd`
|
|
53
|
+
// only if they change but I think this reads clearer and this isn't a performance-critical path.
|
|
54
|
+
if (transitionEnd) {
|
|
55
|
+
transitionEnd = { ...transitionEnd };
|
|
56
|
+
}
|
|
57
|
+
// Go through existing `MotionValue`s and ensure any existing CSS variables are resolved
|
|
58
|
+
visualElement.values.forEach((value) => {
|
|
59
|
+
const current = value.get();
|
|
60
|
+
if (!isCSSVariableToken(current))
|
|
61
|
+
return;
|
|
62
|
+
const resolved = getVariableValue(current, element);
|
|
63
|
+
if (resolved)
|
|
64
|
+
value.set(resolved);
|
|
65
|
+
});
|
|
66
|
+
// Cycle through every target property and resolve CSS variables. Currently
|
|
67
|
+
// we only read single-var properties like `var(--foo)`, not `calc(var(--foo) + 20px)`
|
|
68
|
+
for (const key in target) {
|
|
69
|
+
const current = target[key];
|
|
70
|
+
if (!isCSSVariableToken(current))
|
|
71
|
+
continue;
|
|
72
|
+
const resolved = getVariableValue(current, element);
|
|
73
|
+
if (!resolved)
|
|
74
|
+
continue;
|
|
75
|
+
// Clone target if it hasn't already been
|
|
76
|
+
target[key] = resolved;
|
|
77
|
+
if (!transitionEnd)
|
|
78
|
+
transitionEnd = {};
|
|
79
|
+
// If the user hasn't already set this key on `transitionEnd`, set it to the unresolved
|
|
80
|
+
// CSS variable. This will ensure that after the animation the component will reflect
|
|
81
|
+
// changes in the value of the CSS variable.
|
|
82
|
+
if (transitionEnd[key] === undefined) {
|
|
83
|
+
transitionEnd[key] = current;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { target, transitionEnd };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { parseCSSVariable, resolveCSSVariables };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isValidMotionProp } from '../../../motion/utils/valid-prop.js';
|
|
2
|
+
|
|
3
|
+
let shouldForward = (key) => !isValidMotionProp(key);
|
|
4
|
+
function loadExternalIsValidProp(isValidProp) {
|
|
5
|
+
if (!isValidProp)
|
|
6
|
+
return;
|
|
7
|
+
// Explicitly filter our events
|
|
8
|
+
shouldForward = (key) => key.startsWith("on") ? !isValidMotionProp(key) : isValidProp(key);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Emotion and Styled Components both allow users to pass through arbitrary props to their components
|
|
12
|
+
* to dynamically generate CSS. They both use the `@emotion/is-prop-valid` package to determine which
|
|
13
|
+
* of these should be passed to the underlying DOM node.
|
|
14
|
+
*
|
|
15
|
+
* However, when styling a Motion component `styled(motion.div)`, both packages pass through *all* props
|
|
16
|
+
* as it's seen as an arbitrary component rather than a DOM node. Motion only allows arbitrary props
|
|
17
|
+
* passed through the `custom` prop so it doesn't *need* the payload or computational overhead of
|
|
18
|
+
* `@emotion/is-prop-valid`, however to fix this problem we need to use it.
|
|
19
|
+
*
|
|
20
|
+
* By making it an optionalDependency we can offer this functionality only in the situations where it's
|
|
21
|
+
* actually required.
|
|
22
|
+
*/
|
|
23
|
+
try {
|
|
24
|
+
/**
|
|
25
|
+
* We attempt to import this package but require won't be defined in esm environments, in that case
|
|
26
|
+
* isPropValid will have to be provided via `MotionContext`. In a 6.0.0 this should probably be removed
|
|
27
|
+
* in favour of explicit injection.
|
|
28
|
+
*/
|
|
29
|
+
loadExternalIsValidProp(require("@emotion/is-prop-valid").default);
|
|
30
|
+
}
|
|
31
|
+
catch (_a) {
|
|
32
|
+
// We don't need to actually do anything here - the fallback is the existing `isPropValid`.
|
|
33
|
+
}
|
|
34
|
+
function filterProps(props, isDom, forwardMotionProps) {
|
|
35
|
+
const filteredProps = {};
|
|
36
|
+
for (const key in props) {
|
|
37
|
+
/**
|
|
38
|
+
* values is considered a valid prop by Emotion, so if it's present
|
|
39
|
+
* this will be rendered out to the DOM unless explicitly filtered.
|
|
40
|
+
*
|
|
41
|
+
* We check the type as it could be used with the `feColorMatrix`
|
|
42
|
+
* element, which we support.
|
|
43
|
+
*/
|
|
44
|
+
if (key === "values" && typeof props.values === "object")
|
|
45
|
+
continue;
|
|
46
|
+
if (shouldForward(key) ||
|
|
47
|
+
(forwardMotionProps === true && isValidMotionProp(key)) ||
|
|
48
|
+
(!isDom && !isValidMotionProp(key)) ||
|
|
49
|
+
// If trying to use native HTML drag events, forward drag listeners
|
|
50
|
+
(props["draggable"] && key.startsWith("onDrag"))) {
|
|
51
|
+
filteredProps[key] = props[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return filteredProps;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { filterProps, loadExternalIsValidProp };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
2
|
+
const isCSSVariableName = checkStringStartsWith("--");
|
|
3
|
+
const isCSSVariableToken = checkStringStartsWith("var(--");
|
|
4
|
+
const cssVariableRegex = /var\s*\(\s*--[\w-]+(\s*,\s*(?:(?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)+)?\s*\)/g;
|
|
5
|
+
|
|
6
|
+
export { cssVariableRegex, isCSSVariableName, isCSSVariableToken };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { lowercaseSVGElements } from '../../svg/lowercase-elements.js';
|
|
2
|
+
|
|
3
|
+
function isSVGComponent(Component) {
|
|
4
|
+
if (
|
|
5
|
+
/**
|
|
6
|
+
* If it's not a string, it's a custom React component. Currently we only support
|
|
7
|
+
* HTML custom React components.
|
|
8
|
+
*/
|
|
9
|
+
typeof Component !== "string" ||
|
|
10
|
+
/**
|
|
11
|
+
* If it contains a dash, the element is a custom HTML webcomponent.
|
|
12
|
+
*/
|
|
13
|
+
Component.includes("-")) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
else if (
|
|
17
|
+
/**
|
|
18
|
+
* If it's in our list of lowercase SVG tags, it's an SVG component
|
|
19
|
+
*/
|
|
20
|
+
lowercaseSVGElements.indexOf(Component) > -1 ||
|
|
21
|
+
/**
|
|
22
|
+
* If it contains a capital letter, it's an SVG component
|
|
23
|
+
*/
|
|
24
|
+
/[A-Z]/.test(Component)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { isSVGComponent };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { resolveCSSVariables } from './css-variables-conversion.js';
|
|
2
|
+
import { unitConversion } from './unit-conversion.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parse a DOM variant to make it animatable. This involves resolving CSS variables
|
|
6
|
+
* and ensuring animations like "20%" => "calc(50vw)" are performed in pixels.
|
|
7
|
+
*/
|
|
8
|
+
const parseDomVariant = (visualElement, target, origin, transitionEnd) => {
|
|
9
|
+
const resolved = resolveCSSVariables(visualElement, target, transitionEnd);
|
|
10
|
+
target = resolved.target;
|
|
11
|
+
transitionEnd = resolved.transitionEnd;
|
|
12
|
+
return unitConversion(visualElement, target, origin, transitionEnd);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { parseDomVariant };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { isKeyframesTarget } from '../../../animation/utils/is-keyframes-target.js';
|
|
2
|
+
import { invariant } from '../../../utils/errors.js';
|
|
3
|
+
import { transformPropOrder } from '../../html/utils/transform.js';
|
|
4
|
+
import { findDimensionValueType } from '../value-types/dimensions.js';
|
|
5
|
+
import { isBrowser } from '../../../utils/is-browser.js';
|
|
6
|
+
import { number } from '../../../value/types/numbers/index.js';
|
|
7
|
+
import { px } from '../../../value/types/numbers/units.js';
|
|
8
|
+
|
|
9
|
+
const positionalKeys = new Set([
|
|
10
|
+
"width",
|
|
11
|
+
"height",
|
|
12
|
+
"top",
|
|
13
|
+
"left",
|
|
14
|
+
"right",
|
|
15
|
+
"bottom",
|
|
16
|
+
"x",
|
|
17
|
+
"y",
|
|
18
|
+
"translateX",
|
|
19
|
+
"translateY",
|
|
20
|
+
]);
|
|
21
|
+
const isPositionalKey = (key) => positionalKeys.has(key);
|
|
22
|
+
const hasPositionalKey = (target) => {
|
|
23
|
+
return Object.keys(target).some(isPositionalKey);
|
|
24
|
+
};
|
|
25
|
+
const isNumOrPxType = (v) => v === number || v === px;
|
|
26
|
+
const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
|
|
27
|
+
const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform }) => {
|
|
28
|
+
if (transform === "none" || !transform)
|
|
29
|
+
return 0;
|
|
30
|
+
const matrix3d = transform.match(/^matrix3d\((.+)\)$/);
|
|
31
|
+
if (matrix3d) {
|
|
32
|
+
return getPosFromMatrix(matrix3d[1], pos3);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const matrix = transform.match(/^matrix\((.+)\)$/);
|
|
36
|
+
if (matrix) {
|
|
37
|
+
return getPosFromMatrix(matrix[1], pos2);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const transformKeys = new Set(["x", "y", "z"]);
|
|
45
|
+
const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
|
|
46
|
+
function removeNonTranslationalTransform(visualElement) {
|
|
47
|
+
const removedTransforms = [];
|
|
48
|
+
nonTranslationalTransformKeys.forEach((key) => {
|
|
49
|
+
const value = visualElement.getValue(key);
|
|
50
|
+
if (value !== undefined) {
|
|
51
|
+
removedTransforms.push([key, value.get()]);
|
|
52
|
+
value.set(key.startsWith("scale") ? 1 : 0);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Apply changes to element before measurement
|
|
56
|
+
if (removedTransforms.length)
|
|
57
|
+
visualElement.render();
|
|
58
|
+
return removedTransforms;
|
|
59
|
+
}
|
|
60
|
+
const positionalValues = {
|
|
61
|
+
// Dimensions
|
|
62
|
+
width: ({ x }, { paddingLeft = "0", paddingRight = "0" }) => x.max - x.min - parseFloat(paddingLeft) - parseFloat(paddingRight),
|
|
63
|
+
height: ({ y }, { paddingTop = "0", paddingBottom = "0" }) => y.max - y.min - parseFloat(paddingTop) - parseFloat(paddingBottom),
|
|
64
|
+
top: (_bbox, { top }) => parseFloat(top),
|
|
65
|
+
left: (_bbox, { left }) => parseFloat(left),
|
|
66
|
+
bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
|
|
67
|
+
right: ({ x }, { left }) => parseFloat(left) + (x.max - x.min),
|
|
68
|
+
// Transform
|
|
69
|
+
x: getTranslateFromMatrix(4, 13),
|
|
70
|
+
y: getTranslateFromMatrix(5, 14),
|
|
71
|
+
};
|
|
72
|
+
// Alias translate longform names
|
|
73
|
+
positionalValues.translateX = positionalValues.x;
|
|
74
|
+
positionalValues.translateY = positionalValues.y;
|
|
75
|
+
const convertChangedValueTypes = (target, visualElement, changedKeys) => {
|
|
76
|
+
const originBbox = visualElement.measureViewportBox();
|
|
77
|
+
const element = visualElement.current;
|
|
78
|
+
const elementComputedStyle = getComputedStyle(element);
|
|
79
|
+
const { display } = elementComputedStyle;
|
|
80
|
+
const origin = {};
|
|
81
|
+
// If the element is currently set to display: "none", make it visible before
|
|
82
|
+
// measuring the target bounding box
|
|
83
|
+
if (display === "none") {
|
|
84
|
+
visualElement.setStaticValue("display", target.display || "block");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Record origins before we render and update styles
|
|
88
|
+
*/
|
|
89
|
+
changedKeys.forEach((key) => {
|
|
90
|
+
origin[key] = positionalValues[key](originBbox, elementComputedStyle);
|
|
91
|
+
});
|
|
92
|
+
// Apply the latest values (as set in checkAndConvertChangedValueTypes)
|
|
93
|
+
visualElement.render();
|
|
94
|
+
const targetBbox = visualElement.measureViewportBox();
|
|
95
|
+
changedKeys.forEach((key) => {
|
|
96
|
+
// Restore styles to their **calculated computed style**, not their actual
|
|
97
|
+
// originally set style. This allows us to animate between equivalent pixel units.
|
|
98
|
+
const value = visualElement.getValue(key);
|
|
99
|
+
value && value.jump(origin[key]);
|
|
100
|
+
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
101
|
+
});
|
|
102
|
+
return target;
|
|
103
|
+
};
|
|
104
|
+
const checkAndConvertChangedValueTypes = (visualElement, target, origin = {}, transitionEnd = {}) => {
|
|
105
|
+
target = { ...target };
|
|
106
|
+
transitionEnd = { ...transitionEnd };
|
|
107
|
+
const targetPositionalKeys = Object.keys(target).filter(isPositionalKey);
|
|
108
|
+
// We want to remove any transform values that could affect the element's bounding box before
|
|
109
|
+
// it's measured. We'll reapply these later.
|
|
110
|
+
let removedTransformValues = [];
|
|
111
|
+
let hasAttemptedToRemoveTransformValues = false;
|
|
112
|
+
const changedValueTypeKeys = [];
|
|
113
|
+
targetPositionalKeys.forEach((key) => {
|
|
114
|
+
const value = visualElement.getValue(key);
|
|
115
|
+
if (!visualElement.hasValue(key))
|
|
116
|
+
return;
|
|
117
|
+
let from = origin[key];
|
|
118
|
+
let fromType = findDimensionValueType(from);
|
|
119
|
+
const to = target[key];
|
|
120
|
+
let toType;
|
|
121
|
+
// TODO: The current implementation of this basically throws an error
|
|
122
|
+
// if you try and do value conversion via keyframes. There's probably
|
|
123
|
+
// a way of doing this but the performance implications would need greater scrutiny,
|
|
124
|
+
// as it'd be doing multiple resize-remeasure operations.
|
|
125
|
+
if (isKeyframesTarget(to)) {
|
|
126
|
+
const numKeyframes = to.length;
|
|
127
|
+
const fromIndex = to[0] === null ? 1 : 0;
|
|
128
|
+
from = to[fromIndex];
|
|
129
|
+
fromType = findDimensionValueType(from);
|
|
130
|
+
for (let i = fromIndex; i < numKeyframes; i++) {
|
|
131
|
+
/**
|
|
132
|
+
* Don't allow wildcard keyframes to be used to detect
|
|
133
|
+
* a difference in value types.
|
|
134
|
+
*/
|
|
135
|
+
if (to[i] === null)
|
|
136
|
+
break;
|
|
137
|
+
if (!toType) {
|
|
138
|
+
toType = findDimensionValueType(to[i]);
|
|
139
|
+
invariant(toType === fromType ||
|
|
140
|
+
(isNumOrPxType(fromType) && isNumOrPxType(toType)), "Keyframes must be of the same dimension as the current value");
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
invariant(findDimensionValueType(to[i]) === toType, "All keyframes must be of the same type");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
toType = findDimensionValueType(to);
|
|
149
|
+
}
|
|
150
|
+
if (fromType !== toType) {
|
|
151
|
+
// If they're both just number or px, convert them both to numbers rather than
|
|
152
|
+
// relying on resize/remeasure to convert (which is wasteful in this situation)
|
|
153
|
+
if (isNumOrPxType(fromType) && isNumOrPxType(toType)) {
|
|
154
|
+
const current = value.get();
|
|
155
|
+
if (typeof current === "string") {
|
|
156
|
+
value.set(parseFloat(current));
|
|
157
|
+
}
|
|
158
|
+
if (typeof to === "string") {
|
|
159
|
+
target[key] = parseFloat(to);
|
|
160
|
+
}
|
|
161
|
+
else if (Array.isArray(to) && toType === px) {
|
|
162
|
+
target[key] = to.map(parseFloat);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else if ((fromType === null || fromType === void 0 ? void 0 : fromType.transform) &&
|
|
166
|
+
(toType === null || toType === void 0 ? void 0 : toType.transform) &&
|
|
167
|
+
(from === 0 || to === 0)) {
|
|
168
|
+
// If one or the other value is 0, it's safe to coerce it to the
|
|
169
|
+
// type of the other without measurement
|
|
170
|
+
if (from === 0) {
|
|
171
|
+
value.set(toType.transform(from));
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
target[key] = fromType.transform(to);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// If we're going to do value conversion via DOM measurements, we first
|
|
179
|
+
// need to remove non-positional transform values that could affect the bbox measurements.
|
|
180
|
+
if (!hasAttemptedToRemoveTransformValues) {
|
|
181
|
+
removedTransformValues =
|
|
182
|
+
removeNonTranslationalTransform(visualElement);
|
|
183
|
+
hasAttemptedToRemoveTransformValues = true;
|
|
184
|
+
}
|
|
185
|
+
changedValueTypeKeys.push(key);
|
|
186
|
+
transitionEnd[key] =
|
|
187
|
+
transitionEnd[key] !== undefined
|
|
188
|
+
? transitionEnd[key]
|
|
189
|
+
: target[key];
|
|
190
|
+
value.jump(to);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
if (changedValueTypeKeys.length) {
|
|
195
|
+
const scrollY = changedValueTypeKeys.indexOf("height") >= 0
|
|
196
|
+
? window.pageYOffset
|
|
197
|
+
: null;
|
|
198
|
+
const convertedTarget = convertChangedValueTypes(target, visualElement, changedValueTypeKeys);
|
|
199
|
+
// If we removed transform values, reapply them before the next render
|
|
200
|
+
if (removedTransformValues.length) {
|
|
201
|
+
removedTransformValues.forEach(([key, value]) => {
|
|
202
|
+
visualElement.getValue(key).set(value);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// Reapply original values
|
|
206
|
+
visualElement.render();
|
|
207
|
+
// Restore scroll position
|
|
208
|
+
if (isBrowser && scrollY !== null) {
|
|
209
|
+
window.scrollTo({ top: scrollY });
|
|
210
|
+
}
|
|
211
|
+
return { target: convertedTarget, transitionEnd };
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
return { target, transitionEnd };
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Convert value types for x/y/width/height/top/left/bottom/right
|
|
219
|
+
*
|
|
220
|
+
* Allows animation between `'auto'` -> `'100%'` or `0` -> `'calc(50% - 10vw)'`
|
|
221
|
+
*
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
function unitConversion(visualElement, target, origin, transitionEnd) {
|
|
225
|
+
return hasPositionalKey(target)
|
|
226
|
+
? checkAndConvertChangedValueTypes(visualElement, target, origin, transitionEnd)
|
|
227
|
+
: { target, transitionEnd };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { positionalValues, unitConversion };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { complex } from '../../../value/types/complex/index.js';
|
|
2
|
+
import { filter } from '../../../value/types/complex/filter.js';
|
|
3
|
+
import { getDefaultValueType } from './defaults.js';
|
|
4
|
+
|
|
5
|
+
function getAnimatableNone(key, value) {
|
|
6
|
+
let defaultValueType = getDefaultValueType(key);
|
|
7
|
+
if (defaultValueType !== filter)
|
|
8
|
+
defaultValueType = complex;
|
|
9
|
+
// If value is not recognised as animatable, ie "none", create an animatable version origin based on the target
|
|
10
|
+
return defaultValueType.getAnimatableNone
|
|
11
|
+
? defaultValueType.getAnimatableNone(value)
|
|
12
|
+
: undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { getAnimatableNone };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { color } from '../../../value/types/color/index.js';
|
|
2
|
+
import { filter } from '../../../value/types/complex/filter.js';
|
|
3
|
+
import { numberValueTypes } from './number.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A map of default value types for common values
|
|
7
|
+
*/
|
|
8
|
+
const defaultValueTypes = {
|
|
9
|
+
...numberValueTypes,
|
|
10
|
+
// Color props
|
|
11
|
+
color,
|
|
12
|
+
backgroundColor: color,
|
|
13
|
+
outlineColor: color,
|
|
14
|
+
fill: color,
|
|
15
|
+
stroke: color,
|
|
16
|
+
// Border props
|
|
17
|
+
borderColor: color,
|
|
18
|
+
borderTopColor: color,
|
|
19
|
+
borderRightColor: color,
|
|
20
|
+
borderBottomColor: color,
|
|
21
|
+
borderLeftColor: color,
|
|
22
|
+
filter,
|
|
23
|
+
WebkitFilter: filter,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Gets the default ValueType for the provided value key
|
|
27
|
+
*/
|
|
28
|
+
const getDefaultValueType = (key) => defaultValueTypes[key];
|
|
29
|
+
|
|
30
|
+
export { defaultValueTypes, getDefaultValueType };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { number } from '../../../value/types/numbers/index.js';
|
|
2
|
+
import { px, percent, degrees, vw, vh } from '../../../value/types/numbers/units.js';
|
|
3
|
+
import { testValueType } from './test.js';
|
|
4
|
+
import { auto } from './type-auto.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A list of value types commonly used for dimensions
|
|
8
|
+
*/
|
|
9
|
+
const dimensionValueTypes = [number, px, percent, degrees, vw, vh, auto];
|
|
10
|
+
/**
|
|
11
|
+
* Tests a dimensional value against the list of dimension ValueTypes
|
|
12
|
+
*/
|
|
13
|
+
const findDimensionValueType = (v) => dimensionValueTypes.find(testValueType(v));
|
|
14
|
+
|
|
15
|
+
export { dimensionValueTypes, findDimensionValueType };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { color } from '../../../value/types/color/index.js';
|
|
2
|
+
import { complex } from '../../../value/types/complex/index.js';
|
|
3
|
+
import { dimensionValueTypes } from './dimensions.js';
|
|
4
|
+
import { testValueType } from './test.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A list of all ValueTypes
|
|
8
|
+
*/
|
|
9
|
+
const valueTypes = [...dimensionValueTypes, color, complex];
|
|
10
|
+
/**
|
|
11
|
+
* Tests a value against the list of ValueTypes
|
|
12
|
+
*/
|
|
13
|
+
const findValueType = (v) => valueTypes.find(testValueType(v));
|
|
14
|
+
|
|
15
|
+
export { findValueType };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { scale, alpha } from '../../../value/types/numbers/index.js';
|
|
2
|
+
import { px, degrees, progressPercentage } from '../../../value/types/numbers/units.js';
|
|
3
|
+
import { int } from './type-int.js';
|
|
4
|
+
|
|
5
|
+
const numberValueTypes = {
|
|
6
|
+
// Border props
|
|
7
|
+
borderWidth: px,
|
|
8
|
+
borderTopWidth: px,
|
|
9
|
+
borderRightWidth: px,
|
|
10
|
+
borderBottomWidth: px,
|
|
11
|
+
borderLeftWidth: px,
|
|
12
|
+
borderRadius: px,
|
|
13
|
+
radius: px,
|
|
14
|
+
borderTopLeftRadius: px,
|
|
15
|
+
borderTopRightRadius: px,
|
|
16
|
+
borderBottomRightRadius: px,
|
|
17
|
+
borderBottomLeftRadius: px,
|
|
18
|
+
// Positioning props
|
|
19
|
+
width: px,
|
|
20
|
+
maxWidth: px,
|
|
21
|
+
height: px,
|
|
22
|
+
maxHeight: px,
|
|
23
|
+
size: px,
|
|
24
|
+
top: px,
|
|
25
|
+
right: px,
|
|
26
|
+
bottom: px,
|
|
27
|
+
left: px,
|
|
28
|
+
// Spacing props
|
|
29
|
+
padding: px,
|
|
30
|
+
paddingTop: px,
|
|
31
|
+
paddingRight: px,
|
|
32
|
+
paddingBottom: px,
|
|
33
|
+
paddingLeft: px,
|
|
34
|
+
margin: px,
|
|
35
|
+
marginTop: px,
|
|
36
|
+
marginRight: px,
|
|
37
|
+
marginBottom: px,
|
|
38
|
+
marginLeft: px,
|
|
39
|
+
// Transform props
|
|
40
|
+
rotate: degrees,
|
|
41
|
+
rotateX: degrees,
|
|
42
|
+
rotateY: degrees,
|
|
43
|
+
rotateZ: degrees,
|
|
44
|
+
scale,
|
|
45
|
+
scaleX: scale,
|
|
46
|
+
scaleY: scale,
|
|
47
|
+
scaleZ: scale,
|
|
48
|
+
skew: degrees,
|
|
49
|
+
skewX: degrees,
|
|
50
|
+
skewY: degrees,
|
|
51
|
+
distance: px,
|
|
52
|
+
translateX: px,
|
|
53
|
+
translateY: px,
|
|
54
|
+
translateZ: px,
|
|
55
|
+
x: px,
|
|
56
|
+
y: px,
|
|
57
|
+
z: px,
|
|
58
|
+
perspective: px,
|
|
59
|
+
transformPerspective: px,
|
|
60
|
+
opacity: alpha,
|
|
61
|
+
originX: progressPercentage,
|
|
62
|
+
originY: progressPercentage,
|
|
63
|
+
originZ: px,
|
|
64
|
+
// Misc
|
|
65
|
+
zIndex: int,
|
|
66
|
+
// SVG
|
|
67
|
+
fillOpacity: alpha,
|
|
68
|
+
strokeOpacity: alpha,
|
|
69
|
+
numOctaves: int,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { numberValueTypes };
|