gospelo-iconcraft-react 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,21 @@ npm install gospelo-iconcraft-react
10
10
 
11
11
  ## Quick Start
12
12
 
13
+ ### Factory Pattern (Recommended)
14
+
15
+ ```tsx
16
+ import { IconCraftFactory, IconCraftView } from 'gospelo-iconcraft-react';
17
+
18
+ const factory = new IconCraftFactory({ mode: 'wax', shapeColor: '#6366f1' });
19
+ const icon = factory.create('<svg>...</svg>');
20
+
21
+ function App() {
22
+ return <IconCraftView instance={icon} />;
23
+ }
24
+ ```
25
+
26
+ ### Simple Usage
27
+
13
28
  ```tsx
14
29
  import { IconCraftShape } from 'gospelo-iconcraft-react';
15
30
 
@@ -26,9 +41,106 @@ function App() {
26
41
 
27
42
  ## Components
28
43
 
29
- ### `<IconCraftShape>` (Recommended)
44
+ ### `<IconCraftView>` (Recommended)
30
45
 
31
- Modern component with full feature support.
46
+ Instance-based component with rotation dial, reticle, and animation support. Works with `IconCraftFactory` / `IconCraftInstance`.
47
+
48
+ ```tsx
49
+ import { IconCraftFactory, IconCraftView } from 'gospelo-iconcraft-react';
50
+
51
+ const factory = new IconCraftFactory({
52
+ mode: 'jelly',
53
+ shapeColor: '#10b981',
54
+ size: 120,
55
+ });
56
+
57
+ const icon = factory.create('<svg>...</svg>');
58
+
59
+ <IconCraftView
60
+ instance={icon}
61
+ animation="bounce"
62
+ showRotationDial
63
+ onRotationChange={(deg) => console.log(deg)}
64
+ dialPreset={dialPresetDotted}
65
+ showReticle
66
+ reticlePreset={reticlePresetCross}
67
+ />
68
+ ```
69
+
70
+ #### Props
71
+
72
+ | Prop | Type | Default | Description |
73
+ |------|------|---------|-------------|
74
+ | `instance` | `IconCraftInstance` | required | Icon instance from factory |
75
+ | `animation` | `AnimationType \| AnimationOptions` | - | Animation preset or config |
76
+ | `animationTarget` | `'shape' \| 'icon' \| 'both'` | `'both'` | Animation target |
77
+ | `animateOnHover` | `boolean` | `false` | Trigger animation on hover |
78
+ | `showRotationDial` | `boolean` | `false` | Show rotation dial overlay |
79
+ | `onRotationChange` | `(deg: number) => void` | - | Rotation change callback |
80
+ | `rotationSnap` | `number` | `5` | Snap angle in degrees |
81
+ | `dialPreset` | `DialPreset` | `dialPresetDotted` | Dial visual preset |
82
+ | `showReticle` | `boolean` | `false` | Show center reticle |
83
+ | `reticlePreset` | `ReticlePreset` | - | Reticle visual preset |
84
+ | `renderRing` | `(props: DialRingProps) => ReactNode` | - | Custom ring renderer |
85
+ | `renderNotch` | `(props: DialNotchProps) => ReactNode` | - | Custom notch renderer |
86
+ | `renderLabel` | `(props: DialLabelProps) => ReactNode` | - | Custom label renderer |
87
+ | `renderReticle` | `(props: ReticleProps) => ReactNode` | - | Custom reticle renderer |
88
+ | `zIndex` | `number` | - | Z-index for layering |
89
+ | `className` | `string` | - | CSS class |
90
+ | `style` | `CSSProperties` | - | Inline styles |
91
+ | `onClick` | `() => void` | - | Click handler |
92
+
93
+ ### Dial Presets
94
+
95
+ 10 built-in dial presets for the rotation dial appearance:
96
+
97
+ ```tsx
98
+ import { dialPresets, dialPresetDotted } from 'gospelo-iconcraft-react';
99
+
100
+ // Use by name
101
+ <IconCraftView instance={icon} showRotationDial dialPreset={dialPresets.dotted} />
102
+
103
+ // Available presets
104
+ // dialPresets.dotted - Dotted circle ring (default)
105
+ // dialPresets.dashed - Dashed circle ring
106
+ // dialPresets.solid - Solid circle ring
107
+ // dialPresets.ticks - Tick marks around the ring
108
+ // dialPresets.double - Double circle ring
109
+ // dialPresets.crosshair - Crosshair style
110
+ // dialPresets.minimal - Minimal style
111
+ // dialPresets.needle - Needle indicator
112
+ // dialPresets.bar - Bar indicator
113
+ // dialPresets.arrow - Arrow indicator
114
+ ```
115
+
116
+ ### Reticle Presets
117
+
118
+ 3 built-in reticle presets for center overlay:
119
+
120
+ ```tsx
121
+ import { reticlePresets, reticlePresetCross } from 'gospelo-iconcraft-react';
122
+
123
+ <IconCraftView instance={icon} showReticle reticlePreset={reticlePresets.cross} />
124
+
125
+ // Available presets
126
+ // reticlePresets.cross - Crosshair reticle
127
+ // reticlePresets.bullseye - Bullseye target reticle
128
+ // reticlePresets.globe - Globe/sphere reticle
129
+ ```
130
+
131
+ ### CSS Variables
132
+
133
+ The dial and reticle color can be customized via CSS variable:
134
+
135
+ ```css
136
+ :root {
137
+ --iconcraft-dial-color: #0071e3; /* default */
138
+ }
139
+ ```
140
+
141
+ ### `<IconCraftShape>`
142
+
143
+ Standalone component with full feature support (no factory needed).
32
144
 
33
145
  ```tsx
