solid-tom-ui 1.0.10 → 1.0.14

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.
Files changed (120) hide show
  1. package/README.md +246 -246
  2. package/dist/README.md +246 -246
  3. package/dist/components/avatar/avatar.js.map +1 -1
  4. package/dist/components/badge/badge.js.map +1 -1
  5. package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
  6. package/dist/components/button/button.js.map +1 -1
  7. package/dist/components/carousel/carousel.js.map +1 -1
  8. package/dist/components/chat-bubble/chatBubble.js.map +1 -1
  9. package/dist/components/checkbox/checkbox.js.map +1 -1
  10. package/dist/components/collapse/collapse.js.map +1 -1
  11. package/dist/components/context-menu/context-menu.js.map +1 -1
  12. package/dist/components/context-menu/context-menu.store.js.map +1 -1
  13. package/dist/components/divider/divider.js.map +1 -1
  14. package/dist/components/dropdown/dropdown.js.map +1 -1
  15. package/dist/components/dropdown/dropdown.store.js.map +1 -1
  16. package/dist/components/float-button/float-button.js.map +1 -1
  17. package/dist/components/hover-3d-image/hover-3d-image.js.map +1 -1
  18. package/dist/components/image-preview/image-preview.js.map +1 -1
  19. package/dist/components/input/input.js.map +1 -1
  20. package/dist/components/input/input.utils.js.map +1 -1
  21. package/dist/components/input/variants/input-color.js.map +1 -1
  22. package/dist/components/input/variants/input-date.js.map +1 -1
  23. package/dist/components/input/variants/input-number.d.ts.map +1 -1
  24. package/dist/components/input/variants/input-number.js +1 -1
  25. package/dist/components/input/variants/input-number.js.map +1 -1
  26. package/dist/components/input/variants/input-otp.js.map +1 -1
  27. package/dist/components/input/variants/input-password.js.map +1 -1
  28. package/dist/components/input/variants/input-radio.js.map +1 -1
  29. package/dist/components/input/variants/input-range.js.map +1 -1
  30. package/dist/components/input/variants/input-text.d.ts.map +1 -1
  31. package/dist/components/input/variants/input-text.js +1 -1
  32. package/dist/components/input/variants/input-text.js.map +1 -1
  33. package/dist/components/input/variants/input-textarea.js.map +1 -1
  34. package/dist/components/loading/loading.js.map +1 -1
  35. package/dist/components/mansory/mansory.js.map +1 -1
  36. package/dist/components/menu/menu.js.map +1 -1
  37. package/dist/components/menu/menu.types.d.ts +2 -3
  38. package/dist/components/menu/menu.types.d.ts.map +1 -1
  39. package/dist/components/modal/modal.js.map +1 -1
  40. package/dist/components/modal/modalContext.js.map +1 -1
  41. package/dist/components/pagination/pagination.js.map +1 -1
  42. package/dist/components/progress-bar/progress-bar.js.map +1 -1
  43. package/dist/components/qr-code/qr-code.js.map +1 -1
  44. package/dist/components/select/select.js.map +1 -1
  45. package/dist/components/select-zone/select-zone.js.map +1 -1
  46. package/dist/components/skeleton/skeleton.js.map +1 -1
  47. package/dist/components/slider/slider.js.map +1 -1
  48. package/dist/components/splitter/splitter.js.map +1 -1
  49. package/dist/components/steps/steps.js.map +1 -1
  50. package/dist/components/swap/swap.js.map +1 -1
  51. package/dist/components/switch/switch.js.map +1 -1
  52. package/dist/components/tab/tab.js.map +1 -1
  53. package/dist/components/table/table.js.map +1 -1
  54. package/dist/components/timeline/timeline.js.map +1 -1
  55. package/dist/components/toast/icons/ErrorIcon.js.map +1 -1
  56. package/dist/components/toast/icons/IconCircle.js.map +1 -1
  57. package/dist/components/toast/icons/InfoIcon.js.map +1 -1
  58. package/dist/components/toast/icons/LoaderIcon.js.map +1 -1
  59. package/dist/components/toast/icons/SuccessIcon.js.map +1 -1
  60. package/dist/components/toast/icons/WarningIcon.js.map +1 -1
  61. package/dist/components/toast/toast.js.map +1 -1
  62. package/dist/components/toast/toast.store.js.map +1 -1
  63. package/dist/components/tooltip/tooltip.js.map +1 -1
  64. package/dist/components/tour/tour.js.map +1 -1
  65. package/dist/components/upload/upload.js.map +1 -1
  66. package/dist/components/z-index/z-index.context.js.map +1 -1
  67. package/dist/components/z-index/z-index.js.map +1 -1
  68. package/dist/components/z-index/z-index.store.js.map +1 -1
  69. package/dist/components/z-index/z-index.types.js.map +1 -1
  70. package/dist/package.json +1 -1
  71. package/dist/skill/avatar.skill.md.txt +255 -255
  72. package/dist/skill/badge.skill.md.txt +223 -223
  73. package/dist/skill/breadcrumb.skill.md.txt +177 -177
  74. package/dist/skill/button.skill.md.txt +198 -198
  75. package/dist/skill/carousel.skill.md.txt +406 -406
  76. package/dist/skill/chat-bubble.skill.md.txt +342 -342
  77. package/dist/skill/checkbox.skill.md.txt +326 -326
  78. package/dist/skill/code-preview.skill.md.txt +240 -240
  79. package/dist/skill/collapse.skill.md.txt +329 -329
  80. package/dist/skill/context-menu.skill.md.txt +233 -233
  81. package/dist/skill/diff.skill.md.txt +244 -244
  82. package/dist/skill/divider.skill.md.txt +151 -151
  83. package/dist/skill/doc.skill.md.txt +191 -191
  84. package/dist/skill/drawer.skill.md.txt +157 -157
  85. package/dist/skill/dropdown.skill.md.txt +198 -198
  86. package/dist/skill/float-button.skill.md.txt +315 -315
  87. package/dist/skill/hover-3d-image.skill.md.txt +120 -120
  88. package/dist/skill/iframe.skill.md.txt +114 -114
  89. package/dist/skill/image-preview.skill.md.txt +162 -162
  90. package/dist/skill/indicator.skill.md.txt +60 -60
  91. package/dist/skill/input.skill.md.txt +489 -489
  92. package/dist/skill/loading.skill.md.txt +127 -127
  93. package/dist/skill/menu.skill.md.txt +476 -476
  94. package/dist/skill/modal.skill.md.txt +359 -359
  95. package/dist/skill/pagination.skill.md.txt +405 -405
  96. package/dist/skill/progress-bar.skill.md.txt +207 -207
  97. package/dist/skill/qr-code.skill.md.txt +136 -136
  98. package/dist/skill/rating.skill.md.txt +167 -167
  99. package/dist/skill/select-zone.skill.md.txt +93 -93
  100. package/dist/skill/select.skill.md.txt +663 -663
  101. package/dist/skill/skeleton.skill.md.txt +192 -192
  102. package/dist/skill/slider.skill.md.txt +404 -404
  103. package/dist/skill/splitter.skill.md.txt +411 -411
  104. package/dist/skill/steps.skill.md.txt +264 -264
  105. package/dist/skill/swap.skill.md.txt +139 -139
  106. package/dist/skill/switch.skill.md.txt +191 -191
  107. package/dist/skill/tab.skill.md.txt +484 -484
  108. package/dist/skill/table.example.header.md.txt +666 -666
  109. package/dist/skill/table.skill.md.txt +1407 -1407
  110. package/dist/skill/text-rotate.skill.md.txt +186 -186
  111. package/dist/skill/timeline.skill.md.txt +247 -247
  112. package/dist/skill/toast.skill.md.txt +531 -531
  113. package/dist/skill/tooltip.skill.md.txt +222 -222
  114. package/dist/skill/tour.skill.md.txt +156 -156
  115. package/dist/skill/upload.skill.md.txt +358 -358
  116. package/dist/utils/cn.js.map +1 -1
  117. package/dist/utils/element-tracker.js.map +1 -1
  118. package/dist/utils/helper.js.map +1 -1
  119. package/dist/utils/hoc.js.map +1 -1
  120. package/package.json +132 -133
