@embeddables/cli 0.7.1 → 0.7.3
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.
|
@@ -44,7 +44,7 @@ Pages are stored in `Flow.pages` and transform to React page files. The `FlowPag
|
|
|
44
44
|
|
|
45
45
|
**File Mapping**: `pages/{pageKey}.page.tsx` (e.g., `pages/welcome_page.page.tsx`)
|
|
46
46
|
|
|
47
|
-
**React Structure**: Each page file
|
|
47
|
+
**React Structure**: Each page file must start with `'use client'` at the top, then imports, then export a default React component that renders the page's components as JSX.
|
|
48
48
|
|
|
49
49
|
## Global Components Structure
|
|
50
50
|
|
|
@@ -76,7 +76,7 @@ All component types are derived from `src/types-builder.ts`. The relevant typing
|
|
|
76
76
|
|
|
77
77
|
**Key Base Properties** (all components have these):
|
|
78
78
|
|
|
79
|
-
- `id: string` - Unique identifier
|
|
79
|
+
- `id: string` - Unique identifier — must be unique across the entire Embeddable JSON. Always snake*case. Use the ID format convention (e.g. `comp*` + 10 digits for components; see Important Notes).
|
|
80
80
|
- `key: string` - Unique identifier, used in React as key prop - unique in general but duplicate keys can be used in certain cases (e.g. two `email` fields, each hidden by conditions). Always snake_case. **Keys must not start with a digit** (invalid in JS/JSON). When deriving a key from text that would start with a number (e.g. "1 to 2 weeks" → "1_to_2_weeks"), use a semantic prefix instead: e.g. `range_1_to_2_weeks`, `option_1_to_2_weeks`, or the component key like `delivery_time_1_to_2_weeks`.
|
|
81
81
|
- `type: ComponentType` - Component type
|
|
82
82
|
- `tags?: string[]` - Used for CSS styling
|
|
@@ -191,7 +191,7 @@ This pattern improves readability and makes the buttons array easier to maintain
|
|
|
191
191
|
|
|
192
192
|
Styles are stored in `Flow.styles` as a map of CSS selectors to style objects. The `FlowStyles` type is defined in `src/types-builder.ts`.
|
|
193
193
|
|
|
194
|
-
**File Mapping**:
|
|
194
|
+
**File Mapping**: `styles/index.css` — a single CSS file containing all selectors for this flow.
|
|
195
195
|
|
|
196
196
|
### CSS Selector System
|
|
197
197
|
|
|
@@ -578,6 +578,7 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
578
578
|
### React Files (Pages)
|
|
579
579
|
|
|
580
580
|
- Location: `pages/{pageKey}.page.tsx`
|
|
581
|
+
- Directive: Start the file with `'use client'` at the top
|
|
581
582
|
- Export: **Default export** of React component (e.g., `export default function PageName()`)
|
|
582
583
|
- Props: Component props match JSON properties
|
|
583
584
|
- Keys: All components must have `id` and `key` props matching component `id` and `key` properties respectively
|
|
@@ -591,7 +592,7 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
591
592
|
|
|
592
593
|
### CSS Files
|
|
593
594
|
|
|
594
|
-
- Location: `styles/
|
|
595
|
+
- Location: `styles/index.css` — a single CSS file for the flow (do not create multiple CSS files)
|
|
595
596
|
- Format: Standard CSS with selector as class name
|
|
596
597
|
- Content: Style properties from `Flow.styles[selector]`
|
|
597
598
|
|
|
@@ -619,7 +620,7 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
619
620
|
3. **Component Types**:
|
|
620
621
|
- Use `PlainText` by default
|
|
621
622
|
- Use `RichTextMarkdown` only for mixed formatting (bold, italic, lists, links, colors)
|
|
622
|
-
- Use `CustomHTML` for
|
|
623
|
+
- Use `CustomHTML` for presentational content only (overlays, inline SVGs, decorative HTML). **Caution**: CustomHTML is for presentational content only. For interactive elements like buttons or selectable options, always use `CustomButton` or `OptionSelector` — CustomHTML elements have no access to flow actions or user data outputs.
|
|
623
624
|
|
|
624
625
|
4. **Nested Components**: Containers can have `components[]` array with child components. Render as nested JSX.
|
|
625
626
|
|
|
@@ -637,6 +638,13 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
637
638
|
|
|
638
639
|
## Common Patterns
|
|
639
640
|
|
|
641
|
+
### Adding a New Page
|
|
642
|
+
|
|
643
|
+
1. Create `pages/{pageKey}.page.tsx` with `'use client'` at the top and a default export.
|
|
644
|
+
2. Add an entry to `config.json` under `pages[]` — required fields: `id`, `key`, `tags[]`.
|
|
645
|
+
3. Add CSS for the page tag in `styles/index.css` if new layout styles are needed.
|
|
646
|
+
4. Use a unique page ID: generate a numeric string like `"page_1234567890"` (see **ID format** under Important Notes). Must be unique across the flow.
|
|
647
|
+
|
|
640
648
|
### Adding a Component to a Page
|
|
641
649
|
|
|
642
650
|
1. Update the page's React file (`pages/{pageKey}.page.tsx`)
|
|
@@ -672,7 +680,7 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
672
680
|
|
|
673
681
|
## Important Notes
|
|
674
682
|
|
|
675
|
-
- **IDs**: All components, pages, computed fields, actions, and buttons inside OptionSelectors have unique `id` properties. These are preserved in config.json and used for internal references, except for component and button ids which should always be written in React
|
|
683
|
+
- **IDs**: All components, pages, computed fields, actions, and buttons inside OptionSelectors have unique `id` properties. These are preserved in config.json and used for internal references, except for component and button ids which should always be written in React. **ID format**: Use a prefix plus 10 digits so generated IDs don't collide with real ones: pages → `page_` + 10 digits (e.g. `page_1234567890`); components → `comp_` + 10 digits; option buttons → `button_` prefix (e.g. `button_plan_basic`). Must be unique across the flow.
|
|
676
684
|
|
|
677
685
|
- **Keys**: Component and page `key` properties are used for file naming and must be valid file names (no special characters, use underscores).
|
|
678
686
|
|
package/dist/compiler/reverse.js
CHANGED
|
@@ -1218,16 +1218,16 @@ function htmlToJSXChildren(html, indent) {
|
|
|
1218
1218
|
if (!attrMatch[0].includes('=')) {
|
|
1219
1219
|
continue;
|
|
1220
1220
|
}
|
|
1221
|
-
//
|
|
1222
|
-
// Normalize classname (wrong serialization) to
|
|
1221
|
+
// In CustomHTML we emit HTML-like attribute names (class, for, tabindex) so the
|
|
1222
|
+
// TSX matches the serialized HTML. Normalize classname (wrong serialization) to class.
|
|
1223
1223
|
let jsxAttrName = attrName;
|
|
1224
1224
|
const attrLower = attrName.toLowerCase();
|
|
1225
1225
|
if (attrLower === 'class' || attrLower === 'classname')
|
|
1226
|
-
jsxAttrName = '
|
|
1226
|
+
jsxAttrName = 'class';
|
|
1227
1227
|
else if (attrLower === 'for')
|
|
1228
|
-
jsxAttrName = '
|
|
1228
|
+
jsxAttrName = 'for';
|
|
1229
1229
|
else if (attrLower === 'tabindex')
|
|
1230
|
-
jsxAttrName = '
|
|
1230
|
+
jsxAttrName = 'tabindex';
|
|
1231
1231
|
// Handle style attribute: convert CSS string to JSX object
|
|
1232
1232
|
if (attrName === 'style' && attrValue) {
|
|
1233
1233
|
const styleObj = cssStringToStyleObject(attrValue);
|