34
146
  import { IconCraftShape } from 'gospelo-iconcraft-react';
@@ -58,6 +170,7 @@ import { IconCraftShape } from 'gospelo-iconcraft-react';
58
170
  | `height` | `number \| string` | - | Height |
59
171
  | `shadow` | `boolean` | `true` | Show drop shadow |
60
172
  | `highlight` | `boolean` | `true` | Show highlight effect |
173
+ | `rotation` | `number` | `0` | Icon rotation in degrees (0-360). Shape follows rotated icon. |
61
174
  | `animation` | `AnimationType \| AnimationOptions` | - | Animation preset or config |
62
175
  | `animateOnHover` | `boolean` | `false` | Trigger animation on hover |
63
176
  | `offset` | `number` | `20` | Contour offset |
@@ -69,18 +182,26 @@ import { IconCraftShape } from 'gospelo-iconcraft-react';
69
182
  | `onError` | `(error) => void` | - | Called on error |
70
183
  | `onClick` | `() => void` | - | Click handler |
71
184
 
72
- ### `<IconCraft>` (Legacy)
185
+ ## Factory Pattern
73
186
 
74
- Original component for backwards compatibility.
187
+ `IconCraftFactory` creates reusable `IconCraftInstance` objects with shared configuration:
75
188
 
76
189
  ```tsx
77
- import { IconCraft } from 'gospelo-iconcraft-react';
190
+ import { IconCraftFactory } from 'gospelo-iconcraft-react';
78
191
 
79
- <IconCraft
80
- svgContent="<svg>...</svg>"
81
- mode="wax"
82
- baseColor="#6366f1"
83
- />
192
+ const factory = new IconCraftFactory({
193
+ mode: 'wax',
194
+ shapeColor: '#6366f1',
195
+ iconStyle: 'emboss',
196
+ size: 100,
197
+ });
198
+
199
+ // Create multiple icons with same config
200
+ const icon1 = factory.create('<svg>...</svg>');
201
+ const icon2 = factory.create('<svg>...</svg>');
202
+
203
+ // Update config after creation
204
+ icon1.config.update({ shapeColor: '#10b981', rotation: 45 });
84
205
  ```
85
206
 
86
207
  ## Shape Modes
