@wix/agent-skills 1.14.0 → 1.15.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 +4 -1
- package/package.json +1 -1
- package/skills/README.md +23 -0
- package/skills/wix-app/SKILL.md +10 -2
- package/skills/wix-app/references/AUTO_PATTERNS_DASHBOARD.md +326 -0
- package/skills/wix-app/references/CODE_QUALITY.md +1 -0
- package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +124 -115
- package/skills/wix-app/references/DASHBOARD_PAGE.md +3 -0
- package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +23 -9
- package/skills/wix-app/references/SITE_PLUGIN.md +1 -1
- package/skills/wix-app/references/auto-patterns-dashboard/action-cell.md +115 -0
- package/skills/wix-app/references/auto-patterns-dashboard/app-config-structure.md +264 -0
- package/skills/wix-app/references/auto-patterns-dashboard/app-context.md +37 -0
- package/skills/wix-app/references/auto-patterns-dashboard/bulk-actions.md +86 -0
- package/skills/wix-app/references/auto-patterns-dashboard/collection-page-actions.md +119 -0
- package/skills/wix-app/references/auto-patterns-dashboard/collection-page.md +103 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-actions-override.md +76 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-columns-override.md +82 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-components-override.md +89 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-header-override.md +124 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-sections-override.md +91 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-slots-override.md +71 -0
- package/skills/wix-app/references/auto-patterns-dashboard/entity-page-actions.md +70 -0
- package/skills/wix-app/references/auto-patterns-dashboard/entity-page-view-actions.md +73 -0
- package/skills/wix-app/references/auto-patterns-dashboard/entity-page.md +98 -0
- package/skills/wix-app/references/auto-patterns-dashboard/example-patterns.json +278 -0
- package/skills/wix-app/references/auto-patterns-dashboard/pages-configuration.md +94 -0
- package/skills/wix-app/references/auto-patterns-dashboard/resolved-action.md +43 -0
- package/skills/wix-app/references/auto-patterns-dashboard/sdk-utilities.md +66 -0
- package/skills/wix-app/references/auto-patterns-dashboard/views.md +76 -0
- package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +1 -14
- package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +54 -29
- package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +2 -2
- package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +17 -105
- package/skills/wix-app/references/editor-react-component/DESIGN-STATES.md +127 -0
- package/skills/wix-app/references/editor-react-component/PARTS.md +2 -1
- package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +15 -15
- package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +25 -53
- package/skills/wix-app/scripts/generate-auto-patterns.js +510 -0
- package/skills/wix-auth/SKILL.md +12 -0
- package/skills/wix-auth/references/device-flow.md +140 -0
- package/skills/wix-docs/SKILL.md +188 -0
- package/skills/wix-docs/references/API_SPEC_SEARCH.md +213 -0
- package/skills/wix-docs/references/EXTRACTING.md +120 -0
- package/skills/wix-headless/SKILL.md +84 -130
- package/skills/wix-headless/entry/bootstrap.mjs +93 -0
- package/skills/wix-headless/entry/skill.md +78 -0
- package/skills/wix-headless/references/AI_FEATURES.md +178 -0
- package/skills/wix-headless/references/CAPABILITIES.md +84 -0
- package/skills/wix-headless/references/DISCOVERY.md +34 -56
- package/skills/wix-headless/references/DOC_DISCOVERY.md +37 -0
- package/skills/wix-headless/references/FEEDBACK.md +118 -0
- package/skills/wix-headless/references/IMAGE_GENERATION.md +69 -0
- package/skills/wix-headless/references/SDK_HANDOFF.md +97 -0
- package/skills/wix-headless/references/SEED.md +44 -188
- package/skills/wix-headless/references/SETUP.md +32 -103
- package/skills/wix-headless/references/astro.md +98 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-a-blog.md +196 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-a-store.md +236 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-bookings.md +279 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-cms.md +163 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-events.md +203 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-forms.md +222 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-astro.md +124 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-custom-login.md +160 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-non-astro.md +118 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-portfolio.md +132 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-pricing-plans.md +124 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-restaurant-orders.md +188 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-restaurant-reservations.md +173 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-restaurants.md +161 -0
- package/skills/wix-headless/references/inline-recipes/setup-blog.md +175 -0
- package/skills/wix-headless/references/inline-recipes/setup-bookings.md +228 -0
- package/skills/wix-headless/references/inline-recipes/setup-cms.md +200 -0
- package/skills/wix-headless/references/inline-recipes/setup-events.md +196 -0
- package/skills/wix-headless/references/inline-recipes/setup-forms.md +174 -0
- package/skills/wix-headless/references/inline-recipes/setup-online-store.md +176 -0
- package/skills/wix-headless/references/inline-recipes/setup-portfolio.md +153 -0
- package/skills/wix-headless/references/inline-recipes/setup-pricing-plans.md +229 -0
- package/skills/wix-headless/references/inline-recipes/setup-restaurant-orders.md +161 -0
- package/skills/wix-headless/references/inline-recipes/setup-restaurant-reservations.md +117 -0
- package/skills/wix-headless/references/inline-recipes/setup-restaurants.md +152 -0
- package/skills/wix-headless/references/managed/AUTHENTICATION.md +57 -0
- package/skills/wix-headless/references/managed/CONNECT.md +74 -0
- package/skills/wix-headless/references/managed/CREATE.md +130 -0
- package/skills/wix-headless/references/managed/DEPLOYMENT.md +57 -0
- package/skills/wix-headless/references/non-astro.md +59 -0
- package/skills/wix-headless/references/self-managed/AUTHENTICATION.md +22 -0
- package/skills/wix-headless/references/self-managed/DEPLOYMENT.md +7 -0
- package/skills/wix-headless/references/stripe/AUTHENTICATION.md +55 -0
- package/skills/wix-headless/references/stripe/DEPLOYMENT.md +63 -0
- package/skills/wix-manage/SKILL.md +24 -1
- package/skills/wix-manage/references/analytics/query-site-analytics.md +241 -0
- package/skills/wix-manage/references/bookings/create-and-update-booking-services.md +1 -1
- package/skills/wix-manage/references/bookings/diagnose-availability-issues.md +265 -0
- package/skills/wix-manage/references/marketing/create-and-publish-social-post.md +436 -0
- package/skills/wix-manage/references/marketing/generate-and-publish-marketing-plan.md +209 -0
- package/skills/wix-manage/references/rich-content/author-ricos-rich-content.md +249 -0
- package/skills/wix-manage/references/stores/create-product-with-options-catalog-v3.md +51 -0
- package/skills/wix-vibe-headless/SKILL.md +136 -0
- package/skills/wix-vibe-headless/references/blog/INSTRUCTIONS.md +128 -0
- package/skills/wix-vibe-headless/references/blog/wix-blog.js +217 -0
- package/skills/wix-vibe-headless/references/bookings/INSTRUCTIONS.md +153 -0
- package/skills/wix-vibe-headless/references/bookings/wix-bookings-checkout.js +147 -0
- package/skills/wix-vibe-headless/references/bookings/wix-bookings-services.js +215 -0
- package/skills/wix-vibe-headless/references/cms/INSTRUCTIONS.md +154 -0
- package/skills/wix-vibe-headless/references/cms/wix-cms.js +186 -0
- package/skills/wix-vibe-headless/references/events/INSTRUCTIONS.md +142 -0
- package/skills/wix-vibe-headless/references/events/wix-events-browse.js +135 -0
- package/skills/wix-vibe-headless/references/events/wix-events-registration.js +187 -0
- package/skills/wix-vibe-headless/references/members/INSTRUCTIONS.md +211 -0
- package/skills/wix-vibe-headless/references/members/wix-members-auth.js +387 -0
- package/skills/wix-vibe-headless/references/portfolio/INSTRUCTIONS.md +111 -0
- package/skills/wix-vibe-headless/references/portfolio/wix-portfolio.js +194 -0
- package/skills/wix-vibe-headless/references/pricing-plans/INSTRUCTIONS.md +127 -0
- package/skills/wix-vibe-headless/references/pricing-plans/wix-pricing-plans.js +157 -0
- package/skills/wix-vibe-headless/references/restaurants/INSTRUCTIONS.md +138 -0
- package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-menu.js +224 -0
- package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-ordering.js +156 -0
- package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-reservations.js +107 -0
- package/skills/wix-vibe-headless/references/shared/wix-client.js +186 -0
- package/skills/wix-vibe-headless/references/storefront/INSTRUCTIONS.md +155 -0
- package/skills/wix-vibe-headless/references/storefront/wix-store-cart.js +147 -0
- package/skills/wix-vibe-headless/references/storefront/wix-store-catalog.js +142 -0
- package/skills/wix-headless/references/BUILD-astro.md +0 -253
- package/skills/wix-headless/references/BUILD-own-build.md +0 -167
- package/skills/wix-headless/references/BUILD.md +0 -105
- package/skills/wix-headless/references/DESIGN_SYSTEM.md +0 -165
- package/skills/wix-headless/references/DISCOVERY-connect.md +0 -55
- package/skills/wix-headless/references/DISCOVERY-create.md +0 -238
- package/skills/wix-headless/references/PLAN-connect.md +0 -19
- package/skills/wix-headless/references/PLAN-create.md +0 -17
- package/skills/wix-headless/references/PLAN.md +0 -92
- package/skills/wix-headless/references/astro/blog/BLOG_PAGES.md +0 -300
- package/skills/wix-headless/references/astro/blog/BLOG_SETUP.md +0 -218
- package/skills/wix-headless/references/astro/bookings/COMPONENTS.md +0 -45
- package/skills/wix-headless/references/astro/bookings/SERVICES_PAGES.md +0 -77
- package/skills/wix-headless/references/astro/cms/CMS_FOUNDATIONS.md +0 -214
- package/skills/wix-headless/references/astro/cms/FAQ_KNOWLEDGE_BASE.md +0 -231
- package/skills/wix-headless/references/astro/cms/PORTFOLIO.md +0 -453
- package/skills/wix-headless/references/astro/cms/RESOURCE_LIBRARY.md +0 -354
- package/skills/wix-headless/references/astro/cms/TEAM_DIRECTORY.md +0 -299
- package/skills/wix-headless/references/astro/designer/INSTRUCTIONS.md +0 -351
- package/skills/wix-headless/references/astro/ecom/CART_PAGES.md +0 -119
- package/skills/wix-headless/references/astro/ecom/CART_WIRING.md +0 -103
- package/skills/wix-headless/references/astro/ecom/COMPONENTS_CSS.md +0 -132
- package/skills/wix-headless/references/astro/forms/CONTACT_FORM.md +0 -463
- package/skills/wix-headless/references/astro/gift-cards/COMPONENTS.md +0 -119
- package/skills/wix-headless/references/astro/gift-cards/PAGES.md +0 -129
- package/skills/wix-headless/references/astro/stores/BACK_IN_STOCK.md +0 -178
- package/skills/wix-headless/references/astro/stores/CATEGORY_PAGES.md +0 -85
- package/skills/wix-headless/references/astro/stores/COMPONENTS_CSS.md +0 -129
- package/skills/wix-headless/references/astro/stores/HOME_AND_NAV.md +0 -229
- package/skills/wix-headless/references/astro/stores/PRODUCT_PAGES.md +0 -215
- package/skills/wix-headless/references/astro/stores/SHARED_WIRING.md +0 -165
- package/skills/wix-headless/references/astro/templates/Layout.astro +0 -132
- package/skills/wix-headless/references/astro/templates/astro.config.mjs +0 -41
- package/skills/wix-headless/references/astro/templates/bookings/AvailabilityCalendar.tsx +0 -374
- package/skills/wix-headless/references/astro/templates/bookings/BookingForm.tsx +0 -136
- package/skills/wix-headless/references/astro/templates/bookings/SeoTags.astro +0 -25
- package/skills/wix-headless/references/astro/templates/bookings/ServiceBookingFlow.tsx +0 -71
- package/skills/wix-headless/references/astro/templates/bookings/ServiceCard.astro +0 -54
- package/skills/wix-headless/references/astro/templates/bookings/booking-confirmation.astro +0 -49
- package/skills/wix-headless/references/astro/templates/bookings/bookingDriver.ts +0 -245
- package/skills/wix-headless/references/astro/templates/bookings/components-bookings.css +0 -424
- package/skills/wix-headless/references/astro/templates/bookings/services/[slug].astro +0 -176
- package/skills/wix-headless/references/astro/templates/bookings/services/index.astro +0 -181
- package/skills/wix-headless/references/astro/templates/ecom/CartBadge.tsx +0 -84
- package/skills/wix-headless/references/astro/templates/ecom/CartView.tsx +0 -543
- package/skills/wix-headless/references/astro/templates/ecom/cart.astro +0 -13
- package/skills/wix-headless/references/astro/templates/ecom/components-ecom.css +0 -302
- package/skills/wix-headless/references/astro/templates/ecom/discounts.ts +0 -71
- package/skills/wix-headless/references/astro/templates/ecom/thank-you.astro +0 -24
- package/skills/wix-headless/references/astro/templates/gift-cards/GiftCardPurchase.tsx +0 -172
- package/skills/wix-headless/references/astro/templates/gift-cards/_home-teaser-snippet.astro +0 -42
- package/skills/wix-headless/references/astro/templates/gift-cards/_nav-snippet.astro +0 -11
- package/skills/wix-headless/references/astro/templates/gift-cards/components-gift-cards.css +0 -220
- package/skills/wix-headless/references/astro/templates/gift-cards/gift-cards.astro +0 -51
- package/skills/wix-headless/references/astro/templates/gift-cards/gift-cards.ts +0 -75
- package/skills/wix-headless/references/astro/templates/global.css +0 -288
- package/skills/wix-headless/references/astro/templates/stores/AddToCartButton.tsx +0 -77
- package/skills/wix-headless/references/astro/templates/stores/BackInStockForm.tsx +0 -176
- package/skills/wix-headless/references/astro/templates/stores/CategoryRail.astro +0 -69
- package/skills/wix-headless/references/astro/templates/stores/ProductCard.astro +0 -79
- package/skills/wix-headless/references/astro/templates/stores/ProductPurchase.tsx +0 -397
- package/skills/wix-headless/references/astro/templates/stores/SeoTags.astro +0 -21
- package/skills/wix-headless/references/astro/templates/stores/back-in-stock.ts +0 -67
- package/skills/wix-headless/references/astro/templates/stores/categories.ts +0 -155
- package/skills/wix-headless/references/astro/templates/stores/category/[slug].astro +0 -130
- package/skills/wix-headless/references/astro/templates/stores/components-stores.css +0 -400
- package/skills/wix-headless/references/astro/templates/stores/products/[slug].astro +0 -128
- package/skills/wix-headless/references/astro/templates/stores/products/index.astro +0 -101
- package/skills/wix-headless/references/blog/BLOG_CONTENT.md +0 -161
- package/skills/wix-headless/references/blog/INSTRUCTIONS.md +0 -32
- package/skills/wix-headless/references/bookings/FLOW.md +0 -246
- package/skills/wix-headless/references/bookings/INSTRUCTIONS.md +0 -95
- package/skills/wix-headless/references/bookings/SERVICES_DATA.md +0 -355
- package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +0 -176
- package/skills/wix-headless/references/cms/INSTRUCTIONS.md +0 -71
- package/skills/wix-headless/references/commands/known-apps.json +0 -6
- package/skills/wix-headless/references/custom/CONNECTION_PLAN.md +0 -142
- package/skills/wix-headless/references/custom/INSTRUCTIONS.md +0 -88
- package/skills/wix-headless/references/custom/blog/WIRING.md +0 -52
- package/skills/wix-headless/references/custom/bookings/WIRING.md +0 -197
- package/skills/wix-headless/references/custom/cms/WIRING.md +0 -97
- package/skills/wix-headless/references/custom/ecom/WIRING.md +0 -67
- package/skills/wix-headless/references/custom/forms/WIRING.md +0 -101
- package/skills/wix-headless/references/custom/stores/WIRING.md +0 -80
- package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +0 -59
- package/skills/wix-headless/references/forms/INSTRUCTIONS.md +0 -43
- package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +0 -51
- package/skills/wix-headless/references/images/INSTRUCTIONS.md +0 -357
- package/skills/wix-headless/references/seed-recipes.md +0 -49
- package/skills/wix-headless/references/shared/AGENTS_MD.md +0 -47
- package/skills/wix-headless/references/shared/AUTHENTICATION.md +0 -108
- package/skills/wix-headless/references/shared/BUILD_NOISE.md +0 -8
- package/skills/wix-headless/references/shared/DESIGN_MD.md +0 -84
- package/skills/wix-headless/references/shared/DOCS_SEARCH.md +0 -41
- package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +0 -186
- package/skills/wix-headless/references/shared/IMPLEMENTER.md +0 -206
- package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +0 -97
- package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +0 -143
- package/skills/wix-headless/references/shared/STYLING.md +0 -140
- package/skills/wix-headless/references/stores/INSTRUCTIONS.md +0 -126
- package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +0 -252
- package/skills/wix-headless/references/verticals/_schema.json +0 -74
- package/skills/wix-headless/references/verticals/_schema.md +0 -95
- package/skills/wix-headless/references/verticals/blog.md +0 -31
- package/skills/wix-headless/references/verticals/bookings.md +0 -41
- package/skills/wix-headless/references/verticals/cms.md +0 -30
- package/skills/wix-headless/references/verticals/ecom.md +0 -25
- package/skills/wix-headless/references/verticals/forms.md +0 -26
- package/skills/wix-headless/references/verticals/gift-cards.md +0 -24
- package/skills/wix-headless/references/verticals/stores.md +0 -33
- package/skills/wix-headless/scripts/check-manifest.mjs +0 -335
- package/skills/wix-headless/scripts/compose.mjs +0 -520
- package/skills/wix-headless/scripts/emit-design-tokens.mjs +0 -157
- package/skills/wix-headless/scripts/flatten.sh +0 -61
- package/skills/wix-headless/scripts/generate-images.mjs +0 -242
- package/skills/wix-headless/scripts/patch-decorative-slots.mjs +0 -154
- package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +0 -190
- package/skills/wix-headless/scripts/scaffold.sh +0 -139
- package/skills/wix-headless/scripts/seed-utilities.sh +0 -93
- package/skills/wix-headless/scripts/write-decorative-json.mjs +0 -62
- package/skills/wix-headless/shared-utilities/analytics.ts +0 -40
- package/skills/wix-headless/shared-utilities/ricos.ts +0 -179
- package/skills/wix-headless/shared-utilities/wix-image.ts +0 -72
|
@@ -20,15 +20,68 @@ After scaffolding, edit `<name>.tsx` for the widget logic, `<name>.panel.tsx` fo
|
|
|
20
20
|
|
|
21
21
|
Wix calls `customElements.define()` for you using the builder's `tagName`; do NOT call it in your code.
|
|
22
22
|
|
|
23
|
+
Two valid patterns exist: the **native class** component (CLI default) and the **React function component** via `react-to-webcomponent`.
|
|
24
|
+
|
|
25
|
+
### Native class component (CLI default)
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import styles from './<name>.module.css';
|
|
29
|
+
|
|
30
|
+
class MyWidget extends HTMLElement {
|
|
31
|
+
static get observedAttributes() { return ['display-name']; }
|
|
32
|
+
|
|
33
|
+
constructor() { super(); }
|
|
34
|
+
|
|
35
|
+
connectedCallback() { this.render(); }
|
|
36
|
+
disconnectedCallback() { /* tear down timers, listeners */ }
|
|
37
|
+
attributeChangedCallback() { this.render(); }
|
|
38
|
+
|
|
39
|
+
render() {
|
|
40
|
+
const displayName = this.getAttribute('display-name') || "Your Widget's Title";
|
|
41
|
+
this.innerHTML = `<div class="${styles.root}"><h2>${displayName}</h2></div>`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default MyWidget;
|
|
46
|
+
```
|
|
47
|
+
|
|
23
48
|
Key authoring rules:
|
|
24
49
|
|
|
25
|
-
- Extend `HTMLElement
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
50
|
+
- Extend `HTMLElement`; export the class as the default export.
|
|
51
|
+
- `observedAttributes` must return **kebab-case** strings — HTML attributes don't preserve camelCase.
|
|
52
|
+
- Start side effects in `connectedCallback`, tear them down in `disconnectedCallback`.
|
|
53
|
+
- Call `this.render()` from `attributeChangedCallback`; always provide defaults via `getAttribute` — attributes may be `null` on first paint.
|
|
54
|
+
- Render via `this.innerHTML` (template strings) or imperative DOM, not JSX.
|
|
55
|
+
- Apply the `.root` class from `<name>.module.css` rather than hard-coding colors inline.
|
|
56
|
+
|
|
57
|
+
### React function component alternative (react-to-webcomponent)
|
|
58
|
+
|
|
59
|
+
Use this pattern when you prefer JSX, React hooks, or want to share React components between the widget and the settings panel. Install `react-to-webcomponent` if not already present: `npm install react-to-webcomponent`.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import React, { type FC } from 'react';
|
|
63
|
+
import ReactDOM from 'react-dom';
|
|
64
|
+
import reactToWebComponent from 'react-to-webcomponent';
|
|
65
|
+
import styles from './<name>.module.css';
|
|
66
|
+
|
|
67
|
+
const MyWidget: FC<{ displayName?: string }> = ({
|
|
68
|
+
displayName = "Your Widget's Title",
|
|
69
|
+
}) => (
|
|
70
|
+
<div className={styles.root}>
|
|
71
|
+
<h2>{displayName}</h2>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
export default reactToWebComponent(MyWidget, React, ReactDOM as any, {
|
|
76
|
+
props: { displayName: 'string' },
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Key authoring rules for the function component pattern:
|
|
81
|
+
|
|
82
|
+
- Define props in the `props` option of `reactToWebComponent` using **camelCase** keys. The library automatically maps kebab-case HTML attributes (e.g., `display-name`) to camelCase React props — you do not need `observedAttributes` or `attributeChangedCallback`.
|
|
83
|
+
- Use React hooks (`useState`, `useEffect`) for state and side effects.
|
|
84
|
+
- Render with JSX; use `<name>.module.css` for styles via `className`.
|
|
32
85
|
|
|
33
86
|
## Settings Panel (`<name>.panel.tsx`)
|
|
34
87
|
|
|
@@ -67,18 +120,37 @@ The CLI scaffolds the builder file with sensible defaults — edit it only to cu
|
|
|
67
120
|
|
|
68
121
|
## Props Naming Convention
|
|
69
122
|
|
|
70
|
-
|
|
123
|
+
The convention differs by pattern, but the settings panel side is always kebab-case.
|
|
71
124
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
125
|
+
**Native class component:**
|
|
126
|
+
|
|
127
|
+
| Side | Convention | Example |
|
|
128
|
+
| ---- | ---------- | ------- |
|
|
129
|
+
| `<name>.tsx` — `observedAttributes`, `getAttribute` | kebab-case | `"display-name"`, `"bg-color"` |
|
|
130
|
+
| `<name>.panel.tsx` — `widget.getProp` / `widget.setProp` | kebab-case | `"display-name"`, `"bg-color"` |
|
|
131
|
+
| Local TypeScript variables | camelCase | `displayName`, `bgColor` |
|
|
132
|
+
|
|
133
|
+
**React function component (react-to-webcomponent):** Define props with camelCase keys in the `props` option. The library handles the kebab-case ↔ camelCase mapping at the HTML attribute boundary automatically.
|
|
134
|
+
|
|
135
|
+
| Side | Convention | Example |
|
|
136
|
+
| ---- | ---------- | ------- |
|
|
137
|
+
| `reactToWebComponent` `props` option | camelCase | `{ displayName: 'string' }` |
|
|
138
|
+
| React component props interface | camelCase | `displayName?: string` |
|
|
139
|
+
| `<name>.panel.tsx` — `widget.getProp` / `widget.setProp` | kebab-case | `"display-name"`, `"bg-color"` |
|
|
77
140
|
|
|
78
141
|
## Wix Data API Integration
|
|
79
142
|
|
|
80
143
|
When using the Wix Data API in widgets, you **must** handle the Wix Editor environment gracefully — fetching data inside the Editor produces empty results and noisy errors.
|
|
81
144
|
|
|
145
|
+
**Requirements (both patterns):**
|
|
146
|
+
|
|
147
|
+
- Import `{ window as wixWindow }` from `'@wix/site-window'`.
|
|
148
|
+
- Check `await wixWindow.viewMode()` before fetching data.
|
|
149
|
+
- If `viewMode === 'Editor'`, render a placeholder instead of fetching.
|
|
150
|
+
- Only query and render real data when NOT in Editor mode.
|
|
151
|
+
|
|
152
|
+
**Native class component:**
|
|
153
|
+
|
|
82
154
|
```typescript
|
|
83
155
|
import { items } from '@wix/data';
|
|
84
156
|
import { window as wixWindow } from '@wix/site-window';
|
|
@@ -126,116 +198,52 @@ class MyWidget extends HTMLElement {
|
|
|
126
198
|
export default MyWidget;
|
|
127
199
|
```
|
|
128
200
|
|
|
129
|
-
**
|
|
130
|
-
|
|
131
|
-
- Import `{ window as wixWindow }` from `'@wix/site-window'`.
|
|
132
|
-
- Check `await wixWindow.viewMode()` before fetching data.
|
|
133
|
-
- If `viewMode === 'Editor'`, render a placeholder via `this.innerHTML` instead of fetching.
|
|
134
|
-
- Only query and render real data when NOT in Editor mode.
|
|
135
|
-
|
|
136
|
-
## Color Selection
|
|
137
|
-
|
|
138
|
-
For color selection in settings panels, use `ColorPickerField` component with `inputs.selectColor()` from `@wix/editor`. Do NOT use `<Input type="color">`.
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
// components/ColorPickerField.tsx
|
|
142
|
-
import React, { type FC } from 'react';
|
|
143
|
-
import { inputs } from '@wix/editor';
|
|
144
|
-
import { FormField, Box, FillPreview, SidePanel } from '@wix/design-system';
|
|
145
|
-
|
|
146
|
-
interface ColorPickerFieldProps {
|
|
147
|
-
label: string;
|
|
148
|
-
value: string;
|
|
149
|
-
onChange: (value: string) => void;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export const ColorPickerField: FC<ColorPickerFieldProps> = ({
|
|
153
|
-
label,
|
|
154
|
-
value,
|
|
155
|
-
onChange,
|
|
156
|
-
}) => (
|
|
157
|
-
<SidePanel.Field>
|
|
158
|
-
<FormField label={label}>
|
|
159
|
-
<Box width="30px" height="30px">
|
|
160
|
-
<FillPreview
|
|
161
|
-
fill={value}
|
|
162
|
-
onClick={() => inputs.selectColor(value, { onChange: (val) => { if (val) onChange(val); } })}
|
|
163
|
-
/>
|
|
164
|
-
</Box>
|
|
165
|
-
</FormField>
|
|
166
|
-
</SidePanel.Field>
|
|
167
|
-
);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Usage in panel:
|
|
201
|
+
**React function component** — use `useEffect` for the viewMode check and data fetch:
|
|
171
202
|
|
|
172
203
|
```typescript
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
204
|
+
const [results, setResults] = useState<string[]>([]);
|
|
205
|
+
const [isEditor, setIsEditor] = useState(false);
|
|
206
|
+
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
wixWindow.viewMode().then((viewMode) => {
|
|
209
|
+
if (viewMode === 'Editor') { setIsEditor(true); return; }
|
|
210
|
+
items.query(collectionId).limit(10).find()
|
|
211
|
+
.then(({ items: data }) => setResults(data.map((item) => item.title as string)))
|
|
212
|
+
.catch((err) => console.error('Failed to load data:', err));
|
|
213
|
+
});
|
|
214
|
+
}, [collectionId]);
|
|
215
|
+
|
|
216
|
+
// render: if (isEditor) return <placeholder />; else return <results />;
|
|
179
217
|
```
|
|
180
218
|
|
|
181
|
-
|
|
219
|
+
## Color & Font Pickers
|
|
182
220
|
|
|
183
|
-
|
|
221
|
+
Use native Wix pickers — never `<Input type="color">` or a plain text input.
|
|
184
222
|
|
|
185
|
-
|
|
223
|
+
| Picker | API | Preview component | Value type |
|
|
224
|
+
|--------|-----|-------------------|------------|
|
|
225
|
+
| Color | `inputs.selectColor(value, { onChange })` from `@wix/editor` | `<FillPreview fill={value} onClick={...} />` | `string` |
|
|
226
|
+
| Font | `inputs.selectFont(value, { onChange })` from `@wix/editor` | `<Button onClick={...}>Change Font</Button>` | `{ font: string; textDecoration: string }` — store as `JSON.stringify()` |
|
|
186
227
|
|
|
187
228
|
```typescript
|
|
188
|
-
//
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export const FontPickerField: FC<FontPickerFieldProps> = ({
|
|
205
|
-
label,
|
|
206
|
-
value,
|
|
207
|
-
onChange,
|
|
208
|
-
}) => (
|
|
209
|
-
<SidePanel.Field>
|
|
210
|
-
<FormField label={label}>
|
|
211
|
-
<Button
|
|
212
|
-
size="small"
|
|
213
|
-
priority="secondary"
|
|
214
|
-
onClick={() => inputs.selectFont(value, { onChange: (val) => onChange({ font: val.font, textDecoration: val.textDecoration || "" }) })}
|
|
215
|
-
fullWidth
|
|
216
|
-
>
|
|
217
|
-
<Text size="small" ellipsis>Change Font</Text>
|
|
218
|
-
</Button>
|
|
219
|
-
</FormField>
|
|
220
|
-
</SidePanel.Field>
|
|
221
|
-
);
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Usage in panel:
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
const [font, setFont] = useState<FontValue>({ font: "", textDecoration: "" });
|
|
228
|
-
|
|
229
|
-
const handleFontChange = (value: FontValue) => {
|
|
230
|
-
setFont(value);
|
|
231
|
-
widget.setProp("font", JSON.stringify(value));
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
<FontPickerField label="Text Font" value={font} onChange={handleFontChange} />
|
|
229
|
+
// Color — inside a SidePanel.Field > FormField
|
|
230
|
+
<FillPreview
|
|
231
|
+
fill={bgColor}
|
|
232
|
+
onClick={() => inputs.selectColor(bgColor, {
|
|
233
|
+
onChange: (val) => { if (val) { setBgColor(val); widget.setProp('bg-color', val); } }
|
|
234
|
+
})}
|
|
235
|
+
/>
|
|
236
|
+
|
|
237
|
+
// Font — inside a SidePanel.Field > FormField
|
|
238
|
+
<Button onClick={() => inputs.selectFont(font, {
|
|
239
|
+
onChange: (val) => {
|
|
240
|
+
const next = { font: val.font, textDecoration: val.textDecoration || '' };
|
|
241
|
+
setFont(next);
|
|
242
|
+
widget.setProp('font', JSON.stringify(next));
|
|
243
|
+
}
|
|
244
|
+
})}>Change Font</Button>
|
|
235
245
|
```
|
|
236
246
|
|
|
237
|
-
**Important:** Use `inputs.selectFont(value, { onChange })` from `@wix/editor` with the callback pattern. This provides a rich font picker dialog with bold, italic, size, and typography features. Font values are stored as JSON strings.
|
|
238
|
-
|
|
239
247
|
## Examples
|
|
240
248
|
|
|
241
249
|
### Countdown Timer Widget
|
|
@@ -276,7 +284,8 @@ Avoid generic aesthetics. Create distinctive designs with unique fonts (avoid In
|
|
|
276
284
|
|
|
277
285
|
## Custom-element-specific Conventions
|
|
278
286
|
|
|
279
|
-
-
|
|
287
|
+
- **Native class (CLI default):** Widget extends `HTMLElement` and renders via `this.innerHTML`. Use kebab-case throughout (`observedAttributes`, `getAttribute`, `getProp`, `setProp`).
|
|
288
|
+
- **React function component alternative:** Widget uses a React FC converted via `react-to-webcomponent`. Use camelCase in the `props` option; the library handles kebab-case HTML attributes automatically. The settings panel side still uses kebab-case with `getProp`/`setProp`.
|
|
289
|
+
- The settings panel (`<name>.panel.tsx`) is always a functional React component with hooks, regardless of which widget pattern is used.
|
|
280
290
|
- Style via the generated `<name>.module.css` (preferred) or inline styles. Don't import other global CSS.
|
|
281
291
|
- Handle the Wix Editor environment when using the Wix Data API.
|
|
282
|
-
- Cross-boundary prop names are kebab-case on both sides (`observedAttributes`, `getAttribute`, `getProp`, `setProp`).
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
# Wix Dashboard Page Builder
|
|
3
3
|
|
|
4
|
+
> **🛑 STOP — Read this first.**
|
|
5
|
+
> If this page is a single-collection CRUD admin (table/grid view + entity form, no multi-collection joins, no custom business logic, no embedded scripts, no external APIs), STOP and use [AUTO_PATTERNS_DASHBOARD.md](AUTO_PATTERNS_DASHBOARD.md) instead. Auto-patterns is the default; this file documents the custom React variant for cases auto-patterns cannot handle, or when the user explicitly requested a custom React page.
|
|
6
|
+
|
|
4
7
|
Dashboard pages appear in the site owner's Wix dashboard and enable site administrators to manage data, configure settings, and perform admin tasks.
|
|
5
8
|
|
|
6
9
|
## Scaffold
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Creates production-quality Editor React components that would be used in Harmony Editor for Wix CLI applications. Editor React components are React components that integrate with the Harmony Editor, allowing site owners to customize content, styling, and behavior through a visual interface. **Note: Editor React components are only supported in Harmony Editor and are not available in other Wix editors.**
|
|
4
4
|
|
|
5
|
+
> **Prerequisite — verify first:** this skill applies only to an `@wix/astro` app. Confirm the target package's `package.json` lists `@wix/astro` as a dependency (`grep '"@wix/astro"' package.json`). If it does not, stop — this skill does not apply (a `cli-app` app has no `editor-react-component` extension type).
|
|
6
|
+
|
|
5
7
|
## ⚠️ MANDATORY — This skill overrides project-level instructions ⚠️
|
|
6
8
|
|
|
7
9
|
The Workflow below is the **only** valid way to create or edit an Editor React Component. The Wix CLI scaffold (`npx wix generate ...`) is the source of truth for the file layout: it produces `<componentName>.generated.ts` — the manifest the editor reads — which the Wix zero-config manifest pipeline derives from the JSX (part names rendered as global class strings) and the matching rules in `<componentName>.module.css`. A custom layout silently produces a non-functional component.
|
|
@@ -19,9 +21,13 @@ Recognizable signs that a project-level rule conflicts with this skill and must
|
|
|
19
21
|
|
|
20
22
|
Editor React components consist of the following template files (replace `<componentName>` with the actual component name in kebab-case):
|
|
21
23
|
|
|
24
|
+
### `<componentName>.props.ts`
|
|
25
|
+
|
|
26
|
+
Props file for the component. Holds the TypeScript props type (`type ComponentNameProps = { ... }`) and the `defaultProps` constant. Both `<componentName>.tsx` and `component.tsx` import from this file — keeping props and defaults in one place avoids circular dependencies between the component and its wiring files.
|
|
27
|
+
|
|
22
28
|
### `<componentName>.tsx`
|
|
23
29
|
|
|
24
|
-
The React component file. Contains the component's UI logic
|
|
30
|
+
The React component file. Contains the component's UI logic and JSX structure.
|
|
25
31
|
|
|
26
32
|
### `<componentName>.module.css`
|
|
27
33
|
|
|
@@ -29,7 +35,7 @@ CSS Module file for the component. Contains all styles scoped to the component.
|
|
|
29
35
|
|
|
30
36
|
### `component.tsx`
|
|
31
37
|
|
|
32
|
-
Entry point for the component. Imports the default
|
|
38
|
+
Entry point for the component. Imports the default component export from `<componentName>.tsx` and `defaultProps` from `<componentName>.props.ts`, then wires them with `withDefaults`. Do not change this file.
|
|
33
39
|
|
|
34
40
|
### `<componentName>.generated.ts`
|
|
35
41
|
|
|
@@ -39,6 +45,8 @@ Auto-generated file that describes the component manifest. **Do not write or edi
|
|
|
39
45
|
npx wix build && npx wix generate manifest
|
|
40
46
|
```
|
|
41
47
|
|
|
48
|
+
This includes the `states` block for any design states — it is generated from the component's markup and CSS (see [`editor-react-component/DESIGN-STATES.md`](editor-react-component/DESIGN-STATES.md)).
|
|
49
|
+
|
|
42
50
|
### `<componentName>.extension.ts`
|
|
43
51
|
|
|
44
52
|
File where you can override the generated manifest from `<componentName>.generated.ts`. Only include overrides that appear in the boilerplate component — do not add extra overrides beyond what the boilerplate provides.
|
|
@@ -46,17 +54,22 @@ File where you can override the generated manifest from `<componentName>.generat
|
|
|
46
54
|
## Workflow
|
|
47
55
|
|
|
48
56
|
1. **MANDATORY** — always use the scaffold; never substitute with manual file creation.
|
|
49
|
-
If `src/site/components/component-name/` does not yet exist, run
|
|
50
|
-
`npx wix generate --params '{"extensionType":"EDITOR_REACT_COMPONENT","name":"ComponentName","folder":"component-name","description":"A brief description of what the component does"}'` to scaffold it. Skip this
|
|
57
|
+
If `src/extensions/site/components/component-name/` does not yet exist, run
|
|
58
|
+
`npx wix generate --params '{"extensionType":"EDITOR_REACT_COMPONENT","name":"ComponentName","folder":"component-name","description":"A brief description of what the component does"}'` to scaffold it. The scaffold creates the files under `src/extensions/site/components/<folder>/` and registers the component in `src/extensions.ts`; edit them there (not under `src/site/components/`). Skip this
|
|
51
59
|
step when iterating on an existing component — re-running it would
|
|
52
60
|
return "an extension already exist" error.
|
|
53
61
|
2. Run the following script to verify that the component dependencies are installed properly:
|
|
54
|
-
`[[ -d "node_modules/@wix/react-component-schema" && -d "node_modules/@wix/react-component-utils" && -d "node_modules/@wix/editor-react-types" ]] ||
|
|
62
|
+
`[[ -d "node_modules/@wix/react-component-schema" && -d "node_modules/@wix/react-component-utils" && -d "node_modules/@wix/editor-react-types" ]] || { d="$PWD"; while [ "$d" != "/" ] && [ ! -f "$d/yarn.lock" ]; do d="${d%/*}"; done; { [ -f "$d/yarn.lock" ] && yarn add @wix/react-component-schema @wix/react-component-utils @wix/editor-react-types; } || npm install @wix/react-component-schema @wix/react-component-utils @wix/editor-react-types; }`
|
|
55
63
|
3. Edit the generated react and CSS files in
|
|
56
|
-
`src/site/components/
|
|
64
|
+
`src/extensions/site/components/component-name/`.
|
|
57
65
|
4. Run `npx wix build && npx wix generate manifest` so the editor picks up
|
|
58
66
|
the new/updated prop schema. This command regenerates manifest
|
|
59
|
-
parts for all components.
|
|
67
|
+
parts for all components. Design-states emission requires
|
|
68
|
+
`@wix/cli` ≥ 1.1.215 (native and class-triggered states work from
|
|
69
|
+
≥ 1.1.210, but prop-triggered `ElementState` states need ≥ 1.1.215). If a
|
|
70
|
+
design state is missing from `<componentName>.generated.ts`, the installed
|
|
71
|
+
CLI is older than required — tell the user, and let them decide whether to
|
|
72
|
+
upgrade.
|
|
60
73
|
5. Update `Component.extensions.ts` file according to [`editor-react-component/COMPONENT-CONFIGURATION.md`](editor-react-component/COMPONENT-CONFIGURATION.md)
|
|
61
74
|
|
|
62
75
|
Reference: when modifying an _existing_ component, follow
|
|
@@ -69,12 +82,13 @@ Core rules and workflow: [`editor-react-component/REACT-GUIDELINES.md`](editor-r
|
|
|
69
82
|
Topic-focused references (rules + patterns + common mistakes in one place):
|
|
70
83
|
|
|
71
84
|
- [`editor-react-component/ACCESSIBILITY.md`](editor-react-component/ACCESSIBILITY.md) — ARIA/a11y rules and patterns
|
|
85
|
+
- [`editor-react-component/DESIGN-STATES.md`](editor-react-component/DESIGN-STATES.md) — Which design states a part supports (heuristic) and how to author them
|
|
72
86
|
- [`editor-react-component/DIRECTIONALITY.md`](editor-react-component/DIRECTIONALITY.md) — RTL/LTR rules and patterns
|
|
73
87
|
- [`editor-react-component/PROPS-VS-CSS.md`](editor-react-component/PROPS-VS-CSS.md) — What should be a React prop vs CSS
|
|
74
88
|
- [`editor-react-component/COMPONENT-API.md`](editor-react-component/COMPONENT-API.md) — Props structure, elementProps, data types, file splitting, containers, array props
|
|
75
|
-
- [`editor-react-component/
|
|
76
|
-
- [`editor-react-component/REACT-PATTERNS.md`](editor-react-component/REACT-PATTERNS.md) — CSS rules, remaining common mistakes
|
|
89
|
+
- [`editor-react-component/REACT-PATTERNS.md`](editor-react-component/REACT-PATTERNS.md) — SSR-safe patterns, CSS rules, remaining common mistakes
|
|
77
90
|
|
|
78
91
|
## CSS guidelines
|
|
79
92
|
|
|
80
93
|
Reference: [`editor-react-component/CSS-GUIDELINES.md`](editor-react-component/CSS-GUIDELINES.md).
|
|
94
|
+
|
|
@@ -34,7 +34,7 @@ Settings panel shown in the Wix Editor sidebar:
|
|
|
34
34
|
|
|
35
35
|
### 3. Extension Builder (`<plugin-name>.extension.ts`)
|
|
36
36
|
|
|
37
|
-
Generated by the CLI with placements, tagName, element/settings paths, marketData (name/description/logoUrl), and `installation.autoAdd`. Edit `marketData.description` and `installation.autoAdd` directly in this file after scaffolding if defaults don't match your needs.
|
|
37
|
+
Generated by the CLI with placements, tagName, element/settings paths, marketData (name/description/logoUrl), and `installation.autoAdd`. Edit `marketData.description` and `installation.autoAdd` directly in this file after scaffolding if defaults don't match your needs. `marketData.description` must stay under 130 characters.
|
|
38
38
|
|
|
39
39
|
## Plugin Component Pattern
|
|
40
40
|
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# ActionCell Rules
|
|
2
|
+
|
|
3
|
+
## Type Definitions
|
|
4
|
+
```typescript
|
|
5
|
+
interface ActionCellConfig {
|
|
6
|
+
primaryAction?: SinglePrimary | MultiplePrimary;
|
|
7
|
+
secondaryActions?: {
|
|
8
|
+
items: (ActionCellItem | DividerItem)[];
|
|
9
|
+
inlineCount?: number;
|
|
10
|
+
inlineAlwaysVisible?: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SinglePrimary {
|
|
15
|
+
item: ActionCellItem;
|
|
16
|
+
alwaysVisible?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface MultiplePrimary {
|
|
20
|
+
items: ActionCellItem[];
|
|
21
|
+
alwaysVisible?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ActionCellItem {
|
|
25
|
+
id: string; // Matches resolver if custom
|
|
26
|
+
type: 'update' | 'delete' | 'custom';
|
|
27
|
+
label?: string;
|
|
28
|
+
biName: string; // MANDATORY
|
|
29
|
+
skin?: 'standard' | 'inverted' | 'premium' | 'dark' | 'destructive';
|
|
30
|
+
update?: { mode: 'page'; page: { id: string } };
|
|
31
|
+
delete?: { mode: 'modal'; modal: ModalConfig };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface DividerItem {
|
|
35
|
+
type: 'divider';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Primary cell action resolver — primary actions don't accept `icon`; use `prefixIcon`/`suffixIcon`.
|
|
39
|
+
type CustomActionCellPrimaryActionResolver = (params: {
|
|
40
|
+
actionParams: { item: any };
|
|
41
|
+
sdk: AutoPatternsSDK;
|
|
42
|
+
}) => ResolvedActionCellPrimaryAction;
|
|
43
|
+
// ResolvedActionCellPrimaryAction = Omit<ResolvedAction, 'icon'> & { prefixIcon?: IconElement; suffixIcon?: IconElement }
|
|
44
|
+
|
|
45
|
+
// Secondary cell action resolver — uses standard ResolvedAction (with `icon`).
|
|
46
|
+
type CustomActionCellSecondaryActionResolver = (params: {
|
|
47
|
+
actionParams: { item: any };
|
|
48
|
+
sdk: AutoPatternsSDK;
|
|
49
|
+
}) => ResolvedAction;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Validation Logic
|
|
53
|
+
- **IF** `type: 'update'` **THEN** `update` config with `page.id` is **REQUIRED**.
|
|
54
|
+
- **IF** `type: 'delete'` **THEN** `delete.mode: 'modal'` is **REQUIRED**.
|
|
55
|
+
- **IF** `type: 'custom'` **THEN** resolver implementation is **REQUIRED**.
|
|
56
|
+
- **IF** `type: 'custom'` **THEN** resolver MUST be registered via override pattern (see **custom_actions_override**).
|
|
57
|
+
- **IF** using `secondaryActions.inlineCount` **THEN** value MUST be <= items count.
|
|
58
|
+
|
|
59
|
+
## Implementation Rules
|
|
60
|
+
- **MUST** include `biName` for every action (`{action-purpose}-action`).
|
|
61
|
+
- **MUST** place `actionCell` at component level (sibling to `collection`), NOT inside `table`/`grid`.
|
|
62
|
+
- **MUST** implement custom resolvers using `CustomActionCellPrimaryActionResolver` (for primary actions) or `CustomActionCellSecondaryActionResolver` (for secondary actions).
|
|
63
|
+
- **MUST** use `errorHandler` for Wix API calls in resolvers.
|
|
64
|
+
- **SHOULD** use `multiplePrimary` for 2-3 equally important actions.
|
|
65
|
+
- **NEVER** use `primaryAction` inside `secondaryActions`.
|
|
66
|
+
- **NEVER** use `actionResolvers` prop on `AutoPatternsApp` - this prop does not exist.
|
|
67
|
+
- **NEVER** create resolver files outside `components/actions/` folder.
|
|
68
|
+
|
|
69
|
+
## Canonical Example
|
|
70
|
+
```typescript
|
|
71
|
+
// Config
|
|
72
|
+
actionCell: {
|
|
73
|
+
primaryAction: {
|
|
74
|
+
item: {
|
|
75
|
+
id: 'editItem',
|
|
76
|
+
type: 'update',
|
|
77
|
+
label: 'Edit',
|
|
78
|
+
biName: 'edit-action',
|
|
79
|
+
skin: 'standard',
|
|
80
|
+
update: { mode: 'page', page: { id: 'edit-page' } }
|
|
81
|
+
},
|
|
82
|
+
alwaysVisible: true
|
|
83
|
+
},
|
|
84
|
+
secondaryActions: {
|
|
85
|
+
items: [
|
|
86
|
+
{
|
|
87
|
+
id: 'deleteItem',
|
|
88
|
+
type: 'delete',
|
|
89
|
+
label: 'Delete',
|
|
90
|
+
biName: 'delete-action',
|
|
91
|
+
skin: 'destructive',
|
|
92
|
+
delete: { mode: 'modal', modal: {} }
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Resolvers (if custom) - see custom_actions_override for full registration pattern
|
|
99
|
+
|
|
100
|
+
// Primary action resolver: use prefixIcon (icon is not allowed on primary cell actions)
|
|
101
|
+
export const myPrimaryAction: CustomActionCellPrimaryActionResolver = ({ actionParams }) => ({
|
|
102
|
+
label: 'Custom',
|
|
103
|
+
prefixIcon: <MyIcon />,
|
|
104
|
+
biName: 'custom-action',
|
|
105
|
+
onClick: () => console.log(actionParams.item)
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Secondary action resolver: uses icon
|
|
109
|
+
export const mySecondaryAction: CustomActionCellSecondaryActionResolver = ({ actionParams }) => ({
|
|
110
|
+
label: 'Custom',
|
|
111
|
+
icon: <MyIcon />,
|
|
112
|
+
biName: 'custom-action',
|
|
113
|
+
onClick: () => console.log(actionParams.item)
|
|
114
|
+
});
|
|
115
|
+
```
|