@web-canvas-ui/angular 0.2.0 → 0.3.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/README.md +339 -225
- package/index.js +1761 -636
- package/package.json +1 -1
- package/types/angular/Canvas.d.ts +1 -0
- package/types/angular/index.d.ts +3 -2
- package/types/angular/node-directives.d.ts +52 -2
- package/types/components/Button/button.d.ts +2 -0
- package/types/components/ChoiceGroup/choiceGroup.d.ts +5 -0
- package/types/components/ChoiceGroup/index.d.ts +1 -1
- package/types/components/Form/form.d.ts +42 -0
- package/types/components/Form/index.d.ts +2 -0
- package/types/components/Upload/index.d.ts +2 -2
- package/types/components/Upload/upload.d.ts +10 -0
- package/types/components/Video/index.d.ts +4 -2
- package/types/components/Video/logic.d.ts +56 -0
- package/types/components/Video/video.d.ts +37 -3
- package/types/components/types.d.ts +2 -1
- package/types/engine/accessibility.d.ts +5 -0
- package/types/engine/carousel.d.ts +1 -1
- package/types/engine/forms.d.ts +21 -0
- package/types/engine/interaction.d.ts +1 -0
- package/types/engine/layout.d.ts +1 -1
- package/types/engine/nodes.d.ts +3 -2
- package/types/engine/state.d.ts +12 -1
- package/types/engine/uploads.d.ts +5 -0
- package/types/engine/videos.d.ts +20 -6
- package/types/engine.d.ts +2 -0
- package/types/input-bridge.d.ts +15 -1
- package/types/types.d.ts +41 -3
- package/types/video-assets.d.ts +17 -0
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ npm run dev
|
|
|
25
25
|
OR
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
[▶️
|
|
28
|
+
[▶️ ui-demo](https://codesandbox.io/p/sandbox/web-canvas-ui-demo-2jhwsn)
|
|
29
|
+
|
|
30
|
+
[▶️ form-demo](https://codesandbox.io/p/sandbox/form-demo-drvqqk)
|
|
29
31
|
|
|
30
32
|
## Global Theme Colors
|
|
31
33
|
|
|
@@ -92,12 +94,12 @@ npm install @web-canvas-ui/svelte
|
|
|
92
94
|
npm install @web-canvas-ui/angular
|
|
93
95
|
```
|
|
94
96
|
|
|
95
|
-
| Framework | Entry
|
|
96
|
-
| ----------- |
|
|
97
|
-
| React | `@web-canvas-ui/react`
|
|
98
|
-
| Vue 3 | `@web-canvas-ui/vue`
|
|
99
|
-
| Svelte 5+ | `@web-canvas-ui/svelte`
|
|
100
|
-
| Angular 17+ | `@web-canvas-ui/angular`
|
|
97
|
+
| Framework | Entry |
|
|
98
|
+
| ----------- | ------------------------ |
|
|
99
|
+
| React | `@web-canvas-ui/react` |
|
|
100
|
+
| Vue 3 | `@web-canvas-ui/vue` |
|
|
101
|
+
| Svelte 5+ | `@web-canvas-ui/svelte` |
|
|
102
|
+
| Angular 17+ | `@web-canvas-ui/angular` |
|
|
101
103
|
|
|
102
104
|
Components must be placed inside the corresponding adapter's Canvas container and use the scene components exported by that framework's entry. Do not place plain DOM elements inside a Canvas scene.
|
|
103
105
|
|
|
@@ -141,7 +143,13 @@ export function ProfileCanvas() {
|
|
|
141
143
|
placeholder="Your name"
|
|
142
144
|
onChange={setName}
|
|
143
145
|
/>
|
|
144
|
-
<Text
|
|
146
|
+
<Text
|
|
147
|
+
x={16}
|
|
148
|
+
y={108}
|
|
149
|
+
width={280}
|
|
150
|
+
fontSize={16}
|
|
151
|
+
text={name ? `Hello, ${name}` : 'Type your name'}
|
|
152
|
+
/>
|
|
145
153
|
<Button
|
|
146
154
|
x={16}
|
|
147
155
|
y={136}
|
|
@@ -204,7 +212,12 @@ function exportPng() {
|
|
|
204
212
|
placeholder="Your name"
|
|
205
213
|
@change="name = $event"
|
|
206
214
|
/>
|
|
207
|
-
<Text
|
|
215
|
+
<Text
|
|
216
|
+
:x="16"
|
|
217
|
+
:y="104"
|
|
218
|
+
:width="280"
|
|
219
|
+
:text="name ? `Hello, ${name}` : 'Type your name'"
|
|
220
|
+
/>
|
|
208
221
|
<Button :x="16" :y="142" :width="120" :height="36" @click="exportPng">
|
|
209
222
|
Export Image
|
|
210
223
|
</Button>
|
|
@@ -337,6 +350,12 @@ Every visible component except `<Canvas>` supports the following transform props
|
|
|
337
350
|
| `scaleY` | `number` | `1` | Vertical transform scale. |
|
|
338
351
|
| `visible` | `boolean` | `true` | Whether the component is drawn; when `false`, its children are also hidden and do not respond to clicks. |
|
|
339
352
|
|
|
353
|
+
### Keyboard and accessibility
|
|
354
|
+
|
|
355
|
+
`Input`, `Textarea`, `DatePicker`, `Button`, `Upload`, `Switch`, `Radio`, `Checkbox`, `Slider`, and `Dropdown` support keyboard focus and native accessibility semantics. Use Tab to move between controls, Enter/Space for buttons and switches, and the browser's native keys for choices and sliders. Keyboard operation of Dropdown uses a native selection list. Set `ariaLabel` on interactive components for a meaningful name, for example `<Switch ariaLabel="Notifications" />`; text inputs fall back to their placeholder. Form errors are associated with their fields for assistive technology.
|
|
356
|
+
|
|
357
|
+
Keyboard support for Tabs, Collapse, Carousel, Video, and custom-drawn controls is not yet included. Test keyboard and screen-reader behavior in your application.
|
|
358
|
+
|
|
340
359
|
### Sizing Rules
|
|
341
360
|
|
|
342
361
|
- `Rect`, `Input`, `Textarea`, `Upload`, `Dropdown`, `DatePicker`, `Slider`, `Switch`, and `Button` use `width` and `height` to set their size.
|
|
@@ -470,6 +489,79 @@ Used to group, position, and transform children. Supports [Common Props](#common
|
|
|
470
489
|
</Group>
|
|
471
490
|
```
|
|
472
491
|
|
|
492
|
+
### `<Form>` and `<FormItem>`
|
|
493
|
+
|
|
494
|
+
`Form` manages field values, validation, and submission. Each `FormItem` needs a unique `name` and exactly one direct `Input`, `Textarea`, `DatePicker`, `Radio`, `Checkbox`, `Dropdown`, `Slider`, `Switch`, or `Upload`. Child positions are relative to the item; nested forms are not supported.
|
|
495
|
+
|
|
496
|
+
```tsx
|
|
497
|
+
<Form
|
|
498
|
+
initialValues={{ email: '', role: 'Individual' }}
|
|
499
|
+
onSubmit={(values) => console.log(values)}
|
|
500
|
+
onInvalid={(errors) => console.log(errors)}
|
|
501
|
+
>
|
|
502
|
+
<FormItem
|
|
503
|
+
x={20}
|
|
504
|
+
y={20}
|
|
505
|
+
name="email"
|
|
506
|
+
rules={[
|
|
507
|
+
{ required: true, message: 'Enter an email' },
|
|
508
|
+
{ pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, message: 'Invalid email' },
|
|
509
|
+
]}
|
|
510
|
+
>
|
|
511
|
+
<Input placeholder="Email" />
|
|
512
|
+
</FormItem>
|
|
513
|
+
<FormItem x={20} y={90} name="role">
|
|
514
|
+
<Radio options={['Individual', 'Team']} />
|
|
515
|
+
</FormItem>
|
|
516
|
+
<Button x={20} y={140} text="Submit" formAction="submit" />
|
|
517
|
+
<Button x={160} y={140} text="Reset" formAction="reset" />
|
|
518
|
+
</Form>
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
`Form` and `FormItem` also support [Common Props](#common-props). Field value types depend on the control: `Checkbox` uses `string[]`, `Upload` uses `File[]`, `Switch` uses `boolean`, `Slider` uses `number`, and the other supported controls use `string`. The exported types include `FormValue`, `FormValues` (field names to values), and `FormErrors` (field names to error messages).
|
|
522
|
+
|
|
523
|
+
**Form props**
|
|
524
|
+
|
|
525
|
+
| Prop | Type | Required | Description |
|
|
526
|
+
| ---------------- | ------------------------------------------------- | -------- | ----------- |
|
|
527
|
+
| `children` | Child components | No | Form items, buttons, and layout components. |
|
|
528
|
+
| `initialValues` | `FormValues` | No | Initial values by field name; takes precedence over control initial values. |
|
|
529
|
+
| `controller` | `FormController` | No | Created by `createFormController()` to read or set fields. |
|
|
530
|
+
| `onSubmit` | `(values: FormValues) => void` | No | Called when submission passes validation. |
|
|
531
|
+
| `onInvalid` | `(errors: FormErrors, values: FormValues) => void` | No | Called when submission fails validation. |
|
|
532
|
+
| `onValuesChange` | `(values: FormValues) => void` | No | Called with all current field values when a field changes. |
|
|
533
|
+
| `onReset` | `() => void` | No | Called after a reset. |
|
|
534
|
+
|
|
535
|
+
**FormItem props**
|
|
536
|
+
|
|
537
|
+
| Prop | Type | Required | Default | Description |
|
|
538
|
+
| --------------- | ------------ | -------- | ----------- | ----------- |
|
|
539
|
+
| `children` | Child component | Yes | — | Must contain exactly one direct supported form control. |
|
|
540
|
+
| `name` | `string` | Yes | — | Nonempty field name, unique within the form. |
|
|
541
|
+
| `rules` | `FormRule[]` | No | `[]` | Validation rules evaluated in order. |
|
|
542
|
+
| `errorY` | `number` | No | control height + 4 | Error text's vertical position relative to the item; its horizontal position is `0`. |
|
|
543
|
+
| `errorColor` | `string` | No | `'#d93025'` | Error text color. |
|
|
544
|
+
| `errorFontSize` | `number` | No | `12` | Error text font size. |
|
|
545
|
+
|
|
546
|
+
**FormRule properties**
|
|
547
|
+
|
|
548
|
+
| Property | Type | Description |
|
|
549
|
+
| ----------- | ----------------------------------------------------------------------- | ----------- |
|
|
550
|
+
| `required` | `boolean` | When `true`, whitespace-only strings, empty arrays, and `false` fail validation; `0` is not empty. |
|
|
551
|
+
| `minLength` | `number` | Minimum length for nonempty strings or arrays. |
|
|
552
|
+
| `maxLength` | `number` | Maximum length for nonempty strings or arrays. |
|
|
553
|
+
| `pattern` | `RegExp` | Pattern that a nonempty string must match. |
|
|
554
|
+
| `validator` | `(value: FormValue, values: Readonly<FormValues>) => string \| undefined \| Promise<string \| undefined>` | Synchronous or asynchronous validation; return an error string to fail, or `undefined` or an empty string to pass. |
|
|
555
|
+
| `message` | `string` | Overrides the rule's default or custom validation error message. |
|
|
556
|
+
|
|
557
|
+
- `initialValues` supplies initial field values; otherwise the control's `value` / `defaultValue` (or `checked` / `defaultChecked` for Switch) or its default is used. Form owns these values, but the control's original `onChange` still fires.
|
|
558
|
+
- Rules run in order; validators may return a Promise, and rejections appear as `Validation failed: ...`. Required treats whitespace-only strings, empty arrays and `false` as empty. Length applies to strings and arrays; patterns apply to strings.
|
|
559
|
+
- Text inputs validate on blur, other controls when their keyboard focus leaves, and all fields on submit. After the first submit, edits revalidate the form. Submission waits for async validation; stale results after edits, reset or unmount are ignored. Errors default to 4 pixels below the control; reserve room for errors and upload lists or override `errorY`.
|
|
560
|
+
- `onValuesChange(values)` fires for field edits. A reset button restores the current `initialValues` / control defaults, clears errors and calls `onReset()`. Removed fields are omitted from submission.
|
|
561
|
+
- All four adapters export `Form`, `FormItem`, and their types. Angular uses `<canvas-form>` and `<canvas-form-item>` with `(formSubmit)`, `(formInvalid)`, `(valuesChange)`, and `(formReset)` events.
|
|
562
|
+
|
|
563
|
+
Create a controller with `createFormController()` from the framework entry point and pass it as `controller`. Once mounted, use `controller.getValues()`, `controller.getFieldValue('email')`, or `controller.setFieldValue('email', 'a@example.com')`. Setting a field fires `onValuesChange` and revalidates after a submit, but does not fire the control's `onChange`; arrays returned by the getters are copies. Unknown fields, invalid types, use while unmounted, and sharing a controller between mounted forms throw errors. Angular uses `[controller]`.
|
|
564
|
+
|
|
473
565
|
### `<Grid>`
|
|
474
566
|
|
|
475
567
|
Places children in order into fixed-size cells, wrapping to the next row once a row fills the specified column count. `Grid` does not draw a background; it is a layout container and can use transform props like `Group`.
|
|
@@ -482,7 +574,7 @@ Places children in order into fixed-size cells, wrapping to the next row once a
|
|
|
482
574
|
| `cellWidth` | `number` | No | — | Fixed logical cell width; takes precedence over `width` auto-distribution. Must be positive. |
|
|
483
575
|
| `cellHeight` | `number` | Yes | — | Logical cell height; must be positive. |
|
|
484
576
|
| `gap` | `number` | No | `0` | Equal row and column spacing; must not be negative. |
|
|
485
|
-
| `virtual` | `boolean` | No | `false` | Mount only items near the viewport; requires `height`.
|
|
577
|
+
| `virtual` | `boolean` | No | `false` | Mount only items near the viewport; requires `height`. |
|
|
486
578
|
| `onScroll` | `(scrollTop: number) => void` | No | — | Scroll position change callback, in logical pixels. |
|
|
487
579
|
|
|
488
580
|
Direct children keep their own `x` and `y`, plus the offset of the cell they fall into. When `cellWidth` is not passed, columns are equal-width: `(width - gap * (columns - 1)) / columns`. A child's own size is not automatically stretched.
|
|
@@ -526,13 +618,18 @@ For large data sets, use `<Grid ... height={180} virtual>` (Angular: `[virtual]=
|
|
|
526
618
|
Where possible, unchanged static virtual grids reuse their drawing when other components repaint. Scrolling, content changes, and theme changes invalidate it. Grids containing videos, images, `CustomDraw`, or `CanvasView` are drawn normally to keep dynamic content current. In React, memoize the whole Grid element with `useMemo` to avoid recreating and compiling its children when unrelated state changes; include the data and all values affecting the list in the dependency array:
|
|
527
619
|
|
|
528
620
|
```tsx
|
|
529
|
-
const grid = useMemo(
|
|
530
|
-
|
|
531
|
-
{
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
621
|
+
const grid = useMemo(
|
|
622
|
+
() => (
|
|
623
|
+
<Grid columns={1} width={280} height={180} cellHeight={44} virtual>
|
|
624
|
+
{items.map((item) => (
|
|
625
|
+
<GridItem key={item.id}>
|
|
626
|
+
<Text text={item.label} />
|
|
627
|
+
</GridItem>
|
|
628
|
+
))}
|
|
629
|
+
</Grid>
|
|
630
|
+
),
|
|
631
|
+
[items],
|
|
632
|
+
);
|
|
536
633
|
```
|
|
537
634
|
|
|
538
635
|
### `<GridItem>`
|
|
@@ -573,7 +670,7 @@ Loads an image from `src` and draws it into the Canvas at the specified size. `o
|
|
|
573
670
|
| `width` / `height` | `number` | Yes | — | Canvas logical size. |
|
|
574
671
|
| `objectFit` | `"contain" \| "cover" \| "fill" \| "none" \| "scale-down"` | No | `"contain"` | Image scaling and cropping mode. |
|
|
575
672
|
| `onError` | `(error: Error) => void` | No | — | Fires when the image fails to load. |
|
|
576
|
-
| `onClick` | `() => void` | No | — | Click callback.
|
|
673
|
+
| `onClick` | `() => void` | No | — | Click callback. |
|
|
577
674
|
|
|
578
675
|
```tsx
|
|
579
676
|
<Image x={16} y={16} src="/avatar.png" width={96} height={96} objectFit="cover" />
|
|
@@ -583,20 +680,27 @@ Remote images draw correctly, but browser CORS rules still apply to Canvas expor
|
|
|
583
680
|
|
|
584
681
|
### `<Video>`
|
|
585
682
|
|
|
586
|
-
Loads a video from `src` and paints its frames into the Canvas through the engine's render loop — no extra animation loop is created.
|
|
587
|
-
|
|
588
|
-
| Prop
|
|
589
|
-
|
|
|
590
|
-
| `src`
|
|
591
|
-
| `width` / `height`
|
|
592
|
-
| `objectFit`
|
|
593
|
-
| `autoplay`
|
|
594
|
-
| `loop`
|
|
595
|
-
| `muted`
|
|
596
|
-
| `paused`
|
|
597
|
-
| `currentTime`
|
|
598
|
-
| `
|
|
599
|
-
| `
|
|
683
|
+
Loads a video from `src` and paints its frames into the Canvas through the engine's render loop — no extra animation loop is created. Every `<Video>` node owns a dedicated `<video>` element: nodes sharing the same `src` can still be played, paused and seeked independently, and the element is released automatically when the node leaves the scene. `objectFit` supports the same modes as `<Image>`. Set `controls` to draw the built-in controls bar — a play/pause toggle, a seekable progress track and the time text — and to make the bar's regions pointer-interactive.
|
|
684
|
+
|
|
685
|
+
| Prop | Type | Required | Default | Description |
|
|
686
|
+
| -------------------- | ---------------------------------------------------------- | -------: | -------------------------- | ------------------------------------------------------------------------------------------- |
|
|
687
|
+
| `src` | `string` | Yes | — | Video URL. |
|
|
688
|
+
| `width` / `height` | `number` | No | Video's native | Canvas logical size; defaults to the video's intrinsic size. |
|
|
689
|
+
| `objectFit` | `"contain" \| "cover" \| "fill" \| "none" \| "scale-down"` | No | `"contain"` | Video scaling and cropping mode, identical to `<Image>`. |
|
|
690
|
+
| `autoplay` | `boolean` | No | `false` | Start playback automatically; browsers require `muted` for autoplay to succeed. |
|
|
691
|
+
| `loop` | `boolean` | No | `false` | Restart from the beginning when playback ends. |
|
|
692
|
+
| `muted` | `boolean` | No | `false` | Mute the audio track. |
|
|
693
|
+
| `paused` | `boolean` | No | — | Declarative play/pause: `false` plays, `true` pauses; omitted leaves control to `autoplay`. |
|
|
694
|
+
| `currentTime` | `number` | No | — | Seek target in seconds; set it once to jump, not on every frame. |
|
|
695
|
+
| `controls` | `boolean` | No | `false` | Show the built-in controls bar and accept pointer input on its toggle and track. |
|
|
696
|
+
| `controlsOnHover` | `boolean` | No | `false` | Show controls on hover; on touch devices, tap the video to show or hide them. |
|
|
697
|
+
| `controlsBarColor` | `string` | No | `"rgba(0,0,0,0.55)"` | Background of the controls bar. |
|
|
698
|
+
| `controlsColor` | `string` | No | `"#fff"` | Play/pause icon, played track, thumb and time text color. |
|
|
699
|
+
| `controlsTrackColor` | `string` | No | `"rgba(255,255,255,0.35)"` | Idle part of the seek track. |
|
|
700
|
+
| `onError` | `(error: Error) => void` | No | — | Fires when the video fails to load. |
|
|
701
|
+
| `onTimeUpdate` | `(currentTime: number, duration: number) => void` | No | — | Fires on playback progress, driven by the video's native `timeupdate` event. |
|
|
702
|
+
| `onPausedChange` | `(paused: boolean) => void` | No | — | Fires when the user toggles playback through the controls bar. |
|
|
703
|
+
| `onSeek` | `(currentTime: number) => void` | No | — | Fires when the user seeks through the controls bar (press or drag on the track). |
|
|
600
704
|
|
|
601
705
|
```tsx
|
|
602
706
|
<Video
|
|
@@ -609,10 +713,17 @@ Loads a video from `src` and paints its frames into the Canvas through the engin
|
|
|
609
713
|
muted
|
|
610
714
|
autoplay
|
|
611
715
|
loop
|
|
716
|
+
controls
|
|
717
|
+
controlsOnHover
|
|
718
|
+
onSeek={(currentTime) => console.log(currentTime)}
|
|
612
719
|
/>
|
|
613
720
|
```
|
|
614
721
|
|
|
615
|
-
|
|
722
|
+
During a seek, the previous frame stays visible until the target frame can be drawn. Seeking to unbuffered content may still require the browser to load data. When controlling `paused`, update its state in `onPausedChange` so the next update does not undo a controls-bar action.
|
|
723
|
+
|
|
724
|
+
The fullscreen button opens the current video in the browser's native fullscreen player. Native play, pause, and seek actions also trigger `onPausedChange` and `onSeek`. Native controls take precedence while fullscreen is active: `paused`, `autoplay`, and `currentTime` are not applied to the player until fullscreen exits. Fullscreen errors are reported through `onError`, or logged if no handler is provided.
|
|
725
|
+
|
|
726
|
+
Browser autoplay policies apply: without `muted`, playback only starts after a user gesture. Videos are first loaded with CORS; on failure, loading is retried without CORS, although the browser may still report the initial error in its console. A cross-origin video loaded without CORS can play, but drawing it taints the Canvas and prevents pixel reads and PNG export. For export, use a same-origin video or configure the video server to return an `Access-Control-Allow-Origin` header permitting the current site. Angular uses `<canvas-video>`, with `(videoError)`, `(timeUpdate)`, `(pausedChange)` and `(seek)` event bindings.
|
|
616
727
|
|
|
617
728
|
### `<Progress>`
|
|
618
729
|
|
|
@@ -631,20 +742,20 @@ Draws a non-interactive progress bar. `value` is clamped between `min` and `max`
|
|
|
631
742
|
|
|
632
743
|
`Carousel` shows one `CarouselItem` at a time in child order, with optional autoplay, looping, prev/next arrows, and bottom indicator dots. Item content supports any Canvas UI component; when `activeIndex` is not passed explicitly, the carousel runs uncontrolled starting at index 0.
|
|
633
744
|
|
|
634
|
-
| Component | Prop
|
|
635
|
-
| -------------- |
|
|
636
|
-
| `Carousel` | `width` / `height`
|
|
637
|
-
| `Carousel` | `activeIndex`
|
|
638
|
-
| `Carousel` | `defaultActiveIndex`
|
|
639
|
-
| `Carousel` | `autoplay`
|
|
640
|
-
| `Carousel` | `interval`
|
|
641
|
-
| `Carousel` | `transitionDuration`
|
|
642
|
-
| `Carousel` | `loop`
|
|
643
|
-
| `Carousel` | `showArrows` / `showDots`
|
|
644
|
-
| `Carousel` | `backgroundColor`
|
|
645
|
-
| `Carousel` | `arrowColor` / `dotColor` / `activeDotColor` | `string`
|
|
646
|
-
| `Carousel` | `onChange`
|
|
647
|
-
| `CarouselItem` | Children
|
|
745
|
+
| Component | Prop | Type | Default | Description |
|
|
746
|
+
| -------------- | -------------------------------------------- | ------------------------- | ----------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
747
|
+
| `Carousel` | `width` / `height` | `number` | Required | Viewport size; content overflowing the bounds is clipped. |
|
|
748
|
+
| `Carousel` | `activeIndex` | `number` | — | Controlled current index; combine with `onChange` to update. |
|
|
749
|
+
| `Carousel` | `defaultActiveIndex` | `number` | `0` | Uncontrolled initial index. |
|
|
750
|
+
| `Carousel` | `autoplay` | `boolean` | `true` | Whether to auto-advance; disabled when there are fewer than two items. |
|
|
751
|
+
| `Carousel` | `interval` | `number` | `3000` | Autoplay interval in ms; treated as a minimum of `250`. |
|
|
752
|
+
| `Carousel` | `transitionDuration` | `number` | `450` | Horizontal slide transition duration in ms; set `0` to switch instantly. |
|
|
753
|
+
| `Carousel` | `loop` | `boolean` | `true` | Whether to loop back to the first item at the end. |
|
|
754
|
+
| `Carousel` | `showArrows` / `showDots` | `boolean` | `true` | Whether to show the prev/next arrows and bottom indicator dots. |
|
|
755
|
+
| `Carousel` | `backgroundColor` | `string` | `"transparent"` | Viewport background color. |
|
|
756
|
+
| `Carousel` | `arrowColor` / `dotColor` / `activeDotColor` | `string` | theme / `"#fff"` / `"rgba(255,255,255,0.65)"` / `"#1677ff"` | Arrow, inactive dot and active dot colors; the listed colors are fallbacks. |
|
|
757
|
+
| `Carousel` | `onChange` | `(index: number) => void` | — | Fires when the active index changes. |
|
|
758
|
+
| `CarouselItem` | Children | Canvas UI components | — | Content shown for this slide. |
|
|
648
759
|
|
|
649
760
|
```tsx
|
|
650
761
|
<Carousel width={320} height={180} interval={4000} onChange={setActiveIndex}>
|
|
@@ -663,17 +774,17 @@ Angular uses `<canvas-carousel>` and `<canvas-carousel-item>`; controlled index
|
|
|
663
774
|
|
|
664
775
|
`Tabs` uses `TabItem` to declare tabs and their corresponding Canvas subtrees. The first `TabItem` is selected by default.
|
|
665
776
|
|
|
666
|
-
| Component | Prop | Type
|
|
667
|
-
| --------- | ------------------------------------------------------------------ |
|
|
668
|
-
| `Tabs` | `width` / `height` | `number`
|
|
669
|
-
| `Tabs` | `activeKey` / `defaultActiveKey` | `string`
|
|
670
|
-
| `Tabs` | `headerHeight` | `number`
|
|
671
|
-
| `Tabs` | `backgroundColor` / `textColor` / `activeColor` / `indicatorColor` | `string`
|
|
672
|
-
| `Tabs` | `onChange` | `(key: string) => void`
|
|
673
|
-
| `TabItem` | `id` / `title` | `string`
|
|
674
|
-
| `TabItem` | `disabled` | `boolean`
|
|
675
|
-
| `TabItem` | `size`
|
|
676
|
-
| `TabItem` | Children | Canvas UI components
|
|
777
|
+
| Component | Prop | Type | Description |
|
|
778
|
+
| --------- | ------------------------------------------------------------------ | ------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
779
|
+
| `Tabs` | `width` / `height` | `number` | Size of the tab container; required. Content is drawn below the header and clipped to the content area. |
|
|
780
|
+
| `Tabs` | `activeKey` / `defaultActiveKey` | `string` | Controlled selected key / uncontrolled initial key. |
|
|
781
|
+
| `Tabs` | `headerHeight` | `number` | Header bar height; default `40`. |
|
|
782
|
+
| `Tabs` | `backgroundColor` / `textColor` / `activeColor` / `indicatorColor` | `string` | Colors for the tab bar, text, active state, and indicator line. |
|
|
783
|
+
| `Tabs` | `onChange` | `(key: string) => void` | Fires when the selected tab changes. |
|
|
784
|
+
| `TabItem` | `id` / `title` | `string` | Unique identifier and label; required. |
|
|
785
|
+
| `TabItem` | `disabled` | `boolean` | Disables clicking on this tab. |
|
|
786
|
+
| `TabItem` | `size` | `{ width?: number; height?: number }` | Optional in the public type; currently does not determine the header or content area size. |
|
|
787
|
+
| `TabItem` | Children | Canvas UI components | Canvas content for this tab. |
|
|
677
788
|
|
|
678
789
|
```tsx
|
|
679
790
|
<Tabs width={320} height={180} defaultActiveKey="profile">
|
|
@@ -720,7 +831,7 @@ Angular counterparts are `<canvas-collapse>` and `<canvas-collapse-item>`; expan
|
|
|
720
831
|
|
|
721
832
|
### `<Dialog>`
|
|
722
833
|
|
|
723
|
-
The confirmation dialog overlays the Canvas centered by default, painting a mask, title, content area, and built-in Cancel/Confirm buttons.
|
|
834
|
+
The confirmation dialog overlays the Canvas centered by default, painting a mask, title, content area, and built-in Cancel/Confirm buttons. Only inputs in the topmost dialog are editable while it is open; background inputs are blocked and dialog inputs are clipped to the content area. Focus cycles within the dialog, Escape invokes `onCancel`, and closing restores the previous focus. The mask and focus restriction apply to this Canvas; applications must manage page content outside it.
|
|
724
835
|
|
|
725
836
|
| Prop | Type | Default | Description |
|
|
726
837
|
| ---------------------------- | -------------------- | ------------------: | -------------------------------------------------------- |
|
|
@@ -752,54 +863,54 @@ Angular uses `<canvas-dialog>`, with the `open` input and `(confirm)` / `(cancel
|
|
|
752
863
|
|
|
753
864
|
Draws a rectangle. Supports [Common Props](#common-props).
|
|
754
865
|
|
|
755
|
-
| Prop | Type |
|
|
756
|
-
| ------------- | -------- |
|
|
757
|
-
| `width` | `number` |
|
|
758
|
-
| `height` | `number` |
|
|
759
|
-
| `color` | `string` | theme / `"transparent"` | Fill color.
|
|
760
|
-
| `radius` | `number` |
|
|
761
|
-
| `stroke` | `string` |
|
|
762
|
-
| `strokeWidth` | `number` |
|
|
866
|
+
| Prop | Type | Default | Description |
|
|
867
|
+
| ------------- | -------- | ----------------------: | -------------------------------------- |
|
|
868
|
+
| `width` | `number` | `100` | Width. |
|
|
869
|
+
| `height` | `number` | `40` | Height. |
|
|
870
|
+
| `color` | `string` | theme / `"transparent"` | Fill color. |
|
|
871
|
+
| `radius` | `number` | `0` | Corner radius. |
|
|
872
|
+
| `stroke` | `string` | — | Stroke color; omitted means no stroke. |
|
|
873
|
+
| `strokeWidth` | `number` | `1` | Stroke width. |
|
|
763
874
|
|
|
764
875
|
### `<Circle>`
|
|
765
876
|
|
|
766
877
|
Draws a circle. Supports [Common Props](#common-props).
|
|
767
878
|
|
|
768
|
-
| Prop | Type |
|
|
769
|
-
| ------------- | -------- |
|
|
770
|
-
| `radius` | `number` |
|
|
771
|
-
| `color` | `string` | theme / `"#e74c3c"` | Fill color.
|
|
772
|
-
| `stroke` | `string` |
|
|
773
|
-
| `strokeWidth` | `number` |
|
|
879
|
+
| Prop | Type | Default | Description |
|
|
880
|
+
| ------------- | -------- | ------------------: | -------------------------------------- |
|
|
881
|
+
| `radius` | `number` | `10` | Circle radius. |
|
|
882
|
+
| `color` | `string` | theme / `"#e74c3c"` | Fill color. |
|
|
883
|
+
| `stroke` | `string` | — | Stroke color; omitted means no stroke. |
|
|
884
|
+
| `strokeWidth` | `number` | `1` | Stroke width. |
|
|
774
885
|
|
|
775
886
|
### `<Text>`
|
|
776
887
|
|
|
777
888
|
Draws single-line or auto-wrapped text. Pass content through `text`; `<Text>` does not accept children. Other non-container components also reject child components; `<Button>` accepts plain text children only. The node reports the box its rendered lines actually need, so containers such as `<CollapseItem>` can size themselves to it. Supports [Common Props](#common-props).
|
|
778
889
|
|
|
779
|
-
| Prop | Type
|
|
780
|
-
| ------------ |
|
|
781
|
-
| `text` | `string`
|
|
782
|
-
| `fontSize` | `number`
|
|
783
|
-
| `width` | `number`
|
|
784
|
-
| `maxLines` | `number`
|
|
785
|
-
| `fontFamily` | `string`
|
|
786
|
-
| `color` | `string`
|
|
787
|
-
| `baseline` | `CanvasTextBaseline`
|
|
788
|
-
| `textAlign` | `CanvasTextAlign`
|
|
789
|
-
| `onClick`
|
|
890
|
+
| Prop | Type | Default | Description |
|
|
891
|
+
| ------------ | -------------------- | ---------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
892
|
+
| `text` | `string` | — | Text content. |
|
|
893
|
+
| `fontSize` | `number` | `16` | Font size, in logical pixels. |
|
|
894
|
+
| `width` | `number` | — | Max line width; content wraps beyond it. Monospaced CJK characters also wrap based on measured width. Inside a `<Grid>`, defaults to the cell's width. |
|
|
895
|
+
| `maxLines` | `number` | — | Maximum lines to show; the last visible line is cut with an ellipsis. Inside a `<Grid>`, defaults to the lines that fit the cell; unlimited when neither is set. |
|
|
896
|
+
| `fontFamily` | `string` | `"sans-serif"` | Font family. |
|
|
897
|
+
| `color` | `string` | theme / `"#333"` | Font color. |
|
|
898
|
+
| `baseline` | `CanvasTextBaseline` | `"top"` | Canvas text baseline. |
|
|
899
|
+
| `textAlign` | `CanvasTextAlign` | `"left"` | Horizontal alignment within the text box; only `center` and `right` are special, other values render as `left`. |
|
|
900
|
+
| `onClick` | `() => void` | — | Click callback. |
|
|
790
901
|
|
|
791
902
|
### `<Icon>`
|
|
792
903
|
|
|
793
904
|
Original vector icons with no dependency on icon fonts or external images. Supports [Common Props](#common-props).
|
|
794
905
|
|
|
795
|
-
| Prop | Type |
|
|
796
|
-
| ------------- | ---------------------- |
|
|
797
|
-
| `name` | `IconName` |
|
|
798
|
-
| `size` | `number` |
|
|
799
|
-
| `color` | `string` | theme / `"#333"` | Icon color; can be set via `--canvas-ui-icon-color`.
|
|
800
|
-
| `variant` | `"outline" \| "solid"` |
|
|
801
|
-
| `strokeWidth` | `number` |
|
|
802
|
-
| `onClick`
|
|
906
|
+
| Prop | Type | Default | Description |
|
|
907
|
+
| ------------- | ---------------------- | ---------------: | ---------------------------------------------------------------------------------------- |
|
|
908
|
+
| `name` | `IconName` | Required | Icon name; see the list below. |
|
|
909
|
+
| `size` | `number` | `24` | Icon width and height. |
|
|
910
|
+
| `color` | `string` | theme / `"#333"` | Icon color; can be set via `--canvas-ui-icon-color`. |
|
|
911
|
+
| `variant` | `"outline" \| "solid"` | `"outline"` | `outline` for stroked shapes; `solid` uses thicker strokes and fills the primary shapes. |
|
|
912
|
+
| `strokeWidth` | `number` | `2` | Outline stroke width; solid style uses at least `4`. |
|
|
913
|
+
| `onClick` | `() => void` | — | Click callback. |
|
|
803
914
|
|
|
804
915
|
Supported: `home`, `house`, `building`, `apartment`, `store`, `mapPin`, `map`, `globe`, `compass`, `navigation`, `flag`, `mountain`, `tree`, `leaf`, `flower`, `sun`, `moon`, `cloud`, `rain`, `snow`, `fire`, `water`, `wind`, `car`, `bus`, `train`, `plane`, `bicycle`, `ship`, `rocket`, `truck`, `walk`, `phone`, `message`, `mail`, `bell`, `calendar`, `clock`, `alarm`, `camera`, `image`, `video`, `music`, `microphone`, `headphones`, `play`, `pause`, `stop`, `record`, `volume`, `wifi`, `bluetooth`, `battery`, `signal`, `power`, `monitor`, `laptop`, `tablet`, `keyboard`, `mouse`, `printer`, `folder`, `file`, `document`, `download`, `upload`, `share`, `link`, `search`, `settings`, `sliders`, `menu`, `close`, `check`, `plus`, `minus`, `edit`, `trash`, `copy`, `save`, `lock`, `unlock`, `key`, `user`, `users`, `heart`, `star`, `bookmark`, `cart`, `bag`, `gift`, `creditCard`, `wallet`, `chart`, `pieChart`, `barChart`, `analytics`, `shield`, `warning`, `info`, `help`, `question`, `tag`, `puzzle`, `code`, `database`, and `cloudDownload`.
|
|
805
916
|
|
|
@@ -812,26 +923,26 @@ Supported: `home`, `house`, `building`, `apartment`, `store`, `mapPin`, `map`, `
|
|
|
812
923
|
|
|
813
924
|
Single-line input. The control's appearance is painted onto the Canvas; a transparent HTML input handles keyboard, IME, and selection.
|
|
814
925
|
|
|
815
|
-
| Prop | Type |
|
|
816
|
-
| ------------------ | ---------------------------------- |
|
|
817
|
-
| `width` / `height` | `number` |
|
|
818
|
-
| `value` | `string` |
|
|
819
|
-
| `defaultValue` | `string` |
|
|
820
|
-
| `placeholder` | `string` |
|
|
821
|
-
| `type` | `"text" \| "password" \| "number"` |
|
|
822
|
-
| `fontSize` | `number` |
|
|
823
|
-
| `fontFamily` | `string` |
|
|
824
|
-
| `color` | `string` |
|
|
825
|
-
| `bgColor` | `string` |
|
|
826
|
-
| `borderColor` | `string` | theme / `"#d9d9d9"` | Normal border color.
|
|
827
|
-
| `focusBorderColor` | `string` | theme / `"#1677ff"` | Focused border color.
|
|
828
|
-
| `borderRadius` | `number` |
|
|
829
|
-
| `padding` | `number` |
|
|
830
|
-
| `disabled` | `boolean` |
|
|
831
|
-
| `maxLength` | `number` |
|
|
832
|
-
| `onChange` | `(value: string) => void` |
|
|
833
|
-
| `onFocus` | `() => void` |
|
|
834
|
-
| `onBlur` | `() => void` |
|
|
926
|
+
| Prop | Type | Default | Description |
|
|
927
|
+
| ------------------ | ---------------------------------- | ------------------: | ------------------------------------------------------------ |
|
|
928
|
+
| `width` / `height` | `number` | `200` / `36` | Control size. |
|
|
929
|
+
| `value` | `string` | — | Controlled input value; pair with `onChange` to update. |
|
|
930
|
+
| `defaultValue` | `string` | `""` | Uncontrolled initial value. |
|
|
931
|
+
| `placeholder` | `string` | `""` | Placeholder text. |
|
|
932
|
+
| `type` | `"text" \| "password" \| "number"` | `"text"` | Input type. Password content is shown as dots on the Canvas. |
|
|
933
|
+
| `fontSize` | `number` | `14` | Font size. |
|
|
934
|
+
| `fontFamily` | `string` | `"sans-serif"` | Font family. |
|
|
935
|
+
| `color` | `string` | theme / `"#333"` | Input text color. |
|
|
936
|
+
| `bgColor` | `string` | theme / `"#fff"` | Background color. |
|
|
937
|
+
| `borderColor` | `string` | theme / `"#d9d9d9"` | Normal border color. |
|
|
938
|
+
| `focusBorderColor` | `string` | theme / `"#1677ff"` | Focused border color. |
|
|
939
|
+
| `borderRadius` | `number` | `4` | Corner radius. |
|
|
940
|
+
| `padding` | `number` | `8` | Text padding. |
|
|
941
|
+
| `disabled` | `boolean` | `false` | Disables input. |
|
|
942
|
+
| `maxLength` | `number` | — | Max character count; a non-negative integer takes effect. |
|
|
943
|
+
| `onChange` | `(value: string) => void` | — | Fires when the input changes. |
|
|
944
|
+
| `onFocus` | `() => void` | — | Fires when focused. |
|
|
945
|
+
| `onBlur` | `() => void` | — | Fires when blurred. |
|
|
835
946
|
|
|
836
947
|
### `<Textarea>`
|
|
837
948
|
|
|
@@ -855,48 +966,51 @@ Multi-line text input; inherits value, size, style, and callback props from `<In
|
|
|
855
966
|
|
|
856
967
|
Draws a file-picker button. A built-in vector icon and the label are drawn together as one horizontally centered group. Clicking opens the browser's native file picker; this component does not upload to a server. Supports [Common Props](#common-props).
|
|
857
968
|
|
|
858
|
-
| Prop | Type |
|
|
859
|
-
| ------------------ | ------------------------- |
|
|
860
|
-
| `width` / `height` | `number` |
|
|
861
|
-
| `text` | `string` |
|
|
862
|
-
| `icon` | `IconName` |
|
|
863
|
-
| `iconSize` | `number` | `round(fontSize × 1.1)` | Icon size.
|
|
864
|
-
| `accept` | `string` |
|
|
865
|
-
| `multiple` | `boolean` |
|
|
866
|
-
| `
|
|
867
|
-
| `
|
|
868
|
-
| `
|
|
869
|
-
| `
|
|
870
|
-
| `
|
|
871
|
-
| `
|
|
872
|
-
| `
|
|
969
|
+
| Prop | Type | Default | Description |
|
|
970
|
+
| ------------------ | ------------------------- | ----------------------: | -------------------------------------------------------------------------- |
|
|
971
|
+
| `width` / `height` | `number` | `120` / `40` | Button size. |
|
|
972
|
+
| `text` | `string` | `"Choose File"` | Button label. |
|
|
973
|
+
| `icon` | `IconName` | `"upload"` | Built-in icon drawn before the label; use any name from [`<Icon>`](#icon). |
|
|
974
|
+
| `iconSize` | `number` | `round(fontSize × 1.1)` | Icon size. |
|
|
975
|
+
| `accept` | `string` | — | File type filter, e.g. `"image/*,.pdf"`. |
|
|
976
|
+
| `multiple` | `boolean` | `false` | Allow multi-selection. |
|
|
977
|
+
| `value` / `defaultValue` | `File[]` | `[]` | Controlled file list / uncontrolled initial list. |
|
|
978
|
+
| `maxSize` | `number` | — | Maximum size per file, in bytes. |
|
|
979
|
+
| `disabled` | `boolean` | `false` | Disables file selection. |
|
|
980
|
+
| `backgroundColor` | `string` | theme / `"#1677ff"` | Button background color. |
|
|
981
|
+
| `textColor` | `string` | theme / `"#fff"` | Label and icon color. |
|
|
982
|
+
| `borderColor` | `string` | — | Border color; omitted means no border. |
|
|
983
|
+
| `borderRadius` | `number` | `6` | Corner radius. |
|
|
984
|
+
| `fontSize` | `number` | `15` | Label font size. |
|
|
985
|
+
| `onChange` | `(files: File[]) => void` | — | Receives the complete list after selection or removal; canceled picks do not fire. |
|
|
986
|
+
| `onReject` | `(files: UploadRejection[]) => void` | — | Rejected files and their reasons (`type` or `size`). |
|
|
873
987
|
|
|
874
988
|
```tsx
|
|
875
989
|
<Upload accept="image/*" multiple onChange={(files) => console.log(files)} />
|
|
876
990
|
<Upload icon="cloud" text="Upload Photos" />
|
|
877
991
|
```
|
|
878
992
|
|
|
879
|
-
Angular uses `<canvas-upload
|
|
993
|
+
Files and removal buttons appear below the picker. Single selection replaces the file; multiple selection appends. `accept` and `maxSize` are checked locally; validate files on the server too. Angular uses `<canvas-upload>`, `(change)` and `(reject)`.
|
|
880
994
|
|
|
881
995
|
### `<Dropdown>`
|
|
882
996
|
|
|
883
997
|
Canvas-drawn dropdown select. Supports [Common Props](#common-props).
|
|
884
998
|
|
|
885
|
-
| Prop | Type |
|
|
886
|
-
| ------------------ | --------------------------------- |
|
|
887
|
-
| `width` / `height` | `number` |
|
|
888
|
-
| `options` | `Array<string \| DropdownOption>` |
|
|
889
|
-
| `value` | `string` |
|
|
890
|
-
| `defaultValue` | `string` |
|
|
891
|
-
| `placeholder` | `string` |
|
|
892
|
-
| `disabled` | `boolean` |
|
|
893
|
-
| `fontSize` | `number` |
|
|
894
|
-
| `color` | `string` |
|
|
895
|
-
| `bgColor` | `string` |
|
|
896
|
-
| `borderColor` | `string` | theme / `"#d9d9d9"` | Normal border color.
|
|
897
|
-
| `focusBorderColor` | `string` | theme / `"#1677ff"` | Opened border color.
|
|
898
|
-
| `borderRadius` | `number` |
|
|
899
|
-
| `onChange` | `(value: string) => void` |
|
|
999
|
+
| Prop | Type | Default | Description |
|
|
1000
|
+
| ------------------ | --------------------------------- | ------------------: | ------------------------------------------------------------------- |
|
|
1001
|
+
| `width` / `height` | `number` | `200` / `36` | Control size. |
|
|
1002
|
+
| `options` | `Array<string \| DropdownOption>` | Required | Option list; string options use the same value for label and value. |
|
|
1003
|
+
| `value` | `string` | — | Controlled selected value. |
|
|
1004
|
+
| `defaultValue` | `string` | — | Uncontrolled initial value. |
|
|
1005
|
+
| `placeholder` | `string` | `"Select..."` | Text shown when nothing is selected. |
|
|
1006
|
+
| `disabled` | `boolean` | `false` | Disables interaction. |
|
|
1007
|
+
| `fontSize` | `number` | `14` | Font size. |
|
|
1008
|
+
| `color` | `string` | theme / `"#333"` | Text color; the arrow fallback is `"#555"`. |
|
|
1009
|
+
| `bgColor` | `string` | theme / `"#fff"` | Control background. |
|
|
1010
|
+
| `borderColor` | `string` | theme / `"#d9d9d9"` | Normal border color. |
|
|
1011
|
+
| `focusBorderColor` | `string` | theme / `"#1677ff"` | Opened border color. |
|
|
1012
|
+
| `borderRadius` | `number` | `4` | Corner radius. |
|
|
1013
|
+
| `onChange` | `(value: string) => void` | — | Selection change callback. |
|
|
900
1014
|
|
|
901
1015
|
`DropdownOption` type:
|
|
902
1016
|
|
|
@@ -918,38 +1032,38 @@ Canvas-drawn dropdown select. Supports [Common Props](#common-props).
|
|
|
918
1032
|
|
|
919
1033
|
Canvas-drawn date input; clicking opens the browser's native date picker.
|
|
920
1034
|
|
|
921
|
-
| Prop
|
|
922
|
-
|
|
|
923
|
-
| `width` / `height`
|
|
924
|
-
| `value`
|
|
925
|
-
| `defaultValue`
|
|
926
|
-
| `placeholder`
|
|
927
|
-
| `disabled`
|
|
928
|
-
| `fontSize`
|
|
929
|
-
| `color`
|
|
930
|
-
| `bgColor`
|
|
931
|
-
| `borderColor` / `focusBorderColor` | `string`
|
|
932
|
-
| `borderRadius`
|
|
933
|
-
| `onChange`
|
|
934
|
-
| `onFocus` / `onBlur`
|
|
1035
|
+
| Prop | Type | Default | Description |
|
|
1036
|
+
| ---------------------------------- | ------------------------- | --------------------------------: | -------------------------------------------------------------- |
|
|
1037
|
+
| `width` / `height` | `number` | `200` / `36` | Control size. |
|
|
1038
|
+
| `value` | `string` | — | Controlled date value, format `YYYY-MM-DD`. |
|
|
1039
|
+
| `defaultValue` | `string` | `""` | Uncontrolled initial date value. |
|
|
1040
|
+
| `placeholder` | `string` | `"Select date"` | Text shown when nothing is selected. |
|
|
1041
|
+
| `disabled` | `boolean` | `false` | Disables date selection. |
|
|
1042
|
+
| `fontSize` | `number` | `14` | Text font size. |
|
|
1043
|
+
| `color` | `string` | theme / `"#333"` | Date text color; icon fallback is `"#666"`. |
|
|
1044
|
+
| `bgColor` | `string` | theme / `"#fff"` | Background color. |
|
|
1045
|
+
| `borderColor` / `focusBorderColor` | `string` | theme / `"#d9d9d9"` / `"#1677ff"` | Normal and focused border colors; listed colors are fallbacks. |
|
|
1046
|
+
| `borderRadius` | `number` | `4` | Corner radius. |
|
|
1047
|
+
| `onChange` | `(value: string) => void` | — | Fires when the date changes. |
|
|
1048
|
+
| `onFocus` / `onBlur` | `() => void` | — | Called when focus is gained / lost. |
|
|
935
1049
|
|
|
936
1050
|
### `<Radio>` and `<Checkbox>`
|
|
937
1051
|
|
|
938
1052
|
Both accept an `options` array; Radio is single-select and Checkbox is multi-select. String options use the same value for label and value; you may also pass `{ label, value, disabled }` objects.
|
|
939
1053
|
|
|
940
|
-
| Prop
|
|
941
|
-
|
|
|
942
|
-
| `options`
|
|
943
|
-
| `value`
|
|
944
|
-
| `defaultValue`
|
|
945
|
-
| `direction`
|
|
946
|
-
| `width` / `height`
|
|
947
|
-
| `size`
|
|
948
|
-
| `disabled`
|
|
949
|
-
| `gap` / `optionHeight`
|
|
950
|
-
| `fontSize`
|
|
951
|
-
| `color` / `activeColor` / `disabledColor` / `borderColor` | `string`
|
|
952
|
-
| `onChange`
|
|
1054
|
+
| Prop | Type | Default | Description |
|
|
1055
|
+
| --------------------------------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------: | -------------------------------------------------------------------------------- |
|
|
1056
|
+
| `options` | `Array<string \| ChoiceOption>` | Required | Option list. |
|
|
1057
|
+
| `value` | Radio: `string`; Checkbox: `string[]` | — | Controlled selected value. |
|
|
1058
|
+
| `defaultValue` | Radio: `string`; Checkbox: `string[]` | — | Uncontrolled initial value. |
|
|
1059
|
+
| `direction` | `"horizontal" \| "vertical"` | `"horizontal"` | Option layout direction. |
|
|
1060
|
+
| `width` / `height` | `number` | Auto | Control size. |
|
|
1061
|
+
| `size` | `{ width?: number; height?: number }` | — | Each dimension takes precedence over `width` / `height`. |
|
|
1062
|
+
| `disabled` | `boolean` | `false` | Disables the whole group. |
|
|
1063
|
+
| `gap` / `optionHeight` | `number` | `12` / `28` | Spacing between options and option height. |
|
|
1064
|
+
| `fontSize` | `number` | `14` | Option label font size. |
|
|
1065
|
+
| `color` / `activeColor` / `disabledColor` / `borderColor` | `string` | theme / `"#333"` / `"#1677ff"` / `"#bfbfbf"` / `"#d9d9d9"` | Label, selected, disabled option and border colors; listed colors are fallbacks. |
|
|
1066
|
+
| `onChange` | Radio: `(value: string) => void`; Checkbox: `(value: string[]) => void` | — | Fires when the selection changes. |
|
|
953
1067
|
|
|
954
1068
|
```tsx
|
|
955
1069
|
<Radio options={['Small', 'Medium', 'Large']} value={size} onChange={setSize} />
|
|
@@ -962,50 +1076,50 @@ Angular uses `<canvas-date-picker>`, `<canvas-radio>`, and `<canvas-checkbox>`;
|
|
|
962
1076
|
|
|
963
1077
|
Draggable slider. Supports [Common Props](#common-props).
|
|
964
1078
|
|
|
965
|
-
| Prop | Type |
|
|
966
|
-
| ------------------ | ------------------------- |
|
|
967
|
-
| `width` / `height` | `number` |
|
|
968
|
-
| `min` / `max` | `number` |
|
|
969
|
-
| `step` | `number` |
|
|
970
|
-
| `value` | `number` |
|
|
971
|
-
| `defaultValue` | `number` |
|
|
972
|
-
| `disabled` | `boolean` |
|
|
1079
|
+
| Prop | Type | Default | Description |
|
|
1080
|
+
| ------------------ | ------------------------- | ------------------: | ------------------------------ |
|
|
1081
|
+
| `width` / `height` | `number` | `160` / `32` | Slider size. |
|
|
1082
|
+
| `min` / `max` | `number` | `0` / `100` | Min and max values. |
|
|
1083
|
+
| `step` | `number` | `1` | Step size. |
|
|
1084
|
+
| `value` | `number` | — | Controlled value. |
|
|
1085
|
+
| `defaultValue` | `number` | `min` | Uncontrolled initial value. |
|
|
1086
|
+
| `disabled` | `boolean` | `false` | Disables dragging. |
|
|
973
1087
|
| `trackColor` | `string` | theme / `"#f0f0f0"` | Track color. |
|
|
974
1088
|
| `activeColor` | `string` | theme / `"#1677ff"` | Filled track and border color. |
|
|
975
|
-
| `thumbColor` | `string` |
|
|
976
|
-
| `onChange` | `(value: number) => void` |
|
|
1089
|
+
| `thumbColor` | `string` | theme / `"#fff"` | Thumb color. |
|
|
1090
|
+
| `onChange` | `(value: number) => void` | — | Fires when the value changes. |
|
|
977
1091
|
|
|
978
1092
|
### `<Switch>`
|
|
979
1093
|
|
|
980
1094
|
Toggle switch. Supports [Common Props](#common-props).
|
|
981
1095
|
|
|
982
|
-
| Prop | Type |
|
|
983
|
-
| ------------------ | ---------------------------- |
|
|
984
|
-
| `width` / `height` | `number` |
|
|
985
|
-
| `checked` | `boolean` |
|
|
986
|
-
| `defaultChecked` | `boolean` |
|
|
987
|
-
| `disabled` | `boolean` |
|
|
1096
|
+
| Prop | Type | Default | Description |
|
|
1097
|
+
| ------------------ | ---------------------------- | ------------------: | ----------------------------- |
|
|
1098
|
+
| `width` / `height` | `number` | `44` / `24` | Switch size. |
|
|
1099
|
+
| `checked` | `boolean` | — | Controlled checked state. |
|
|
1100
|
+
| `defaultChecked` | `boolean` | `false` | Uncontrolled initial state. |
|
|
1101
|
+
| `disabled` | `boolean` | `false` | Blocks toggling. |
|
|
988
1102
|
| `onColor` | `string` | theme / `"#1677ff"` | Track color when on. |
|
|
989
1103
|
| `offColor` | `string` | theme / `"#d9d9d9"` | Track color when off. |
|
|
990
|
-
| `thumbColor` | `string` |
|
|
991
|
-
| `onChange` | `(checked: boolean) => void` |
|
|
1104
|
+
| `thumbColor` | `string` | theme / `"#fff"` | Thumb color. |
|
|
1105
|
+
| `onChange` | `(checked: boolean) => void` | — | Fires when the state changes. |
|
|
992
1106
|
|
|
993
1107
|
### `<Button>`
|
|
994
1108
|
|
|
995
1109
|
Canvas-drawn button. Supports [Common Props](#common-props).
|
|
996
1110
|
|
|
997
|
-
| Prop | Type |
|
|
998
|
-
| ------------------ | ------------------ |
|
|
999
|
-
| `width` / `height` | `number` |
|
|
1000
|
-
| Children | `string \| number` |
|
|
1001
|
-
| `text` | `string` |
|
|
1002
|
-
| `fontSize` | `number` |
|
|
1003
|
-
| `fontColor` | `string` |
|
|
1004
|
-
| `backgroundColor` | `string` | theme / `"#1677ff"` | Background color.
|
|
1005
|
-
| `borderColor` | `string` |
|
|
1006
|
-
| `borderRadius` | `number` |
|
|
1007
|
-
| `disabled` | `boolean` |
|
|
1008
|
-
| `onClick` | `() => void` |
|
|
1111
|
+
| Prop | Type | Default | Description |
|
|
1112
|
+
| ------------------ | ------------------ | ------------------: | ---------------------------------------------------------- |
|
|
1113
|
+
| `width` / `height` | `number` | `120` / `40` | Button size. |
|
|
1114
|
+
| Children | `string \| number` | — | Button label; can be replaced by `text`. |
|
|
1115
|
+
| `text` | `string` | — | Button label; wins over `children` when both are provided. |
|
|
1116
|
+
| `fontSize` | `number` | `15` | Font size. |
|
|
1117
|
+
| `fontColor` | `string` | theme / `"#fff"` | Text color. |
|
|
1118
|
+
| `backgroundColor` | `string` | theme / `"#1677ff"` | Background color. |
|
|
1119
|
+
| `borderColor` | `string` | — | Stroke color. |
|
|
1120
|
+
| `borderRadius` | `number` | `6` | Corner radius. |
|
|
1121
|
+
| `disabled` | `boolean` | `false` | Disables the button. |
|
|
1122
|
+
| `onClick` | `() => void` | — | Click callback. |
|
|
1009
1123
|
|
|
1010
1124
|
## Image Export
|
|
1011
1125
|
|
|
@@ -1056,30 +1170,30 @@ Export size and pixel ratio must be positive numbers. If the scene contains a cr
|
|
|
1056
1170
|
|
|
1057
1171
|
Paths below are relative to `src/canvas-ui/`.
|
|
1058
1172
|
|
|
1059
|
-
| File
|
|
1060
|
-
|
|
|
1061
|
-
| `react/`
|
|
1062
|
-
| `vue/`
|
|
1063
|
-
| `svelte/`
|
|
1064
|
-
| `angular/`
|
|
1065
|
-
| `components/`
|
|
1066
|
-
| `components/types.ts`
|
|
1067
|
-
| `theme.css`
|
|
1068
|
-
| `types.ts`
|
|
1069
|
-
| `renderer.ts`
|
|
1070
|
-
| `scene.ts`
|
|
1071
|
-
| `input-bridge.ts`
|
|
1072
|
-
| `engine.ts`
|
|
1073
|
-
| `engine/transform.ts`
|
|
1074
|
-
| `engine/interaction.ts`
|
|
1075
|
-
| `engine/layout.ts`
|
|
1076
|
-
| `engine/carousel.ts`
|
|
1077
|
-
| `engine/images.ts`
|
|
1078
|
-
| `engine/text-controls.ts` | DOM input bridge synchronization.
|
|
1079
|
-
| `engine/events.ts`
|
|
1080
|
-
| `engine/hit-test.ts`
|
|
1081
|
-
| `engine/vnodes.ts`
|
|
1082
|
-
| `engine/nodes.ts`
|
|
1083
|
-
| `engine/state.ts`
|
|
1173
|
+
| File | Purpose |
|
|
1174
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
1175
|
+
| `react/` | React components and Canvas container adapter. |
|
|
1176
|
+
| `vue/` | Vue 3 components and Canvas container adapter. |
|
|
1177
|
+
| `svelte/` | Svelte 5+ adapter and template components. |
|
|
1178
|
+
| `angular/` | Angular standalone Canvas component and scene directives. |
|
|
1179
|
+
| `components/` | Shared implementations, each with its own directory, entry, Props and drawing code, and optional interaction logic. |
|
|
1180
|
+
| `components/types.ts` | Aggregates public component Props types. |
|
|
1181
|
+
| `theme.css` | Light and dark CSS theme variables for Canvas components. |
|
|
1182
|
+
| `types.ts` | Component Props, scene, Canvas, and input-bridge types. |
|
|
1183
|
+
| `renderer.ts` | Drawing registration, scene traversal, and Canvas rendering. |
|
|
1184
|
+
| `scene.ts` | Scene nodes and child reconciliation. |
|
|
1185
|
+
| `input-bridge.ts` | Transparent HTML input bridge for Input and Textarea. |
|
|
1186
|
+
| `engine.ts` | Orchestrates scene updates, rendering, input, and interaction. |
|
|
1187
|
+
| `engine/transform.ts` | Pure matrix math. |
|
|
1188
|
+
| `engine/interaction.ts` | Pointer and wheel interactions and state changes. |
|
|
1189
|
+
| `engine/layout.ts` | Declarative tree preparation and layout. |
|
|
1190
|
+
| `engine/carousel.ts` | Carousel state and animation timing. |
|
|
1191
|
+
| `engine/images.ts` | Image subscription lifecycle. |
|
|
1192
|
+
| `engine/text-controls.ts` | DOM input bridge synchronization. |
|
|
1193
|
+
| `engine/events.ts` | Public and CanvasView event dispatch. |
|
|
1194
|
+
| `engine/hit-test.ts` | Coordinate resolution and hit testing. |
|
|
1195
|
+
| `engine/vnodes.ts` | VNode tree and Grid layout helpers. |
|
|
1196
|
+
| `engine/nodes.ts` | SceneNode predicates and derived values. |
|
|
1197
|
+
| `engine/state.ts` | Internal types, EngineCore interface, and EngineState container. |
|
|
1084
1198
|
|
|
1085
1199
|
For appearance changes, edit the drawing function in `components/<Component>/<component>.ts`; place component-specific interaction logic in `logic.ts` in the same directory. For shared layout, event, or export behavior, edit the relevant adapter, `engine.ts`, or `renderer.ts`.
|