@@ -243,6 +364,15 @@ import type {
243
364
  AnimationOptions,
244
365
  IconCraftResult,
245
366
  IconCraftShapeProps,
367
+ IconCraftViewProps,
368
+ DialPreset,
369
+ DialPresetName,
370
+ ReticlePreset,
371
+ ReticlePresetName,
372
+ DialRingProps,
373
+ DialNotchProps,
374
+ DialLabelProps,
375
+ ReticleProps,
246
376
  } from 'gospelo-iconcraft-react';
247
377
  ```
248
378
 
package/dist/index.d.ts CHANGED
@@ -88,6 +88,7 @@ interface IconCraftResult {
88
88
  svg_paths: SvgPaths | null;
89
89
  emboss_svg: string | null;
90
90
  icon_paths: EmbossIconData | null;
91
+ rotation: number;
91
92
  }
92
93
  interface IconCraftShapeProps {
93
94
  /** SVG content string or URL */
@@ -104,6 +105,8 @@ interface IconCraftShapeProps {
104
105
  shadow?: boolean;
105
106
  /** Show highlight effect */
106
107
  highlight?: boolean;
108
+ /** Icon rotation in degrees (0-360). Applied at WASM level so shape follows rotated icon. */
109
+ rotation?: number;
107
110
  /** Contour offset (default: 20) */
108
111
  offset?: number;
109
112
  /** Rasterization resolution (default: 256) */
@@ -157,6 +160,7 @@ interface IconCraftConfigOptions {
157
160
  offset?: number;
158
161
  resolution?: number;
159
162
  simplify?: number;
163
+ rotation?: number;
160
164
  size?: number | string;
161
165
  width?: number | string;
162
166
  height?: number | string;
@@ -182,6 +186,7 @@ declare class IconCraftConfig {
182
186
  readonly offset: number;
183
187
  readonly resolution: number;
184
188
  readonly simplify: number;
189
+ readonly rotation: number;
185
190
  readonly size: number | string;
186
191
  readonly width?: number | string;
187
192
  readonly height?: number | string;
@@ -202,6 +207,7 @@ declare class IconCraftConfig {
202
207
  simplify: number;
203
208
  includeIcon: boolean;
204
209
  shapeColor: string;
210
+ rotation: number;
205
211
  };
206
212
  /**
207
213
  * スタイル用のサイズを取得
@@ -328,6 +334,7 @@ interface WasmGenerateParams {
328
334
  simplify: number;
329
335
  includeIcon: boolean;
330
336
  shapeColor: string;
337
+ rotation?: number;
331
338
  }
332
339
  /**
333
340
  * WASMマネージャー(Singleton)
@@ -446,6 +453,70 @@ declare class IconCraftRegistry {
446
453
  */
447
454
  declare const globalRegistry: IconCraftRegistry;
448
455
 
456
+ /**
457
+ * Dial preset definition
458
+ */
459
+ interface DialPreset {
460
+ name: string;
461
+ renderRing: (props: DialRingProps) => React.ReactNode;
462
+ renderNotch: (props: DialNotchProps) => React.ReactNode;
463
+ renderLabel?: (props: DialLabelProps) => React.ReactNode;
464
+ }
465
+ /** Default: dashed ring with circle notch */
466
+ declare const dialPresetDashed: DialPreset;
467
+ /** Solid thin ring with diamond notch */
468
+ declare const dialPresetSolid: DialPreset;
469
+ /** Tick marks ring with arrow notch */
470
+ declare const dialPresetTicks: DialPreset;
471
+ /** Dotted ring with square notch */
472
+ declare const dialPresetDotted: DialPreset;
473
+ /** Double ring with pill-shaped notch */
474
+ declare const dialPresetDouble: DialPreset;
475
+ /** Crosshair style with + shaped notch */
476
+ declare const dialPresetCrosshair: DialPreset;
477
+ /** Minimal: only quarter arcs with triangle notch */
478
+ declare const dialPresetMinimal: DialPreset;
479
+ /** Needle: dashed ring with elongated needle notch */
480
+ declare const dialPresetNeedle: DialPreset;
481
+ /** Bar: solid ring with rounded bar notch */
482
+ declare const dialPresetBar: DialPreset;
483
+ /** Arrow: tick ring with arrow-head notch */
484
+ declare const dialPresetArrow: DialPreset;
485
+ /** All presets for easy iteration */
486
+ declare const dialPresets: {
487
+ readonly dotted: DialPreset;
488
+ readonly dashed: DialPreset;
489
+ readonly solid: DialPreset;
490
+ readonly ticks: DialPreset;
491
+ readonly double: DialPreset;
492
+ readonly crosshair: DialPreset;
493
+ readonly minimal: DialPreset;
494
+ readonly needle: DialPreset;
495
+ readonly bar: DialPreset;
496
+ readonly arrow: DialPreset;
497
+ };
498
+ type DialPresetName = keyof typeof dialPresets;
499
+ /**
500
+ * Reticle preset definition
501
+ */
502
+ interface ReticlePreset {
503
+ name: string;
504
+ render: (props: ReticleProps) => React.ReactNode;
505
+ }
506
+ /** Cross: back=bottom+right arms, front=top+left arms + center dot */
507
+ declare const reticlePresetCross: ReticlePreset;
508
+ /** Bullseye: circle + center dot */
509
+ declare const reticlePresetBullseye: ReticlePreset;
510
+ /** Globe: wireframe sphere — all lines split into back (far side) and front (near side) */
511
+ declare const reticlePresetGlobe: ReticlePreset;
512
+ /** All reticle presets */
513
+ declare const reticlePresets: {
514
+ readonly cross: ReticlePreset;
515
+ readonly bullseye: ReticlePreset;
516
+ readonly globe: ReticlePreset;
517
+ };
518
+ type ReticlePresetName = keyof typeof reticlePresets;
519
+
449
520
  interface IconCraftViewProps {
450
521
  /** IconCraftInstance */
451
522
  instance: IconCraftInstance;
@@ -472,6 +543,54 @@ interface IconCraftViewProps {
472
543
  onLoad?: () => void;
473
544
  /** Error callback */
474
545
  onError?: (error: string) => void;
546
+ /** Show rotation dial overlay */
547
+ showRotationDial?: boolean;
548
+ /** Rotation change callback (called on mouseup with final degree) */
549
+ onRotationChange?: (deg: number) => void;
550
+ /** Snap angle in degrees (default: 5) */
551
+ rotationSnap?: number;
552
+ /** Custom ring SVG renderer */
553
+ renderRing?: (props: DialRingProps) => React.ReactNode;
554
+ /** Custom notch SVG renderer */
555
+ renderNotch?: (props: DialNotchProps) => React.ReactNode;
556
+ /** Custom label SVG renderer */
557
+ renderLabel?: (props: DialLabelProps) => React.ReactNode;
558
+ /** Dial preset object (overrides renderRing/renderNotch/renderLabel) */
559
+ dialPreset?: DialPreset;
560
+ /** Show center reticle */
561
+ showReticle?: boolean;
562
+ /** Custom reticle SVG renderer */
563
+ renderReticle?: (props: ReticleProps) => React.ReactNode;
564
+ /** Reticle preset object (overrides renderReticle) */
565
+ reticlePreset?: ReticlePreset;
566
+ }
567
+ /** Props passed to custom reticle renderer */
568
+ interface ReticleProps {
569
+ cx: number;
570
+ cy: number;
571
+ size: number;
572
+ /** Which layer is being rendered: 'back' (behind icon) or 'front' (above icon) */
573
+ layer: 'back' | 'front';
574
+ }
575
+ /** Props passed to custom ring renderer */
576
+ interface DialRingProps {
577
+ cx: number;
578
+ cy: number;
579
+ radius: number;
580
+ }
581
+ /** Props passed to custom notch renderer */
582
+ interface DialNotchProps {
583
+ x: number;
584
+ y: number;
585
+ /** Current angle in degrees (0 = top) */
586
+ degrees: number;
587
+ onMouseDown: (e: React.MouseEvent) => void;
588
+ }
589
+ /** Props passed to custom label renderer */
590
+ interface DialLabelProps {
591
+ x: number;
592
+ y: number;
593
+ degrees: number;
475
594
  }
476
595
  /**
477
596
  * IconCraftView - インスタンスからSVGを表示するコンポーネント
@@ -484,7 +603,7 @@ interface IconCraftViewProps {
484
603
  * <IconCraftView instance={icon} zIndex={10} />
485
604
  * ```
