@number10/phaserjsx 0.1.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/LICENSE +667 -0
- package/README.md +238 -0
- package/dist/TransformOriginView-BYPbRH8N.cjs +17045 -0
- package/dist/TransformOriginView-BYPbRH8N.cjs.map +1 -0
- package/dist/TransformOriginView-CO-tJCmV.js +17046 -0
- package/dist/TransformOriginView-CO-tJCmV.js.map +1 -0
- package/dist/animation/animated-signal.d.ts +35 -0
- package/dist/animation/animated-signal.d.ts.map +1 -0
- package/dist/animation/index.d.ts +7 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/spring-physics.d.ts +120 -0
- package/dist/animation/spring-physics.d.ts.map +1 -0
- package/dist/animation/useSpring.d.ts +54 -0
- package/dist/animation/useSpring.d.ts.map +1 -0
- package/dist/colors/color-presets.d.ts +89 -0
- package/dist/colors/color-presets.d.ts.map +1 -0
- package/dist/colors/color-theme-helpers.d.ts +65 -0
- package/dist/colors/color-theme-helpers.d.ts.map +1 -0
- package/dist/colors/color-types.d.ts +100 -0
- package/dist/colors/color-types.d.ts.map +1 -0
- package/dist/colors/color-utils.d.ts +171 -0
- package/dist/colors/color-utils.d.ts.map +1 -0
- package/dist/colors/index.d.ts +17 -0
- package/dist/colors/index.d.ts.map +1 -0
- package/dist/colors/preset-manager.d.ts +35 -0
- package/dist/colors/preset-manager.d.ts.map +1 -0
- package/dist/colors/use-color-mode.d.ts +22 -0
- package/dist/colors/use-color-mode.d.ts.map +1 -0
- package/dist/colors/use-colors.d.ts +40 -0
- package/dist/colors/use-colors.d.ts.map +1 -0
- package/dist/components/appliers/applyBackground.d.ts +13 -0
- package/dist/components/appliers/applyBackground.d.ts.map +1 -0
- package/dist/components/appliers/applyGestures.d.ts +12 -0
- package/dist/components/appliers/applyGestures.d.ts.map +1 -0
- package/dist/components/appliers/applyGraphics.d.ts +10 -0
- package/dist/components/appliers/applyGraphics.d.ts.map +1 -0
- package/dist/components/appliers/applyGraphicsLayout.d.ts +10 -0
- package/dist/components/appliers/applyGraphicsLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyImage.d.ts +10 -0
- package/dist/components/appliers/applyImage.d.ts.map +1 -0
- package/dist/components/appliers/applyImageLayout.d.ts +15 -0
- package/dist/components/appliers/applyImageLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyLayout.d.ts +15 -0
- package/dist/components/appliers/applyLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyNineSlice.d.ts +11 -0
- package/dist/components/appliers/applyNineSlice.d.ts.map +1 -0
- package/dist/components/appliers/applyNineSliceLayout.d.ts +15 -0
- package/dist/components/appliers/applyNineSliceLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyPhaser.d.ts +22 -0
- package/dist/components/appliers/applyPhaser.d.ts.map +1 -0
- package/dist/components/appliers/applySprite.d.ts +10 -0
- package/dist/components/appliers/applySprite.d.ts.map +1 -0
- package/dist/components/appliers/applySpriteLayout.d.ts +14 -0
- package/dist/components/appliers/applySpriteLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyText.d.ts +25 -0
- package/dist/components/appliers/applyText.d.ts.map +1 -0
- package/dist/components/appliers/applyTextLayout.d.ts +15 -0
- package/dist/components/appliers/applyTextLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyTooltip.d.ts +12 -0
- package/dist/components/appliers/applyTooltip.d.ts.map +1 -0
- package/dist/components/appliers/applyTransform.d.ts +21 -0
- package/dist/components/appliers/applyTransform.d.ts.map +1 -0
- package/dist/components/creators/createBackground.d.ts +15 -0
- package/dist/components/creators/createBackground.d.ts.map +1 -0
- package/dist/components/creators/createGestures.d.ts +11 -0
- package/dist/components/creators/createGestures.d.ts.map +1 -0
- package/dist/components/creators/createGraphicsLayout.d.ts +9 -0
- package/dist/components/creators/createGraphicsLayout.d.ts.map +1 -0
- package/dist/components/creators/createImageLayout.d.ts +14 -0
- package/dist/components/creators/createImageLayout.d.ts.map +1 -0
- package/dist/components/creators/createLayout.d.ts +15 -0
- package/dist/components/creators/createLayout.d.ts.map +1 -0
- package/dist/components/creators/createNineSliceLayout.d.ts +14 -0
- package/dist/components/creators/createNineSliceLayout.d.ts.map +1 -0
- package/dist/components/creators/createPhaser.d.ts +14 -0
- package/dist/components/creators/createPhaser.d.ts.map +1 -0
- package/dist/components/creators/createSpriteLayout.d.ts +15 -0
- package/dist/components/creators/createSpriteLayout.d.ts.map +1 -0
- package/dist/components/creators/createTextLayout.d.ts +14 -0
- package/dist/components/creators/createTextLayout.d.ts.map +1 -0
- package/dist/components/creators/createTransform.d.ts +11 -0
- package/dist/components/creators/createTransform.d.ts.map +1 -0
- package/dist/components/custom/Accordion.d.ts +34 -0
- package/dist/components/custom/Accordion.d.ts.map +1 -0
- package/dist/components/custom/AlertDialog.d.ts +63 -0
- package/dist/components/custom/AlertDialog.d.ts.map +1 -0
- package/dist/components/custom/Button.d.ts +44 -0
- package/dist/components/custom/Button.d.ts.map +1 -0
- package/dist/components/custom/CharText/CharText.d.ts +8 -0
- package/dist/components/custom/CharText/CharText.d.ts.map +1 -0
- package/dist/components/custom/CharText/index.d.ts +3 -0
- package/dist/components/custom/CharText/index.d.ts.map +1 -0
- package/dist/components/custom/CharText/types.d.ts +117 -0
- package/dist/components/custom/CharText/types.d.ts.map +1 -0
- package/dist/components/custom/CharText/utils.d.ts +34 -0
- package/dist/components/custom/CharText/utils.d.ts.map +1 -0
- package/dist/components/custom/CharTextInput.d.ts +62 -0
- package/dist/components/custom/CharTextInput.d.ts.map +1 -0
- package/dist/components/custom/Dialog.d.ts +60 -0
- package/dist/components/custom/Dialog.d.ts.map +1 -0
- package/dist/components/custom/Divider.d.ts +21 -0
- package/dist/components/custom/Divider.d.ts.map +1 -0
- package/dist/components/custom/Dropdown.d.ts +91 -0
- package/dist/components/custom/Dropdown.d.ts.map +1 -0
- package/dist/components/custom/Icon.d.ts +75 -0
- package/dist/components/custom/Icon.d.ts.map +1 -0
- package/dist/components/custom/Image.d.ts +50 -0
- package/dist/components/custom/Image.d.ts.map +1 -0
- package/dist/components/custom/Modal.d.ts +37 -0
- package/dist/components/custom/Modal.d.ts.map +1 -0
- package/dist/components/custom/NineSlice.d.ts +81 -0
- package/dist/components/custom/NineSlice.d.ts.map +1 -0
- package/dist/components/custom/NineSliceButton.d.ts +128 -0
- package/dist/components/custom/NineSliceButton.d.ts.map +1 -0
- package/dist/components/custom/Portal.d.ts +43 -0
- package/dist/components/custom/Portal.d.ts.map +1 -0
- package/dist/components/custom/Portal.test.d.ts +2 -0
- package/dist/components/custom/Portal.test.d.ts.map +1 -0
- package/dist/components/custom/RadioButton.d.ts +20 -0
- package/dist/components/custom/RadioButton.d.ts.map +1 -0
- package/dist/components/custom/RadioGroup.d.ts +33 -0
- package/dist/components/custom/RadioGroup.d.ts.map +1 -0
- package/dist/components/custom/RefOriginView.d.ts +45 -0
- package/dist/components/custom/RefOriginView.d.ts.map +1 -0
- package/dist/components/custom/ScrollSlider.d.ts +36 -0
- package/dist/components/custom/ScrollSlider.d.ts.map +1 -0
- package/dist/components/custom/ScrollView.d.ts +48 -0
- package/dist/components/custom/ScrollView.d.ts.map +1 -0
- package/dist/components/custom/Sidebar.d.ts +50 -0
- package/dist/components/custom/Sidebar.d.ts.map +1 -0
- package/dist/components/custom/Slider.d.ts +131 -0
- package/dist/components/custom/Slider.d.ts.map +1 -0
- package/dist/components/custom/Text.d.ts +26 -0
- package/dist/components/custom/Text.d.ts.map +1 -0
- package/dist/components/custom/Toggle.d.ts +51 -0
- package/dist/components/custom/Toggle.d.ts.map +1 -0
- package/dist/components/custom/TransformOriginView.d.ts +34 -0
- package/dist/components/custom/TransformOriginView.d.ts.map +1 -0
- package/dist/components/custom/View.d.ts +33 -0
- package/dist/components/custom/View.d.ts.map +1 -0
- package/dist/components/custom/WrapText.d.ts +60 -0
- package/dist/components/custom/WrapText.d.ts.map +1 -0
- package/dist/components/custom/index.cjs +32 -0
- package/dist/components/custom/index.cjs.map +1 -0
- package/dist/components/custom/index.d.ts +29 -0
- package/dist/components/custom/index.d.ts.map +1 -0
- package/dist/components/custom/index.js +32 -0
- package/dist/components/custom/index.js.map +1 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/internal/SceneWrapper.d.ts +20 -0
- package/dist/components/internal/SceneWrapper.d.ts.map +1 -0
- package/dist/components/primitives/graphics.d.ts +40 -0
- package/dist/components/primitives/graphics.d.ts.map +1 -0
- package/dist/components/primitives/image.d.ts +45 -0
- package/dist/components/primitives/image.d.ts.map +1 -0
- package/dist/components/primitives/nineslice.d.ts +111 -0
- package/dist/components/primitives/nineslice.d.ts.map +1 -0
- package/dist/components/primitives/sprite.d.ts +58 -0
- package/dist/components/primitives/sprite.d.ts.map +1 -0
- package/dist/components/primitives/text.d.ts +26 -0
- package/dist/components/primitives/text.d.ts.map +1 -0
- package/dist/components/primitives/tilesprite.d.ts +47 -0
- package/dist/components/primitives/tilesprite.d.ts.map +1 -0
- package/dist/components/primitives/view.d.ts +23 -0
- package/dist/components/primitives/view.d.ts.map +1 -0
- package/dist/core-props.d.ts +605 -0
- package/dist/core-props.d.ts.map +1 -0
- package/dist/core-types.d.ts +59 -0
- package/dist/core-types.d.ts.map +1 -0
- package/dist/design-tokens/design-token-presets.d.ts +26 -0
- package/dist/design-tokens/design-token-presets.d.ts.map +1 -0
- package/dist/design-tokens/design-token-types.d.ts +109 -0
- package/dist/design-tokens/design-token-types.d.ts.map +1 -0
- package/dist/design-tokens/index.d.ts +8 -0
- package/dist/design-tokens/index.d.ts.map +1 -0
- package/dist/design-tokens/use-theme-tokens.d.ts +28 -0
- package/dist/design-tokens/use-theme-tokens.d.ts.map +1 -0
- package/dist/dev-config.d.ts +238 -0
- package/dist/dev-config.d.ts.map +1 -0
- package/dist/effects/effect-registry.d.ts +54 -0
- package/dist/effects/effect-registry.d.ts.map +1 -0
- package/dist/effects/index.d.ts +56 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/use-effect.d.ts +172 -0
- package/dist/effects/use-effect.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/index.d.ts +7 -0
- package/dist/fx/convenience-hooks/index.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/use-blur.d.ts +21 -0
- package/dist/fx/convenience-hooks/use-blur.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/use-glow.d.ts +21 -0
- package/dist/fx/convenience-hooks/use-glow.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/use-shadow.d.ts +21 -0
- package/dist/fx/convenience-hooks/use-shadow.d.ts.map +1 -0
- package/dist/fx/fx-creators/blur.d.ts +37 -0
- package/dist/fx/fx-creators/blur.d.ts.map +1 -0
- package/dist/fx/fx-creators/color-matrix.d.ts +31 -0
- package/dist/fx/fx-creators/color-matrix.d.ts.map +1 -0
- package/dist/fx/fx-creators/glow.d.ts +36 -0
- package/dist/fx/fx-creators/glow.d.ts.map +1 -0
- package/dist/fx/fx-creators/index.d.ts +10 -0
- package/dist/fx/fx-creators/index.d.ts.map +1 -0
- package/dist/fx/fx-creators/pixelate.d.ts +24 -0
- package/dist/fx/fx-creators/pixelate.d.ts.map +1 -0
- package/dist/fx/fx-creators/shadow.d.ts +43 -0
- package/dist/fx/fx-creators/shadow.d.ts.map +1 -0
- package/dist/fx/fx-creators/vignette.d.ts +33 -0
- package/dist/fx/fx-creators/vignette.d.ts.map +1 -0
- package/dist/fx/fx-registry.d.ts +59 -0
- package/dist/fx/fx-registry.d.ts.map +1 -0
- package/dist/fx/index.d.ts +51 -0
- package/dist/fx/index.d.ts.map +1 -0
- package/dist/fx/use-fx.d.ts +53 -0
- package/dist/fx/use-fx.d.ts.map +1 -0
- package/dist/gestures/gesture-manager.d.ts +149 -0
- package/dist/gestures/gesture-manager.d.ts.map +1 -0
- package/dist/gestures/gesture-types.d.ts +229 -0
- package/dist/gestures/gesture-types.d.ts.map +1 -0
- package/dist/hooks-svg.d.ts +104 -0
- package/dist/hooks-svg.d.ts.map +1 -0
- package/dist/hooks.d.ts +135 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/host.d.ts +74 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/index.cjs +584 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs +10 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +5 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +11 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +43 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.d.ts +25 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +43 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-types.d.ts +33 -0
- package/dist/jsx-types.d.ts.map +1 -0
- package/dist/layout/appliers/background-applier.d.ts +16 -0
- package/dist/layout/appliers/background-applier.d.ts.map +1 -0
- package/dist/layout/appliers/container-applier.d.ts +9 -0
- package/dist/layout/appliers/container-applier.d.ts.map +1 -0
- package/dist/layout/appliers/position-applier.d.ts +8 -0
- package/dist/layout/appliers/position-applier.d.ts.map +1 -0
- package/dist/layout/index.d.ts +22 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/layout-engine-test-utils.d.ts +19 -0
- package/dist/layout/layout-engine-test-utils.d.ts.map +1 -0
- package/dist/layout/layout-engine.d.ts +98 -0
- package/dist/layout/layout-engine.d.ts.map +1 -0
- package/dist/layout/strategies/base-strategy.d.ts +59 -0
- package/dist/layout/strategies/base-strategy.d.ts.map +1 -0
- package/dist/layout/strategies/column-layout.d.ts +38 -0
- package/dist/layout/strategies/column-layout.d.ts.map +1 -0
- package/dist/layout/strategies/row-layout.d.ts +38 -0
- package/dist/layout/strategies/row-layout.d.ts.map +1 -0
- package/dist/layout/strategies/stack-layout.d.ts +30 -0
- package/dist/layout/strategies/stack-layout.d.ts.map +1 -0
- package/dist/layout/types.d.ts +137 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/utils/child-utils.d.ts +74 -0
- package/dist/layout/utils/child-utils.d.ts.map +1 -0
- package/dist/layout/utils/dimension-calculator.d.ts +59 -0
- package/dist/layout/utils/dimension-calculator.d.ts.map +1 -0
- package/dist/layout/utils/flex-distributor.d.ts +18 -0
- package/dist/layout/utils/flex-distributor.d.ts.map +1 -0
- package/dist/layout/utils/size-resolver.d.ts +84 -0
- package/dist/layout/utils/size-resolver.d.ts.map +1 -0
- package/dist/layout/utils/spacing-calculator.d.ts +27 -0
- package/dist/layout/utils/spacing-calculator.d.ts.map +1 -0
- package/dist/memo.d.ts +29 -0
- package/dist/memo.d.ts.map +1 -0
- package/dist/portal/index.d.ts +6 -0
- package/dist/portal/index.d.ts.map +1 -0
- package/dist/portal/portal-registry.d.ts +97 -0
- package/dist/portal/portal-registry.d.ts.map +1 -0
- package/dist/portal/portal-types.d.ts +20 -0
- package/dist/portal/portal-types.d.ts.map +1 -0
- package/dist/render-context.d.ts +118 -0
- package/dist/render-context.d.ts.map +1 -0
- package/dist/scripts/generate-icon-loaders.d.ts +2 -0
- package/dist/scripts/generate-icon-loaders.d.ts.map +1 -0
- package/dist/scripts/generate-icon-loaders.js +195 -0
- package/dist/scripts/generate-icon-types.d.ts +2 -0
- package/dist/scripts/generate-icon-types.d.ts.map +1 -0
- package/dist/scripts/generate-icon-types.js +124 -0
- package/dist/scripts/generate-icons.d.ts +37 -0
- package/dist/scripts/generate-icons.d.ts.map +1 -0
- package/dist/scripts/generate-icons.js +494 -0
- package/dist/scripts/icon-generator-config.d.ts +87 -0
- package/dist/scripts/icon-generator-config.d.ts.map +1 -0
- package/dist/scripts/icon-generator-config.js +6 -0
- package/dist/theme-base.d.ts +116 -0
- package/dist/theme-base.d.ts.map +1 -0
- package/dist/theme-custom.d.ts +262 -0
- package/dist/theme-custom.d.ts.map +1 -0
- package/dist/theme-defaults.d.ts +6 -0
- package/dist/theme-defaults.d.ts.map +1 -0
- package/dist/theme.d.ts +132 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/tooltip/tooltip-types.d.ts +57 -0
- package/dist/tooltip/tooltip-types.d.ts.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/KeyboardInputManager.d.ts +48 -0
- package/dist/utils/KeyboardInputManager.d.ts.map +1 -0
- package/dist/utils/dom-input-manager.d.ts +109 -0
- package/dist/utils/dom-input-manager.d.ts.map +1 -0
- package/dist/utils/svg-texture.d.ts +30 -0
- package/dist/utils/svg-texture.d.ts.map +1 -0
- package/dist/utils/texture-registry.d.ts +49 -0
- package/dist/utils/texture-registry.d.ts.map +1 -0
- package/dist/vdom.d.ts +60 -0
- package/dist/vdom.d.ts.map +1 -0
- package/dist/viewport-context.d.ts +39 -0
- package/dist/viewport-context.d.ts.map +1 -0
- package/dist/vite-plugin-icons.d.ts +29 -0
- package/dist/vite-plugin-icons.d.ts.map +1 -0
- package/dist/vite-plugin-icons.js +95 -0
- package/package.json +117 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Signal } from '@preact/signals-core';
|
|
2
|
+
/**
|
|
3
|
+
* Animated signal that holds a numeric value
|
|
4
|
+
* Can be used in JSX props for direct updates without VDOM
|
|
5
|
+
*/
|
|
6
|
+
export interface AnimatedSignal extends Signal<number> {
|
|
7
|
+
/** Mark as animated signal for VDOM detection */
|
|
8
|
+
__isAnimated: true;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates an animated signal
|
|
12
|
+
* @param initialValue - Initial numeric value
|
|
13
|
+
* @returns Animated signal
|
|
14
|
+
*/
|
|
15
|
+
export declare function animatedSignal(initialValue: number): AnimatedSignal;
|
|
16
|
+
/**
|
|
17
|
+
* Type guard to check if value is an animated signal
|
|
18
|
+
* @param value - Value to check
|
|
19
|
+
* @returns True if value is an animated signal
|
|
20
|
+
*/
|
|
21
|
+
export declare function isAnimatedSignal(value: unknown): value is AnimatedSignal;
|
|
22
|
+
/**
|
|
23
|
+
* Unwraps signal value or returns raw value
|
|
24
|
+
* Type-safe overloads ensure correct return types
|
|
25
|
+
* @param value - Signal or raw value
|
|
26
|
+
* @returns Unwrapped value
|
|
27
|
+
*/
|
|
28
|
+
declare function unwrapSignal(value: AnimatedSignal): number;
|
|
29
|
+
declare function unwrapSignal(value: number): number;
|
|
30
|
+
declare function unwrapSignal(value: string): string;
|
|
31
|
+
declare function unwrapSignal(value: number | AnimatedSignal): number;
|
|
32
|
+
declare function unwrapSignal(value: string | AnimatedSignal): string | number;
|
|
33
|
+
declare function unwrapSignal(value: number | string | AnimatedSignal): number | string;
|
|
34
|
+
export { unwrapSignal };
|
|
35
|
+
//# sourceMappingURL=animated-signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animated-signal.d.ts","sourceRoot":"","sources":["../../src/animation/animated-signal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,CAAC;IACpD,iDAAiD;IACjD,YAAY,EAAE,IAAI,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CAInE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAOxE;AAED;;;;;GAKG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAAA;AACpD,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;AAC5C,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;AAC5C,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,MAAM,CAAA;AAC7D,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,MAAM,GAAG,MAAM,CAAA;AACtE,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,MAAM,GAAG,MAAM,CAAA;AAQ/E,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/animation/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spring physics engine for smooth, natural animations
|
|
3
|
+
* Based on spring-damper system with configurable tension, friction, and mass
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for spring physics behavior
|
|
7
|
+
*/
|
|
8
|
+
export interface SpringConfig {
|
|
9
|
+
/** Spring stiffness (higher = faster, snappier). Default: 170 */
|
|
10
|
+
tension?: number;
|
|
11
|
+
/** Damping force (higher = less oscillation). Default: 26 */
|
|
12
|
+
friction?: number;
|
|
13
|
+
/** Mass of the animated object (higher = slower). Default: 1 */
|
|
14
|
+
mass?: number;
|
|
15
|
+
/** Velocity threshold below which animation stops. Default: 0.01 */
|
|
16
|
+
restVelocity?: number;
|
|
17
|
+
/** Distance threshold below which animation stops. Default: 0.01 */
|
|
18
|
+
restDelta?: number;
|
|
19
|
+
/** Clamp values to prevent overshoot. Default: false */
|
|
20
|
+
clamp?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Spring physics state
|
|
24
|
+
*/
|
|
25
|
+
export interface SpringState {
|
|
26
|
+
/** Current value */
|
|
27
|
+
value: number;
|
|
28
|
+
/** Current velocity */
|
|
29
|
+
velocity: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Default spring configuration (similar to react-spring)
|
|
33
|
+
*/
|
|
34
|
+
export declare const DEFAULT_SPRING_CONFIG: Required<SpringConfig>;
|
|
35
|
+
/**
|
|
36
|
+
* Preset spring configurations for common use cases
|
|
37
|
+
* Note: clamp prevents overshoot but can make animations feel less natural
|
|
38
|
+
* For UI animations, consider enabling clamp to prevent visual artifacts
|
|
39
|
+
*/
|
|
40
|
+
export declare const SPRING_PRESETS: {
|
|
41
|
+
/** Gentle, slow animation */
|
|
42
|
+
readonly gentle: {
|
|
43
|
+
readonly tension: 120;
|
|
44
|
+
readonly friction: 14;
|
|
45
|
+
};
|
|
46
|
+
/** Moderate, balanced animation (default) */
|
|
47
|
+
readonly default: {
|
|
48
|
+
readonly tension: 170;
|
|
49
|
+
readonly friction: 26;
|
|
50
|
+
};
|
|
51
|
+
/** Fast, snappy animation */
|
|
52
|
+
readonly wobbly: {
|
|
53
|
+
readonly tension: 180;
|
|
54
|
+
readonly friction: 12;
|
|
55
|
+
};
|
|
56
|
+
/** Very fast, bouncy animation */
|
|
57
|
+
readonly stiff: {
|
|
58
|
+
readonly tension: 210;
|
|
59
|
+
readonly friction: 20;
|
|
60
|
+
};
|
|
61
|
+
/** Slow, smooth animation */
|
|
62
|
+
readonly slow: {
|
|
63
|
+
readonly tension: 280;
|
|
64
|
+
readonly friction: 60;
|
|
65
|
+
};
|
|
66
|
+
/** Instant, no animation */
|
|
67
|
+
readonly instant: {
|
|
68
|
+
readonly tension: 1000;
|
|
69
|
+
readonly friction: 100;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Type for animation preset keys
|
|
74
|
+
*/
|
|
75
|
+
export type AnimationPreset = keyof typeof SPRING_PRESETS;
|
|
76
|
+
/**
|
|
77
|
+
* Type for animation configuration (preset name or custom config)
|
|
78
|
+
*/
|
|
79
|
+
export type AnimationConfig = AnimationPreset | SpringConfig;
|
|
80
|
+
/**
|
|
81
|
+
* Spring physics engine
|
|
82
|
+
* Implements spring-damper physics for smooth, natural animations
|
|
83
|
+
*/
|
|
84
|
+
export declare class SpringPhysics {
|
|
85
|
+
private config;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a new spring physics engine
|
|
88
|
+
* @param config - Spring configuration
|
|
89
|
+
*/
|
|
90
|
+
constructor(config?: SpringConfig);
|
|
91
|
+
/**
|
|
92
|
+
* Updates spring configuration
|
|
93
|
+
* @param config - Partial config to merge with current
|
|
94
|
+
*/
|
|
95
|
+
updateConfig(config: Partial<SpringConfig>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Performs one physics step
|
|
98
|
+
* Uses semi-implicit Euler integration for stability
|
|
99
|
+
* @param state - Current spring state
|
|
100
|
+
* @param target - Target value
|
|
101
|
+
* @param deltaTime - Time delta in seconds
|
|
102
|
+
* @returns New spring state
|
|
103
|
+
*/
|
|
104
|
+
step(state: SpringState, target: number, deltaTime: number): SpringState;
|
|
105
|
+
/**
|
|
106
|
+
* Checks if spring has reached rest state
|
|
107
|
+
* @param state - Current spring state
|
|
108
|
+
* @param target - Target value
|
|
109
|
+
* @returns True if spring is at rest
|
|
110
|
+
*/
|
|
111
|
+
isAtRest(state: SpringState, target: number): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Snaps spring to target if at rest
|
|
114
|
+
* @param state - Current spring state
|
|
115
|
+
* @param target - Target value
|
|
116
|
+
* @returns Adjusted state (snapped if at rest)
|
|
117
|
+
*/
|
|
118
|
+
snapIfAtRest(state: SpringState, target: number): SpringState;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=spring-physics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring-physics.d.ts","sourceRoot":"","sources":["../../src/animation/spring-physics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,YAAY,CAOxD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc;IACzB,6BAA6B;;;;;IAE7B,6CAA6C;;;;;IAE7C,6BAA6B;;;;;IAE7B,kCAAkC;;;;;IAElC,6BAA6B;;;;;IAE7B,4BAA4B;;;;;CAEpB,CAAA;AAEV;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,cAAc,CAAA;AACzD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,YAAY,CAAA;AAE5D;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAwB;IAEtC;;;OAGG;gBACS,MAAM,GAAE,YAAiB;IAIrC;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAIjD;;;;;;;OAOG;IACH,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW;IA+BxE;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAOrD;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW;CAM9D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { computed } from '@preact/signals-core';
|
|
2
|
+
import { AnimatedSignal } from './animated-signal';
|
|
3
|
+
import { SPRING_PRESETS, SpringConfig } from './spring-physics';
|
|
4
|
+
/**
|
|
5
|
+
* Spring animation hook
|
|
6
|
+
* Creates an animated signal that smoothly transitions to target values
|
|
7
|
+
*
|
|
8
|
+
* @param initialValue - Initial value
|
|
9
|
+
* @param config - Spring configuration or preset name
|
|
10
|
+
* @returns Tuple of [animated signal, setter function]
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // ✓ SAFE - leaf node
|
|
15
|
+
* const [x, setX] = useSpring(0, 'wobbly')
|
|
16
|
+
* <View x={x} width={50} height={50} backgroundColor={0xff0000} />
|
|
17
|
+
*
|
|
18
|
+
* // ✓ SAFE - transform properties
|
|
19
|
+
* const [scale, setScale] = useSpring(1, 'default')
|
|
20
|
+
* <View scale={scale}><Text text="Hello" /></View>
|
|
21
|
+
*
|
|
22
|
+
* // ✗ UNSAFE - container with percentage children
|
|
23
|
+
* const [width, setWidth] = useSpring(200, 'wobbly')
|
|
24
|
+
* <View width={width}><NineSlice width="100%" /></View> // BREAKS!
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useSpring(initialValue: number, config?: SpringConfig | keyof typeof SPRING_PRESETS, onComplete?: () => void): [AnimatedSignal, (target: number | ((prev: number) => number)) => void];
|
|
28
|
+
/**
|
|
29
|
+
* Multi-spring animation hook
|
|
30
|
+
* Creates multiple animated signals that share the same configuration
|
|
31
|
+
* @param initialValues - Object with initial values
|
|
32
|
+
* @param config - Spring configuration or preset name
|
|
33
|
+
* @returns Tuple of [animated signals object, setter function]
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* const [pos, setPos] = useSprings({ x: 0, y: 0 }, 'wobbly')
|
|
38
|
+
* <View x={pos.x} y={pos.y} />
|
|
39
|
+
* setPos({ x: 100, y: 200 })
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function useSprings<T extends Record<string, number>>(initialValues: T, config?: SpringConfig | keyof typeof SPRING_PRESETS): [
|
|
43
|
+
{
|
|
44
|
+
[K in keyof T]: AnimatedSignal;
|
|
45
|
+
},
|
|
46
|
+
(values: Partial<{
|
|
47
|
+
[K in keyof T]: number | ((prev: number) => number);
|
|
48
|
+
}>) => void
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Export presets for convenience
|
|
52
|
+
*/
|
|
53
|
+
export { computed, SPRING_PRESETS };
|
|
54
|
+
//# sourceMappingURL=useSpring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpring.d.ts","sourceRoot":"","sources":["../../src/animation/useSpring.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAe,MAAM,sBAAsB,CAAA;AAI5D,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EACL,cAAc,EAEd,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CACvB,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,OAAO,cAAc,EACnD,UAAU,CAAC,EAAE,MAAM,IAAI,GACtB,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,KAAK,IAAI,CAAC,CAiGzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzD,aAAa,EAAE,CAAC,EAChB,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,OAAO,cAAc,GAClD;IACD;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc;KAAE;IAClC,CAAC,MAAM,EAAE,OAAO,CAAC;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;KAAE,CAAC,KAAK,IAAI;CACnF,CA4GA;AAED;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ColorShade, ColorTokens } from './color-types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a complete color scale from a base color
|
|
4
|
+
* Creates shades from lightest to darkest with DEFAULT pointing to medium
|
|
5
|
+
* @param baseColor - The base color in hex format (e.g., '#2196f3')
|
|
6
|
+
* @returns Complete ColorShade with all semantic levels as HexColor objects
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const primaryScale = generateColorScale('#2196f3')
|
|
10
|
+
* // Usage: colors.primary.medium.toNumber()
|
|
11
|
+
* // DEFAULT also works: colors.primary.DEFAULT.toNumber()
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateColorScale(baseColor: string): ColorShade;
|
|
15
|
+
/**
|
|
16
|
+
* Color preset configuration
|
|
17
|
+
* Defines a complete set of semantic colors for a theme
|
|
18
|
+
*/
|
|
19
|
+
export interface ColorPreset {
|
|
20
|
+
/** Preset name for identification */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Complete color token set */
|
|
23
|
+
colors: ColorTokens;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Ocean Blue Preset
|
|
27
|
+
* Clean, professional blue-based palette
|
|
28
|
+
*/
|
|
29
|
+
export declare const oceanBluePreset: ColorPreset;
|
|
30
|
+
/**
|
|
31
|
+
* Forest Green Preset
|
|
32
|
+
* Nature-inspired green-based palette
|
|
33
|
+
*/
|
|
34
|
+
export declare const forestGreenPreset: ColorPreset;
|
|
35
|
+
/**
|
|
36
|
+
* Midnight Preset
|
|
37
|
+
* Dark, elegant purple-based palette
|
|
38
|
+
*/
|
|
39
|
+
export declare const midnightPreset: ColorPreset;
|
|
40
|
+
/**
|
|
41
|
+
* Apply light mode overrides to a preset
|
|
42
|
+
* Adjusts neutral colors for optimal light mode appearance
|
|
43
|
+
* @param preset - Base preset to modify
|
|
44
|
+
* @returns New preset with light mode neutral colors
|
|
45
|
+
*/
|
|
46
|
+
export declare function applyLightMode(preset: ColorPreset): ColorPreset;
|
|
47
|
+
/**
|
|
48
|
+
* Apply dark mode overrides to a preset
|
|
49
|
+
* Adjusts neutral colors for optimal dark mode appearance
|
|
50
|
+
* @param preset - Base preset to modify
|
|
51
|
+
* @returns New preset with dark mode neutral colors
|
|
52
|
+
*/
|
|
53
|
+
export declare function applyDarkMode(preset: ColorPreset): ColorPreset;
|
|
54
|
+
/**
|
|
55
|
+
* All available presets
|
|
56
|
+
*/
|
|
57
|
+
export declare const presets: {
|
|
58
|
+
readonly oceanBlue: ColorPreset;
|
|
59
|
+
readonly forestGreen: ColorPreset;
|
|
60
|
+
readonly midnight: ColorPreset;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Preset names for type safety
|
|
64
|
+
*/
|
|
65
|
+
export type PresetName = keyof typeof presets;
|
|
66
|
+
/**
|
|
67
|
+
* Get a preset by name
|
|
68
|
+
* @param name - Preset name
|
|
69
|
+
* @returns Color preset
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const preset = getPreset('oceanBlue')
|
|
73
|
+
* const primaryColor = preset.colors.primary.DEFAULT
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function getPreset(name: PresetName): ColorPreset;
|
|
77
|
+
/**
|
|
78
|
+
* Get a preset with color mode applied
|
|
79
|
+
* @param name - Preset name
|
|
80
|
+
* @param mode - Color mode ('light' or 'dark')
|
|
81
|
+
* @returns Color preset with mode-specific neutral colors
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const darkPreset = getPresetWithMode('oceanBlue', 'dark')
|
|
85
|
+
* const bgColor = darkPreset.colors.background.DEFAULT
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function getPresetWithMode(name: PresetName, mode: 'light' | 'dark'): ColorPreset;
|
|
89
|
+
//# sourceMappingURL=color-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-presets.d.ts","sourceRoot":"","sources":["../../src/colors/color-presets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAyB3E;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAQhE;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,MAAM,EAAE,WAAW,CAAA;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,WA4C7B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,WA4C/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,WA4C5B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAmC/D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAmC9D;AAED;;GAEG;AACH,eAAO,MAAM,OAAO;;;;CAIV,CAAA;AAEV;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,OAAO,CAAA;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,CAEvD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,WAAW,CAGvF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ColorTokens } from './color-types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert ColorTokens to a theme-compatible object
|
|
4
|
+
* Maps semantic color names to Phaser number format for View/Button components
|
|
5
|
+
* @param colors - ColorTokens to convert
|
|
6
|
+
* @returns Object with backgroundColor, borderColor, etc.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const colors = getPreset('oceanBlue').colors
|
|
10
|
+
* const buttonTheme = {
|
|
11
|
+
* ...colorsToTheme(colors, 'primary'),
|
|
12
|
+
* padding: 8,
|
|
13
|
+
* }
|
|
14
|
+
* // Returns: { backgroundColor: 0x2196f3, borderColor: 0x... }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function colorsToTheme(colors: ColorTokens, colorKey: keyof Pick<ColorTokens, 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'error' | 'info'>, options?: {
|
|
18
|
+
/** Which shade to use for background (default: 'DEFAULT') */
|
|
19
|
+
backgroundShade?: 'lightest' | 'light' | 'medium' | 'dark' | 'darkest' | 'DEFAULT';
|
|
20
|
+
/** Which shade to use for border (default: 'dark') */
|
|
21
|
+
borderShade?: 'lightest' | 'light' | 'medium' | 'dark' | 'darkest' | 'DEFAULT';
|
|
22
|
+
/** Include border color (default: true) */
|
|
23
|
+
includeBorder?: boolean;
|
|
24
|
+
}): {
|
|
25
|
+
backgroundColor: number;
|
|
26
|
+
borderColor?: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Get text color from ColorTokens as hex string for Phaser Text style
|
|
30
|
+
* @param colors - ColorTokens to use
|
|
31
|
+
* @param shade - Which text shade to use (default: 'DEFAULT')
|
|
32
|
+
* @param alphaValue - Optional alpha value (0-1)
|
|
33
|
+
* @returns Hex string or rgba string for Text style
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const colors = getPreset('oceanBlue').colors
|
|
37
|
+
* const textStyle = {
|
|
38
|
+
* color: getTextColor(colors),
|
|
39
|
+
* fontSize: '18px'
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function getTextColor(colors: ColorTokens, shade?: 'lightest' | 'light' | 'medium' | 'dark' | 'darkest' | 'DEFAULT', alphaValue?: number): string;
|
|
44
|
+
/**
|
|
45
|
+
* Get background color from ColorTokens
|
|
46
|
+
* @param colors - ColorTokens to use
|
|
47
|
+
* @param shade - Which shade to use (default: 'DEFAULT')
|
|
48
|
+
* @returns Phaser color number
|
|
49
|
+
*/
|
|
50
|
+
export declare function getBackgroundColor(colors: ColorTokens, shade?: 'lightest' | 'light' | 'medium' | 'dark' | 'darkest' | 'DEFAULT'): number;
|
|
51
|
+
/**
|
|
52
|
+
* Get surface color from ColorTokens
|
|
53
|
+
* @param colors - ColorTokens to use
|
|
54
|
+
* @param shade - Which shade to use (default: 'DEFAULT')
|
|
55
|
+
* @returns Phaser color number
|
|
56
|
+
*/
|
|
57
|
+
export declare function getSurfaceColor(colors: ColorTokens, shade?: 'lightest' | 'light' | 'medium' | 'dark' | 'darkest' | 'DEFAULT'): number;
|
|
58
|
+
/**
|
|
59
|
+
* Get border color from ColorTokens
|
|
60
|
+
* @param colors - ColorTokens to use
|
|
61
|
+
* @param shade - Which shade to use (default: 'DEFAULT')
|
|
62
|
+
* @returns Phaser color number
|
|
63
|
+
*/
|
|
64
|
+
export declare function getBorderColor(colors: ColorTokens, shade?: 'lightest' | 'light' | 'medium' | 'dark' | 'darkest' | 'DEFAULT'): number;
|
|
65
|
+
//# sourceMappingURL=color-theme-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-theme-helpers.d.ts","sourceRoot":"","sources":["../../src/colors/color-theme-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,IAAI,CAClB,WAAW,EACX,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAC9E,EACD,OAAO,GAAE;IACP,6DAA6D;IAC7D,eAAe,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;IAClF,sDAAsD;IACtD,WAAW,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;IAC9E,2CAA2C;IAC3C,aAAa,CAAC,EAAE,OAAO,CAAA;CACnB,GACL;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAYA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,EACnB,KAAK,GAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAqB,EACnF,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EACnB,KAAK,GAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAqB,GAClF,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,KAAK,GAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAqB,GAClF,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,KAAK,GAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAqB,GAClF,MAAM,CAER"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color system types for PhaserJSX UI
|
|
3
|
+
* Provides semantic color tokens with named shade levels
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Named shade levels for color scales
|
|
7
|
+
* Uses semantic names instead of numeric values
|
|
8
|
+
*/
|
|
9
|
+
export type ShadeLevel = 'lightest' | 'light' | 'medium' | 'dark' | 'darkest';
|
|
10
|
+
/**
|
|
11
|
+
* Hex color string with conversion method
|
|
12
|
+
* Extends string but adds toNumber() for Phaser compatibility
|
|
13
|
+
*/
|
|
14
|
+
export declare class HexColor extends String {
|
|
15
|
+
/**
|
|
16
|
+
* Convert to Phaser number format
|
|
17
|
+
* @returns Color as number (0xffffff)
|
|
18
|
+
*/
|
|
19
|
+
toNumber(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Create a HexColor from a hex string
|
|
22
|
+
* @param hex - Hex color string
|
|
23
|
+
*/
|
|
24
|
+
static from(hex: string): HexColor;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Color shade scale with semantic naming
|
|
28
|
+
* Each color token has multiple shades for different use cases
|
|
29
|
+
* Uses HexColor type for VS Code color picker support and .toNumber() method
|
|
30
|
+
* DEFAULT is computed property pointing to medium (not in interface)
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const primaryShade: ColorShade = {
|
|
34
|
+
* lightest: HexColor.from('#e3f2fd'),
|
|
35
|
+
* light: HexColor.from('#90caf9'),
|
|
36
|
+
* medium: HexColor.from('#42a5f5'),
|
|
37
|
+
* dark: HexColor.from('#1976d2'),
|
|
38
|
+
* darkest: HexColor.from('#0d47a1'),
|
|
39
|
+
* }
|
|
40
|
+
* // DEFAULT is available via getter:
|
|
41
|
+
* backgroundColor: colors.primary.DEFAULT.toNumber() // returns medium
|
|
42
|
+
* // Direct usage:
|
|
43
|
+
* backgroundColor: colors.primary.medium.toNumber()
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export interface ColorShade {
|
|
47
|
+
/** Lightest shade - backgrounds, hover states */
|
|
48
|
+
lightest: HexColor;
|
|
49
|
+
/** Light shade - secondary elements */
|
|
50
|
+
light: HexColor;
|
|
51
|
+
/** Medium shade - interactive elements (also available as DEFAULT) */
|
|
52
|
+
medium: HexColor;
|
|
53
|
+
/** Dark shade - borders, dividers */
|
|
54
|
+
dark: HexColor;
|
|
55
|
+
/** Darkest shade - text, emphasis */
|
|
56
|
+
darkest: HexColor;
|
|
57
|
+
/** DEFAULT shade - computed property that points to medium */
|
|
58
|
+
readonly DEFAULT: HexColor;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Complete color token system with semantic color categories
|
|
62
|
+
* Designed for global theme usage with nested theme support
|
|
63
|
+
*/
|
|
64
|
+
export interface ColorTokens {
|
|
65
|
+
/** Primary brand color - main actions and emphasis */
|
|
66
|
+
primary: ColorShade;
|
|
67
|
+
/** Secondary brand color - supporting actions */
|
|
68
|
+
secondary: ColorShade;
|
|
69
|
+
/** Accent color - highlights and special elements */
|
|
70
|
+
accent: ColorShade;
|
|
71
|
+
/** Success state color - confirmations, positive feedback */
|
|
72
|
+
success: ColorShade;
|
|
73
|
+
/** Warning state color - cautions, alerts */
|
|
74
|
+
warning: ColorShade;
|
|
75
|
+
/** Error state color - errors, destructive actions */
|
|
76
|
+
error: ColorShade;
|
|
77
|
+
/** Info state color - informational messages */
|
|
78
|
+
info: ColorShade;
|
|
79
|
+
/** Background colors - main app backgrounds */
|
|
80
|
+
background: ColorShade;
|
|
81
|
+
/** Surface colors - cards, panels, elevated elements */
|
|
82
|
+
surface: ColorShade;
|
|
83
|
+
/** Text colors - typography hierarchy */
|
|
84
|
+
text: ColorShade;
|
|
85
|
+
/** Border colors - dividers, outlines */
|
|
86
|
+
border: ColorShade;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Color mode enum for light/dark theme switching
|
|
90
|
+
*/
|
|
91
|
+
export type ColorMode = 'light' | 'dark';
|
|
92
|
+
/**
|
|
93
|
+
* RGB color representation
|
|
94
|
+
*/
|
|
95
|
+
export interface RGBColor {
|
|
96
|
+
r: number;
|
|
97
|
+
g: number;
|
|
98
|
+
b: number;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=color-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-types.d.ts","sourceRoot":"","sources":["../../src/colors/color-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAA;AAE7E;;;GAGG;AACH,qBAAa,QAAS,SAAQ,MAAM;IAClC;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAKlB;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;CAGnC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,QAAQ,EAAE,QAAQ,CAAA;IAClB,uCAAuC;IACvC,KAAK,EAAE,QAAQ,CAAA;IACf,sEAAsE;IACtE,MAAM,EAAE,QAAQ,CAAA;IAChB,qCAAqC;IACrC,IAAI,EAAE,QAAQ,CAAA;IACd,qCAAqC;IACrC,OAAO,EAAE,QAAQ,CAAA;IACjB,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,OAAO,EAAE,UAAU,CAAA;IACnB,iDAAiD;IACjD,SAAS,EAAE,UAAU,CAAA;IACrB,qDAAqD;IACrD,MAAM,EAAE,UAAU,CAAA;IAElB,6DAA6D;IAC7D,OAAO,EAAE,UAAU,CAAA;IACnB,6CAA6C;IAC7C,OAAO,EAAE,UAAU,CAAA;IACnB,sDAAsD;IACtD,KAAK,EAAE,UAAU,CAAA;IACjB,gDAAgD;IAChD,IAAI,EAAE,UAAU,CAAA;IAEhB,+CAA+C;IAC/C,UAAU,EAAE,UAAU,CAAA;IACtB,wDAAwD;IACxD,OAAO,EAAE,UAAU,CAAA;IACnB,yCAAyC;IACzC,IAAI,EAAE,UAAU,CAAA;IAChB,yCAAyC;IACzC,MAAM,EAAE,UAAU,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;AAExC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { TextStyleToken } from '../design-tokens';
|
|
2
|
+
import { HexColor, RGBColor } from './color-types';
|
|
3
|
+
/**
|
|
4
|
+
* Convert hex string to Phaser number format
|
|
5
|
+
* @param hex - Hex color string (e.g., '#ffffff' or 'ffffff')
|
|
6
|
+
* @returns Phaser color number (e.g., 0xffffff)
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* hexToNumber('#ff0000') // returns 0xff0000
|
|
10
|
+
* hexToNumber('00ff00') // returns 0x00ff00
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function hexToNumber(hex: string): number;
|
|
14
|
+
/**
|
|
15
|
+
* Convert Phaser number format to hex string
|
|
16
|
+
* @param num - Phaser color number (e.g., 0xffffff)
|
|
17
|
+
* @param withHash - Include '#' prefix (default: true)
|
|
18
|
+
* @returns Hex color string (e.g., '#ffffff')
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* numberToHex(0xff0000) // returns '#ff0000'
|
|
22
|
+
* numberToHex(0x00ff00, false) // returns '00ff00'
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function numberToHex(num: number, withHash?: boolean): string;
|
|
26
|
+
/**
|
|
27
|
+
* Convert RGB values to Phaser number format
|
|
28
|
+
* @param r - Red component (0-255)
|
|
29
|
+
* @param g - Green component (0-255)
|
|
30
|
+
* @param b - Blue component (0-255)
|
|
31
|
+
* @returns Phaser color number
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* rgbToNumber(255, 0, 0) // returns 0xff0000 (red)
|
|
35
|
+
* rgbToNumber(0, 255, 0) // returns 0x00ff00 (green)
|
|
36
|
+
* rgbToNumber(255, 255, 255) // returns 0xffffff (white)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function rgbToNumber(r: number, g: number, b: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Convert Phaser number to RGB components
|
|
42
|
+
* @param num - Phaser color number
|
|
43
|
+
* @returns RGB color object
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* numberToRgb(0xff0000) // returns { r: 255, g: 0, b: 0 }
|
|
47
|
+
* numberToRgb(0x00ff00) // returns { r: 0, g: 255, b: 0 }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function numberToRgb(num: number): RGBColor;
|
|
51
|
+
/**
|
|
52
|
+
* Lighten a color by a given amount
|
|
53
|
+
* @param color - Phaser color number
|
|
54
|
+
* @param amount - Amount to lighten (0.0 to 1.0, where 1.0 is white)
|
|
55
|
+
* @returns Lightened color number
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* lighten(0x0000ff, 0.3) // returns lighter blue
|
|
59
|
+
* lighten(0xff0000, 0.5) // returns light red/pink
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function lighten(color: number, amount: number): number;
|
|
63
|
+
/**
|
|
64
|
+
* Darken a color by a given amount
|
|
65
|
+
* @param color - Phaser color number
|
|
66
|
+
* @param amount - Amount to darken (0.0 to 1.0, where 1.0 is black)
|
|
67
|
+
* @returns Darkened color number
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* darken(0x0000ff, 0.3) // returns darker blue
|
|
71
|
+
* darken(0xff0000, 0.5) // returns dark red
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function darken(color: number, amount: number): number;
|
|
75
|
+
/**
|
|
76
|
+
* Lighten a hex color by a given amount
|
|
77
|
+
* @param hex - Hex color (e.g., '#ffffff' or 'ffffff')
|
|
78
|
+
* @param amount - Amount to lighten (0.0 to 1.0, where 1.0 is white)
|
|
79
|
+
* @returns Lightened hex color string with '#' prefix
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* lightenHex('#0000ff', 0.3) // returns lighter blue
|
|
83
|
+
* lightenHex('#ff0000', 0.5) // returns light red/pink
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function lightenHex(hex: string, amount: number): HexColor;
|
|
87
|
+
/**
|
|
88
|
+
* Darken a hex color by a given amount
|
|
89
|
+
* @param hex - Hex color (e.g., '#ffffff' or 'ffffff')
|
|
90
|
+
* @param amount - Amount to darken (0.0 to 1.0, where 1.0 is black)
|
|
91
|
+
* @returns Darkened hex color string with '#' prefix
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* darkenHex('#0000ff', 0.3) // returns darker blue
|
|
95
|
+
* darkenHex('#ff0000', 0.5) // returns dark red
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function darkenHex(hex: string, amount: number): HexColor;
|
|
99
|
+
/**
|
|
100
|
+
* Hex color wrapper with chainable conversion methods
|
|
101
|
+
* Provides fluent API for color conversions
|
|
102
|
+
*/
|
|
103
|
+
export interface HexColorWrapper {
|
|
104
|
+
/** Original hex string value */
|
|
105
|
+
value: string;
|
|
106
|
+
/** Convert to Phaser number format */
|
|
107
|
+
toNumber: () => number;
|
|
108
|
+
/** Convert to string (returns hex) */
|
|
109
|
+
toString: () => string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a hex color wrapper with chainable methods
|
|
113
|
+
* @param hex - Hex color string
|
|
114
|
+
* @returns Wrapper object with conversion methods
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const color = hex('#ff0000')
|
|
118
|
+
* color.toNumber() // 0xff0000
|
|
119
|
+
* color.toString() // '#ff0000'
|
|
120
|
+
*
|
|
121
|
+
* // Direct usage:
|
|
122
|
+
* backgroundColor: hex(colors.primary.DEFAULT).toNumber()
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function hex(hexColor: string): HexColorWrapper;
|
|
126
|
+
/**
|
|
127
|
+
* Convert color to rgba string for Phaser Text style
|
|
128
|
+
* @param color - Phaser color number
|
|
129
|
+
* @param alphaValue - Alpha value (0.0 to 1.0, default: 1.0)
|
|
130
|
+
* @returns RGBA string usable in Text style (e.g., 'rgba(255, 0, 0, 0.5)')
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* alpha(0xff0000, 1.0) // returns 'rgba(255, 0, 0, 1)'
|
|
134
|
+
* alpha(0x00ff00, 0.5) // returns 'rgba(0, 255, 0, 0.5)'
|
|
135
|
+
* alpha(0x0000ff) // returns 'rgba(0, 0, 255, 1)'
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare function alpha(color: number, alphaValue?: number): string;
|
|
139
|
+
/**
|
|
140
|
+
* Calculate contrast ratio between two colors (WCAG 2.0)
|
|
141
|
+
* @param foreground - Foreground color (e.g., text)
|
|
142
|
+
* @param background - Background color
|
|
143
|
+
* @returns Contrast ratio (1 to 21)
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* getContrastRatio(0x000000, 0xffffff) // returns 21 (black on white)
|
|
147
|
+
* getContrastRatio(0xffffff, 0xffffff) // returns 1 (white on white)
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function getContrastRatio(foreground: number, background: number): number;
|
|
151
|
+
/**
|
|
152
|
+
* Ensure minimum contrast ratio by adjusting foreground color
|
|
153
|
+
* @param foreground - Foreground color to adjust
|
|
154
|
+
* @param background - Background color (fixed)
|
|
155
|
+
* @param minRatio - Minimum contrast ratio (default: 4.5 for WCAG AA)
|
|
156
|
+
* @returns Adjusted foreground color meeting contrast requirements
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* // Ensure text is readable on background
|
|
160
|
+
* const textColor = ensureContrast(0x888888, 0xffffff, 4.5)
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function ensureContrast(foreground: number, background: number, minRatio?: number): number;
|
|
164
|
+
/**
|
|
165
|
+
* Create a TextStyleToken by merging base style with overrides to ensure required properties are set
|
|
166
|
+
* @param baseStyle
|
|
167
|
+
* @param overrides
|
|
168
|
+
* @returns
|
|
169
|
+
*/
|
|
170
|
+
export declare function createTextStyle(baseStyle: Partial<TextStyleToken> | undefined, overrides: Partial<TextStyleToken>): TextStyleToken;
|
|
171
|
+
//# sourceMappingURL=color-utils.d.ts.map
|