@@ -1,120 +1,120 @@
1
- ## COMPONENT IDENTITY
2
- - **Import**: `import { Hover3DImage } from 'solid-tom-ui';`
3
- - **Export**: `Hover3DImage` (named export)
4
- - **Framework**: SolidJS
5
- - **Purpose**: Interactive 3D tilt image card — responds to mouse movement with a CSS perspective effect; requires global `hover-3d` CSS class
6
-
7
- ## TYPE SIGNATURE
8
-
9
- ```typescript
10
- import { Hover3DImage } from 'solid-tom-ui';
11
- import type { Image } from 'solid-tom-ui';
12
-
13
- <Hover3DImage
14
- image={Image} // REQUIRED: image descriptor object
15
- class?={Partial<Record<'root' | 'figure' | 'image', string>>} // optional per-slot class overrides
16
- />
17
- ```
18
-
19
- ### `Image` type (from `@/utils/helper`)
20
- ```typescript
21
- type Image = {
22
- src: string; // image URL
23
- alt?: string; // alt text
24
- class?: string; // class on the <img> element
25
- [key: string]: any; // other img attributes (width, height, loading, etc.)
26
- }
27
- ```
28
-
29
- ## INTERNAL STRUCTURE
30
- ```
31
- div.hover-3d[class.root]
32
- figure.rounded-2xl[class.figure]
33
- img[...image props][class.image] ← spreads all Image props onto <img>
34
- div × 8 ← required overlay divs for 3D CSS effect
35
- ```
36
- > The 9 child divs (1 figure + 8 empty divs) are structural requirements for the CSS 3D hover effect. Do NOT remove or reorder them.
37
-
38
- ## USAGE PATTERNS
39
-
40
- ### Basic usage
41
- ```tsx
42
- import { Hover3DImage } from 'solid-tom-ui';
43
-
44
- <Hover3DImage
45
- image={{ src: '/images/product.jpg', alt: 'Product showcase' }}
46
- />
47
- ```
48
-
49
- ### With width constraint on image
50
- ```tsx
51
- <Hover3DImage
52
- image={{
53
- src: 'https://example.com/photo.jpg',
54
- alt: '3D card',
55
- class: 'w-[500px]',
56
- }}
57
- />
58
- ```
59
-
60
- ### With layout centering
61
- ```tsx
62
- <Hover3DImage
63
- class={{ root: 'mx-auto' }}
64
- image={{ src: '/hero.jpg', alt: 'Hero image', class: 'w-full' }}
65
- />
66
- ```
67
-
68
- ### With custom figure and image classes
69
- ```tsx
70
- <Hover3DImage
71
- image={{ src: '/banner.webp', alt: 'Banner', class: 'object-cover h-64' }}
72
- class={{
73
- root: 'max-w-md',
74
- figure: 'shadow-xl',
75
- image: 'rounded-xl',
76
- }}
77
- />
78
- ```
79
-
80
- ## CLASS SLOTS
81
- | Slot | Targets | Notes |
82
- |------|---------|-------|
83
- | `root` | `div.hover-3d` | Outermost wrapper — use for sizing/positioning |
84
- | `figure` | `figure` | Always has `rounded-2xl`; extend here for shadow, overflow, etc. |
85
- | `image` | `img` | Applied via `image.class` prop (not via `class.image` — `class.image` is not wired in current impl) |
86
-
87
- > **Note**: `class.image` slot is declared in the type but the `<img>` element only spreads the `image` object props. To add classes to the `<img>`, put them in `image.class`.
88
-
89
- ## CONSTRAINTS
90
- - The component requires the `hover-3d` CSS utility class to be globally available. Ensure the project's global stylesheet includes the 3D hover animation rules.
91
- - The 8 empty `<div>` children inside `.hover-3d` are part of the CSS trick (grid/overlay for mouse tracking). They must not be conditionally removed.
92
- - This component is purely presentational — no internal state or events.
93
-
94
- ## ANTI-PATTERNS
95
- ```tsx
96
- // ❌ Missing required image prop
97
- <Hover3DImage />
98
-
99
- // ❌ Trying to class the img via class.image (not wired)
100
- <Hover3DImage image={{ src: '...' }} class={{ image: 'w-64' }} />
101
- // ✅ Correct: put image class inside the image object
102
- <Hover3DImage image={{ src: '...', class: 'w-64' }} />
103
-
104
- // ❌ Wrapping in another container that constrains height unexpectedly
105
- // ✅ Use class.root for sizing instead
106
- <Hover3DImage image={{ src: '...' }} class={{ root: 'w-72' }} />
107
- ```
108
-
109
- ## DECISION RULES
110
- - Use this component for hero images, product showcases, or any image that benefits from an interactive 3D tilt effect on hover.
111
- - Control the image size via `image.class` (e.g., `class: 'w-[400px]'`).
112
- - Control component placement/layout via `class.root`.
113
- - Control card shape/shadow via `class.figure`.
114
- ---
115
-
116
- ## Component Conventions
117
-
118
- > **CSS encoding**: internal CSS classes use short encoded names (e.g. `h301`, `h302`) per project convention.
119
-
120
- > **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
1
+ ## COMPONENT IDENTITY
2
+ - **Import**: `import { Hover3DImage } from 'solid-tom-ui';`
3
+ - **Export**: `Hover3DImage` (named export)
4
+ - **Framework**: SolidJS
5
+ - **Purpose**: Interactive 3D tilt image card — responds to mouse movement with a CSS perspective effect; requires global `hover-3d` CSS class
6
+
7
+ ## TYPE SIGNATURE
8
+
9
+ ```typescript
10
+ import { Hover3DImage } from 'solid-tom-ui';
11
+ import type { Image } from 'solid-tom-ui';
12
+
13
+ <Hover3DImage
14
+ image={Image} // REQUIRED: image descriptor object
15
+ class?={Partial<Record<'root' | 'figure' | 'image', string>>} // optional per-slot class overrides
16
+ />
17
+ ```
18
+
19
+ ### `Image` type (from `@/utils/helper`)
20
+ ```typescript
21
+ type Image = {
22
+ src: string; // image URL
23
+ alt?: string; // alt text
24
+ class?: string; // class on the <img> element
25
+ [key: string]: any; // other img attributes (width, height, loading, etc.)
26
+ }
27
+ ```
28
+
29
+ ## INTERNAL STRUCTURE
30
+ ```
31
+ div.hover-3d[class.root]
32
+ figure.rounded-2xl[class.figure]
33
+ img[...image props][class.image] ← spreads all Image props onto <img>
34
+ div × 8 ← required overlay divs for 3D CSS effect
35
+ ```
36
+ > The 9 child divs (1 figure + 8 empty divs) are structural requirements for the CSS 3D hover effect. Do NOT remove or reorder them.
37
+
38
+ ## USAGE PATTERNS
39
+
40
+ ### Basic usage
41
+ ```tsx
42
+ import { Hover3DImage } from 'solid-tom-ui';
43
+
44
+ <Hover3DImage
45
+ image={{ src: '/images/product.jpg', alt: 'Product showcase' }}
46
+ />
47
+ ```
48
+
49
+ ### With width constraint on image
50
+ ```tsx
51
+ <Hover3DImage
52
+ image={{
53
+ src: 'https://example.com/photo.jpg',
54
+ alt: '3D card',
55
+ class: 'w-[500px]',
56
+ }}
57
+ />
58
+ ```
59
+
60
+ ### With layout centering
61
+ ```tsx
62
+ <Hover3DImage
63
+ class={{ root: 'mx-auto' }}
64
+ image={{ src: '/hero.jpg', alt: 'Hero image', class: 'w-full' }}
65
+ />
66
+ ```
67
+
68
+ ### With custom figure and image classes
69
+ ```tsx
70
+ <Hover3DImage
71
+ image={{ src: '/banner.webp', alt: 'Banner', class: 'object-cover h-64' }}
72
+ class={{
73
+ root: 'max-w-md',
74
+ figure: 'shadow-xl',
75
+ image: 'rounded-xl',
76
+ }}
77
+ />
78
+ ```
79
+
80
+ ## CLASS SLOTS
81
+ | Slot | Targets | Notes |
82
+ |------|---------|-------|
83
+ | `root` | `div.hover-3d` | Outermost wrapper — use for sizing/positioning |
84
+ | `figure` | `figure` | Always has `rounded-2xl`; extend here for shadow, overflow, etc. |
85
+ | `image` | `img` | Applied via `image.class` prop (not via `class.image` — `class.image` is not wired in current impl) |
86
+
87
+ > **Note**: `class.image` slot is declared in the type but the `<img>` element only spreads the `image` object props. To add classes to the `<img>`, put them in `image.class`.
88
+
89
+ ## CONSTRAINTS
90
+ - The component requires the `hover-3d` CSS utility class to be globally available. Ensure the project's global stylesheet includes the 3D hover animation rules.
91
+ - The 8 empty `<div>` children inside `.hover-3d` are part of the CSS trick (grid/overlay for mouse tracking). They must not be conditionally removed.
92
+ - This component is purely presentational — no internal state or events.
93
+
94
+ ## ANTI-PATTERNS
95
+ ```tsx
96
+ // ❌ Missing required image prop
97
+ <Hover3DImage />
98
+
99
+ // ❌ Trying to class the img via class.image (not wired)
100
+ <Hover3DImage image={{ src: '...' }} class={{ image: 'w-64' }} />
101
+ // ✅ Correct: put image class inside the image object
102
+ <Hover3DImage image={{ src: '...', class: 'w-64' }} />
103
+
104
+ // ❌ Wrapping in another container that constrains height unexpectedly
105
+ // ✅ Use class.root for sizing instead
106
+ <Hover3DImage image={{ src: '...' }} class={{ root: 'w-72' }} />
107
+ ```
108
+
109
+ ## DECISION RULES
110
+ - Use this component for hero images, product showcases, or any image that benefits from an interactive 3D tilt effect on hover.
111
+ - Control the image size via `image.class` (e.g., `class: 'w-[400px]'`).
112
+ - Control component placement/layout via `class.root`.
113
+ - Control card shape/shadow via `class.figure`.
114
+ ---
115
+
116
+ ## Component Conventions
117
+
118
+ > **CSS encoding**: internal CSS classes use short encoded names (e.g. `h301`, `h302`) per project convention.
119
+
120
+ > **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
@@ -1,114 +1,114 @@
1
- ## COMPONENT IDENTITY
2
- - **Import**: `import { Iframe } from 'solid-tom-ui';`
3
- - **Export**: `Iframe` (named export)
4
- - **Framework**: SolidJS
5
- - **Purpose**: Renders a SolidJS component inside a sandboxed `<iframe>` — inherits parent styles, sets up event delegation, and preserves reactivity across the iframe boundary
6
-
7
- ## PURPOSE
8
- Renders a SolidJS component inside a sandboxed `<iframe>` element while:
9
- 1. Cloning all parent `<style>` and `<link rel="stylesheet">` tags into the iframe `<head>` so styles are inherited.
10
- 2. Setting up SolidJS event delegation inside the iframe document (`click`, `mousedown`, `input`, `change`, `focus`, `blur`).
11
- 3. Running the component under the parent's reactive owner context, preserving reactivity and signal updates across the iframe boundary.
12
-
13
- ## TYPE SIGNATURE
14
-
15
- ```typescript
16
- import { Iframe } from 'solid-tom-ui';
17
- import { SolidComponent } from '@/type';
18
-
19
- <Iframe
20
- element={SolidComponent} // REQUIRED: a SolidJS component (not JSX, not an element — the component function itself)
21
- />
22
- ```
23
-
24
- ### `SolidComponent` type (from `@/type`)
25
- ```typescript
26
- type SolidComponent = Component<any> | (() => JSX.Element);
27
- ```
28
-
29
- ## INTERNAL BEHAVIOR
30
- - The iframe has class `size-full` (fills its parent container).
31
- - Mounting is deferred by `setTimeout(..., 200)` to wait for the iframe DOM to be ready.
32
- - The component is rendered via `render(props.element as () => Element, iframeDoc.body)`.
33
-
34
- ## USAGE PATTERNS
35
-
36
- ### Basic: render a component in an isolated iframe
37
- ```tsx
38
- import { Iframe } from '@/components/iframe';
39
- import { MyWidget } from '@/components/my-widget';
40
-
41
- // Wrap in a sized container — Iframe fills 100% of its parent
42
- <div class="h-64 w-full border rounded">
43
- <Iframe element={MyWidget} />
44
- </div>
45
- ```
46
-
47
- ### Render an inline arrow function component
48
- ```tsx
49
- const PreviewContent = () => (
50
- <div class="p-4 bg-base-100">
51
- <p>This renders inside an iframe</p>
52
- </div>
53
- );
54
-
55
- <div class="h-96 w-full">
56
- <Iframe element={PreviewContent} />
57
- </div>
58
- ```
59
-
60
- ### Use case: component preview sandbox (e.g., documentation page)
61
- ```tsx
62
- import { CodePreview } from '@/components/doc/CodePreview';
63
- import { Iframe } from '@/components/iframe';
64
-
65
- // Wrapping a preview inside Iframe ensures style isolation
66
- <div class="h-80 overflow-hidden rounded-lg border">
67
- <Iframe element={() => <SomeExampleComponent />} />
68
- </div>
69
- ```
70
-
71
- ## CONSTRAINTS
72
- - **Pass the component function, NOT rendered JSX.** `element` expects a component reference or factory function, not `<MyWidget />`.
73
- ```tsx
74
- // ✅ Correct
75
- <Iframe element={MyWidget} />
76
- <Iframe element={() => <MyWidget someProp="value" />} />
77
-
78
- // ❌ Wrong — passing already-rendered JSX
79
- <Iframe element={<MyWidget />} />
80
- ```
81
- - **Iframe fills its parent** via `size-full` (`width: 100%; height: 100%`). Always wrap it in a container with explicit dimensions.
82
- - **Mounting delay**: the component renders after ~200ms. Do not rely on immediate DOM availability.
83
- - **No scrollbars by default**: the iframe body inherits styles from the parent. Add `overflow: auto` to the rendered component if scrolling is needed.
84
- - **No cross-origin support**: this component only works for same-origin content (it directly accesses `contentDocument`).
85
-
86
- ## ANTI-PATTERNS
87
- ```tsx
88
- // ❌ No wrapper size — iframe renders but is invisible (0 height)
89
- <Iframe element={MyWidget} />
90
-
91
- // ✅ Always provide a sized wrapper
92
- <div class="h-64 w-full">
93
- <Iframe element={MyWidget} />
94
- </div>
95
-
96
- // ❌ Passing JSX instead of component function
97
- <Iframe element={<MyWidget />} />
98
-
99
- // ✅ Pass component reference or factory
100
- <Iframe element={MyWidget} />
101
- <Iframe element={() => <MyWidget foo="bar" />} />
102
- ```
103
-
104
- ## DECISION RULES
105
- - Use `Iframe` when you need to render a SolidJS component in a visually isolated sandbox (e.g., live component previews, documentation demos, embedded widgets).
106
- - Do NOT use `Iframe` for external URLs — it only renders SolidJS components inside the iframe body.
107
- - For component demos in documentation, prefer wrapping with `<div class="h-[desired-height] w-full">` around `<Iframe>`.
108
- ---
109
-
110
- ## Component Conventions
111
-
112
- > **CSS encoding**: internal CSS classes use short encoded names (e.g. `if01`, `if02`) per project convention.
113
-
114
- > **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
1
+ ## COMPONENT IDENTITY
2
+ - **Import**: `import { Iframe } from 'solid-tom-ui';`
3
+ - **Export**: `Iframe` (named export)
4
+ - **Framework**: SolidJS
5
+ - **Purpose**: Renders a SolidJS component inside a sandboxed `<iframe>` — inherits parent styles, sets up event delegation, and preserves reactivity across the iframe boundary
6
+
7
+ ## PURPOSE
8
+ Renders a SolidJS component inside a sandboxed `<iframe>` element while:
9
+ 1. Cloning all parent `<style>` and `<link rel="stylesheet">` tags into the iframe `<head>` so styles are inherited.
10
+ 2. Setting up SolidJS event delegation inside the iframe document (`click`, `mousedown`, `input`, `change`, `focus`, `blur`).
11
+ 3. Running the component under the parent's reactive owner context, preserving reactivity and signal updates across the iframe boundary.
12
+
13
+ ## TYPE SIGNATURE
14
+
15
+ ```typescript
16
+ import { Iframe } from 'solid-tom-ui';
17
+ import { SolidComponent } from '@/type';
18
+
19
+ <Iframe
20
+ element={SolidComponent} // REQUIRED: a SolidJS component (not JSX, not an element — the component function itself)
21
+ />
22
+ ```
23
+
24
+ ### `SolidComponent` type (from `@/type`)
25
+ ```typescript
26
+ type SolidComponent = Component<any> | (() => JSX.Element);
27
+ ```
28
+
29
+ ## INTERNAL BEHAVIOR
30
+ - The iframe has class `size-full` (fills its parent container).
31
+ - Mounting is deferred by `setTimeout(..., 200)` to wait for the iframe DOM to be ready.
32
+ - The component is rendered via `render(props.element as () => Element, iframeDoc.body)`.
33
+
34
+ ## USAGE PATTERNS
35
+
36
+ ### Basic: render a component in an isolated iframe
37
+ ```tsx
38
+ import { Iframe } from '@/components/iframe';
39
+ import { MyWidget } from '@/components/my-widget';
40
+
41
+ // Wrap in a sized container — Iframe fills 100% of its parent
42
+ <div class="h-64 w-full border rounded">
43
+ <Iframe element={MyWidget} />
44
+ </div>
45
+ ```
46
+
47
+ ### Render an inline arrow function component
48
+ ```tsx
49
+ const PreviewContent = () => (
50
+ <div class="p-4 bg-base-100">
51
+ <p>This renders inside an iframe</p>
52
+ </div>
53
+ );
54
+
55
+ <div class="h-96 w-full">
56
+ <Iframe element={PreviewContent} />
57
+ </div>
58
+ ```
59
+
60
+ ### Use case: component preview sandbox (e.g., documentation page)
61
+ ```tsx
62
+ import { CodePreview } from '@/components/doc/CodePreview';
63
+ import { Iframe } from '@/components/iframe';
64
+
65
+ // Wrapping a preview inside Iframe ensures style isolation
66
+ <div class="h-80 overflow-hidden rounded-lg border">
67
+ <Iframe element={() => <SomeExampleComponent />} />
68
+ </div>
69
+ ```
70
+
71
+ ## CONSTRAINTS
72
+ - **Pass the component function, NOT rendered JSX.** `element` expects a component reference or factory function, not `<MyWidget />`.
73
+ ```tsx
74
+ // ✅ Correct
75
+ <Iframe element={MyWidget} />
76
+ <Iframe element={() => <MyWidget someProp="value" />} />
77
+
78
+ // ❌ Wrong — passing already-rendered JSX
79
+ <Iframe element={<MyWidget />} />
80
+ ```
81
+ - **Iframe fills its parent** via `size-full` (`width: 100%; height: 100%`). Always wrap it in a container with explicit dimensions.
82
+ - **Mounting delay**: the component renders after ~200ms. Do not rely on immediate DOM availability.
83
+ - **No scrollbars by default**: the iframe body inherits styles from the parent. Add `overflow: auto` to the rendered component if scrolling is needed.
84
+ - **No cross-origin support**: this component only works for same-origin content (it directly accesses `contentDocument`).
85
+
86
+ ## ANTI-PATTERNS
87
+ ```tsx
88
+ // ❌ No wrapper size — iframe renders but is invisible (0 height)
89
+ <Iframe element={MyWidget} />
90
+
91
+ // ✅ Always provide a sized wrapper
92
+ <div class="h-64 w-full">
93
+ <Iframe element={MyWidget} />
94
+ </div>
95
+
96
+ // ❌ Passing JSX instead of component function
97
+ <Iframe element={<MyWidget />} />
98
+
99
+ // ✅ Pass component reference or factory
100
+ <Iframe element={MyWidget} />
101
+ <Iframe element={() => <MyWidget foo="bar" />} />
102
+ ```
103
+
104
+ ## DECISION RULES
105
+ - Use `Iframe` when you need to render a SolidJS component in a visually isolated sandbox (e.g., live component previews, documentation demos, embedded widgets).
106
+ - Do NOT use `Iframe` for external URLs — it only renders SolidJS components inside the iframe body.
107
+ - For component demos in documentation, prefer wrapping with `<div class="h-[desired-height] w-full">` around `<Iframe>`.
108
+ ---
109
+
110
+ ## Component Conventions
111
+
112
+ > **CSS encoding**: internal CSS classes use short encoded names (e.g. `if01`, `if02`) per project convention.
113
+
114
+ > **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.