486
605
  */
487
- declare function IconCraftView({ instance, animation, animationTarget, animateOnHover, zIndex, className, style, onClick, onLoad, onError, }: IconCraftViewProps): react_jsx_runtime.JSX.Element | null;
606
+ declare function IconCraftView({ instance, animation, animationTarget, animateOnHover, zIndex, className, style, onClick, onLoad, onError, showRotationDial, onRotationChange, rotationSnap, renderRing: renderRingProp, renderNotch: renderNotchProp, renderLabel: renderLabelProp, dialPreset, showReticle, renderReticle: renderReticleProp, reticlePreset, }: IconCraftViewProps): react_jsx_runtime.JSX.Element | null;
488
607
 
489
608
  /**
490
609
  * IconCraftSimple Props
@@ -570,7 +689,7 @@ declare function IconCraftSimple({ src, mode, iconStyle, iconColor, shapeColor,
570
689
  * />
571
690
  * ```
572
691
  */
573
- declare function IconCraftShape({ svg, mode, shapeColor, iconStyle, shadow: _shadow, highlight: _highlight, offset, resolution, simplify, width, height, size, animation, animateOnHover, className, style, onLoad, onError, onClick, }: IconCraftShapeProps): react_jsx_runtime.JSX.Element | null;
692
+ declare function IconCraftShape({ svg, mode, shapeColor, iconStyle, shadow: _shadow, highlight: _highlight, offset, resolution, simplify, rotation, width, height, size, animation, animateOnHover, className, style, onLoad, onError, onClick, }: IconCraftShapeProps): react_jsx_runtime.JSX.Element | null;
574
693
 
575
694
  /**
576
695
  * Legacy IconCraft component
@@ -859,6 +978,8 @@ interface UseIconCraftOptions {
859
978
  resolution?: number;
860
979
  /** Polygon simplification epsilon */
861
980
  simplify?: number;
981
+ /** Icon rotation in degrees (0-360) */
982
+ rotation?: number;
862
983
  /** Auto-generate on mount/change */
863
984
  autoGenerate?: boolean;
864
985
  }
@@ -1033,6 +1154,8 @@ interface IconBackupData {
1033
1154
  zIndex?: number;
1034
1155
  /** アイコンの色(オプション) */
1035
1156
  iconColor?: string;
1157
+ /** 回転角度(オプション) */
1158
+ rotation?: number;
1036
1159
  /** アニメーション(オプション) */
1037
1160
  animation?: AnimationType;
1038
1161
  /** カスタムメタデータ(オプション) */
@@ -1108,4 +1231,4 @@ declare function parseBackup(json: string): IconCraftBackup | null;
1108
1231
  */
1109
1232
  declare function loadBackupFromFile(file: File): Promise<IconCraftBackup | null>;
1110
1233
 
1111
- export { type AnimationOptions, type AnimationTarget, type AnimationType, BACKUP_VERSION, type BackupValidationResult, type BuiltInAnimationType, type ColorPalette, type CreateBackupOptions, type CustomAnimationDefinition, type CustomAnimationRegistry, DEFAULT_CONFIG, DEFAULT_METADATA, type EmbossIconData, type EmbossPath, type IconBackupData, IconCraft, type IconCraftBackup, IconCraftConfig, type IconCraftConfigOptions, type IconCraftContextValue, type IconCraftDispatcher, type IconCraftEvent, type IconCraftEventFilter, type IconCraftEventHandler, type IconCraftEventType, IconCraftFactory, IconCraftInstance, type IconCraftMetadata, type IconCraftProps, IconCraftProvider, type IconCraftProviderProps, IconCraftRegistry, type IconCraftResult, IconCraftShape, type IconCraftShapeProps, IconCraftSimple, type IconCraftSimpleProps, type IconCraftStoreActions, type IconCraftStoreState, IconCraftView, type IconCraftViewProps, type IconLayout, type IconStyle, type ShapeMode, type SvgPaths, type TransformOriginCustom, type TransformOriginPreset, type TransformOriginValue, type UseIconCraftCreateOptions, type UseIconCraftReturn$1 as UseIconCraftInstanceReturn, type UseIconCraftOptions, type UseIconCraftReturn, type UseIconCraftSelectionReturn, type WasmGenerateParams, WasmManager, animationDefaults, createBackup, createDispatcher, defaultFactory, downloadBackup, exportBackup, generateIconId, getAnimationDefaults, getAnimationName, getAnimationStyle, getCustomAnimation, getKeyframes, getTimestampFromId, getTransformOrigin, globalRegistry, injectKeyframes, keyframes, loadBackupFromFile, parseAnimationOptions, parseBackup, registerAnimation, useIconCraft, useIconCraftContext, useIconCraftCreate, useIconCraftEvent, useIconCraft$1 as useIconCraftInstance, useIconCraftSelection, useIconCraftStore, useLegacyIconCraft, validateBackup };
1234
+ export { type AnimationOptions, type AnimationTarget, type AnimationType, BACKUP_VERSION, type BackupValidationResult, type BuiltInAnimationType, type ColorPalette, type CreateBackupOptions, type CustomAnimationDefinition, type CustomAnimationRegistry, DEFAULT_CONFIG, DEFAULT_METADATA, type DialLabelProps, type DialNotchProps, type DialPreset, type DialPresetName, type DialRingProps, type EmbossIconData, type EmbossPath, type IconBackupData, IconCraft, type IconCraftBackup, IconCraftConfig, type IconCraftConfigOptions, type IconCraftContextValue, type IconCraftDispatcher, type IconCraftEvent, type IconCraftEventFilter, type IconCraftEventHandler, type IconCraftEventType, IconCraftFactory, IconCraftInstance, type IconCraftMetadata, type IconCraftProps, IconCraftProvider, type IconCraftProviderProps, IconCraftRegistry, type IconCraftResult, IconCraftShape, type IconCraftShapeProps, IconCraftSimple, type IconCraftSimpleProps, type IconCraftStoreActions, type IconCraftStoreState, IconCraftView, type IconCraftViewProps, type IconLayout, type IconStyle, type ReticlePreset, type ReticlePresetName, type ReticleProps, type ShapeMode, type SvgPaths, type TransformOriginCustom, type TransformOriginPreset, type TransformOriginValue, type UseIconCraftCreateOptions, type UseIconCraftReturn$1 as UseIconCraftInstanceReturn, type UseIconCraftOptions, type UseIconCraftReturn, type UseIconCraftSelectionReturn, type WasmGenerateParams, WasmManager, animationDefaults, createBackup, createDispatcher, defaultFactory, dialPresetArrow, dialPresetBar, dialPresetCrosshair, dialPresetDashed, dialPresetDotted, dialPresetDouble, dialPresetMinimal, dialPresetNeedle, dialPresetSolid, dialPresetTicks, dialPresets, downloadBackup, exportBackup, generateIconId, getAnimationDefaults, getAnimationName, getAnimationStyle, getCustomAnimation, getKeyframes, getTimestampFromId, getTransformOrigin, globalRegistry, injectKeyframes, keyframes, loadBackupFromFile, parseAnimationOptions, parseBackup, registerAnimation, reticlePresetBullseye, reticlePresetCross, reticlePresetGlobe, reticlePresets, useIconCraft, useIconCraftContext, useIconCraftCreate, useIconCraftEvent, useIconCraft$1 as useIconCraftInstance, useIconCraftSelection, useIconCraftStore, useLegacyIconCraft, validateBackup };