@happyvertical/smrt-products 0.60.16 → 0.60.17
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/dist/lib/chunks/{__smrt-register__-DCxRzaaR.js → __smrt-register__-CfedXJ8n.js} +2 -2
- package/dist/lib/chunks/{__smrt-register__-DCxRzaaR.js.map → __smrt-register__-CfedXJ8n.js.map} +1 -1
- package/dist/lib/chunks/{collections-CdoY699J.js → collections-CH8P9U_s.js} +2 -2
- package/dist/lib/chunks/{collections-CdoY699J.js.map → collections-CH8P9U_s.js.map} +1 -1
- package/dist/lib/chunks/{components-DMJz1geh.js → components-j1pkLwKV.js} +14 -14
- package/dist/lib/chunks/components-j1pkLwKV.js.map +1 -0
- package/dist/lib/chunks/{generated-CEDw1Uka.js → generated-D6SpalT3.js} +2 -2
- package/dist/lib/chunks/{generated-CEDw1Uka.js.map → generated-D6SpalT3.js.map} +1 -1
- package/dist/lib/chunks/models-trtehGCE.js +2 -0
- package/dist/lib/collections.js +1 -1
- package/dist/lib/components.js +1 -1
- package/dist/lib/generated.js +1 -1
- package/dist/lib/index.js +5 -5
- package/dist/lib/lib/components/LiveProductList.svelte +56 -51
- package/dist/lib/lib/components/ProductCard.svelte +65 -59
- package/dist/lib/lib/components/ProductForm.svelte +55 -51
- package/dist/lib/lib/components/TestComponent.svelte +9 -3
- package/dist/lib/lib/components/auto-generated/AutoForm.svelte +52 -42
- package/dist/lib/lib/components/auto-generated/FieldRenderer.svelte +18 -18
- package/dist/lib/lib/features/CategoryManager.svelte +33 -23
- package/dist/lib/lib/features/ProductCatalog.svelte +69 -64
- package/dist/lib/manifest.json +1 -1
- package/dist/lib/models.js +1 -1
- package/dist/lib/smrt-knowledge.json +3 -3
- package/dist/lib/smrt-products.css +92 -82
- package/package.json +14 -14
- package/dist/lib/chunks/components-DMJz1geh.js.map +0 -1
- package/dist/lib/chunks/models-CCSb3kln.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections-
|
|
1
|
+
{"version":3,"file":"collections-CH8P9U_s.js","names":[],"sources":["../../../src/lib/collections/CategoryCollection.ts","../../../src/lib/collections/MaterialCollection.ts","../../../src/lib/collections/ProductVariantCollection.ts","../../../src/lib/collections/SkuCollection.ts"],"sourcesContent":["/**\n * CategoryCollection — Collection manager for {@link Category} objects.\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { Category } from '../models/Category';\n\nexport class CategoryCollection extends SmrtCollection<Category> {\n static readonly _itemClass = Category;\n\n /**\n * Return every top-level category. `parentId` on `Category` is typed\n * `string | undefined`; SMRT serializes undefined string fields as `''`\n * rather than `NULL`, so a category created without an explicit\n * `parentId` lands in the DB with `parent_id = ''`, not `parent_id IS NULL`.\n *\n * We accept both shapes — historical data, migrations, and direct DB\n * imports can produce either — so consumers don't have to normalize\n * `parentId` on write to be discoverable as a root. SQL's `IN` operator\n * does NOT match `NULL` (NULL is not equal to anything, including itself\n * inside an IN list), so the empty-string and NULL cases must run as\n * separate queries and merge.\n */\n async getRootCategories(): Promise<Category[]> {\n const [emptyParents, nullParents] = await Promise.all([\n this.list({ where: { parentId: '' } }),\n this.list({ where: { parentId: null } }),\n ]);\n\n if (emptyParents.length === 0) return nullParents;\n if (nullParents.length === 0) return emptyParents;\n\n // De-dupe by id in case a row somehow shows up in both lists.\n const seen = new Set<string>();\n const merged: Category[] = [];\n for (const row of [...emptyParents, ...nullParents]) {\n const id = row.id ?? '';\n if (!id || seen.has(id)) continue;\n seen.add(id);\n merged.push(row);\n }\n return merged;\n }\n}\n","/**\n * MaterialCollection — Collection manager for {@link Material} objects.\n *\n * STI framework auto-filters by `_meta_type` to return only Material rows\n * from the shared `products` table.\n */\n\nimport { Material } from '../models/Material';\nimport type { MaterialKind } from '../models/types';\nimport { ProductCollection } from './ProductCollection';\n\nexport class MaterialCollection extends ProductCollection {\n static override readonly _itemClass = Material;\n\n /**\n * Find every {@link Material} with the given kind.\n *\n * `materialKind` is an `@meta()` field — it lives inside the shared\n * `_meta_data` JSON column on `products`, not as its own SQL column.\n * That means a naive `list({ where: { materialKind } })` would generate\n * a WHERE on a non-existent column. We list every Material STI row and\n * filter the hydrated instances in JS.\n *\n * For very large catalogs, consumers should add a generated column or\n * an expression index over the JSON path and override this helper.\n */\n async findByKind(materialKind: MaterialKind): Promise<Material[]> {\n const items = (await this.list({})) as Material[];\n return items.filter((m) => m.materialKind === materialKind);\n }\n}\n","/**\n * ProductVariantCollection — read helpers for {@link ProductVariant} rows.\n *\n * {@link ProductVariant} is a standalone model (not a Product STI subtype),\n * so this collection drives its own table (`product_variants`). Helper\n * methods cover the two common query patterns: \"what axes does this\n * product vary along?\" and \"tell me about the size axis specifically.\"\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { ProductVariant } from '../models/ProductVariant';\n\nexport class ProductVariantCollection extends SmrtCollection<ProductVariant> {\n static readonly _itemClass = ProductVariant;\n\n /** Every axis declaration for a given product, in display order. */\n async findForProduct(productId: string): Promise<ProductVariant[]> {\n return this.list({\n where: { productId },\n orderBy: 'sortOrder ASC',\n });\n }\n\n /** The axis declaration for a `(productId, axisName)` pair, or null. */\n async findAxis(\n productId: string,\n axisName: string,\n ): Promise<ProductVariant | null> {\n const matches = await this.list({\n where: { productId, axisName },\n limit: 1,\n });\n return matches[0] ?? null;\n }\n}\n","/**\n * SkuCollection — query helpers for {@link Sku} rows.\n *\n * @packageDocumentation\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { Sku } from '../models/Sku';\n\nexport class SkuCollection extends SmrtCollection<Sku> {\n static readonly _itemClass = Sku;\n\n /**\n * Look up a SKU by its tenant-scoped `code` (UPC, internal part\n * number, etc.). Returns `null` when no row matches.\n */\n async findByCode(code: string): Promise<Sku | null> {\n const matches = await this.list({ where: { code }, limit: 1 });\n return matches[0] ?? null;\n }\n\n /**\n * Look up a SKU by its scannable barcode. Returns `null` when no row\n * matches; pass `''` to skip the query early.\n */\n async findByBarcode(barcode: string): Promise<Sku | null> {\n if (!barcode) return null;\n const matches = await this.list({ where: { barcode }, limit: 1 });\n return matches[0] ?? null;\n }\n\n /**\n * Find every SKU pointing at the given `Product` id (or any Product\n * STI subtype id — `Material` upstream, vertical subtypes defined in\n * templates). Useful for listing the SKUs that back a single product\n * card.\n */\n async findByProduct(productId: string): Promise<Sku[]> {\n return this.list({ where: { productId }, orderBy: 'code ASC' });\n }\n\n /**\n * Find every SKU that is a component of the given parent SKU (for\n * bundles / kits). Returns an empty array when the parent has no\n * children.\n */\n async findByParent(parentSkuId: string): Promise<Sku[]> {\n return this.list({ where: { parentSkuId }, orderBy: 'code ASC' });\n }\n\n /** Find every active SKU, optionally narrowed by parent product id. */\n async findActive(productId?: string): Promise<Sku[]> {\n const where: Record<string, unknown> = { active: true };\n if (productId) where.productId = productId;\n return this.list({ where, orderBy: 'code ASC' });\n }\n}\n"],"mappings":";;;;;;;;;AAOA,IAAa,qBAAb,cAAwC,eAAyB;CAC/D,OAAgB,aAAa;;;;;;;;;;;;;;CAe7B,MAAM,oBAAyC;EAC7C,MAAM,CAAC,cAAc,eAAe,MAAM,QAAQ,IAAI,CACpD,KAAK,KAAK,EAAE,OAAO,EAAE,UAAU,GAAG,EAAE,CAAC,GACrC,KAAK,KAAK,EAAE,OAAO,EAAE,UAAU,KAAK,EAAE,CAAC,CACzC,CAAC;EAED,IAAI,aAAa,WAAW,GAAG,OAAO;EACtC,IAAI,YAAY,WAAW,GAAG,OAAO;EAGrC,MAAM,uBAAO,IAAI,IAAY;EAC7B,MAAM,SAAqB,CAAC;EAC5B,KAAK,MAAM,OAAO,CAAC,GAAG,cAAc,GAAG,WAAW,GAAG;GACnD,MAAM,KAAK,IAAI,MAAM;GACrB,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,GAAG;GACzB,KAAK,IAAI,EAAE;GACX,OAAO,KAAK,GAAG;EACjB;EACA,OAAO;CACT;AACF;;;;;;;;;AChCA,IAAa,qBAAb,cAAwC,kBAAk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13 @@ import { Button } from "@happyvertical/smrt-ui/ui";
|
|
|
5
5
|
import { Form, Input, Textarea } from "@happyvertical/smrt-ui/forms";
|
|
6
6
|
import { useI18n } from "@happyvertical/smrt-ui/i18n";
|
|
7
7
|
//#region src/lib/components/ProductCard.svelte
|
|
8
|
-
var root$1 = $.from_html(`<div class="product-
|
|
9
|
-
var root_1$1 = $.from_html(`<div class="product-
|
|
10
|
-
var root_2$1 = $.from_html(`<p class="product-
|
|
11
|
-
var root_3 = $.from_html(`<div class="product-
|
|
12
|
-
var root_4 = $.from_html(`<span class="
|
|
13
|
-
var root_5 = $.from_html(`<div class="product-
|
|
14
|
-
var root_6 = $.from_html(`<div class="product-
|
|
8
|
+
var root$1 = $.from_html(`<div class="smrt-product-card__manufacturer svelte-11ja2cl" data-smrt-part="meta"> </div>`);
|
|
9
|
+
var root_1$1 = $.from_html(`<div class="smrt-product-card__model svelte-11ja2cl" data-smrt-part="meta"> </div>`);
|
|
10
|
+
var root_2$1 = $.from_html(`<p class="smrt-product-card__description svelte-11ja2cl" data-smrt-part="body"> </p>`);
|
|
11
|
+
var root_3 = $.from_html(`<div class="smrt-product-card__category svelte-11ja2cl" data-smrt-part="badge"> </div>`);
|
|
12
|
+
var root_4 = $.from_html(`<span class="smrt-product-card__tag svelte-11ja2cl" data-smrt-part="item"> </span>`);
|
|
13
|
+
var root_5 = $.from_html(`<div class="smrt-product-card__tags svelte-11ja2cl" data-smrt-part="list"></div>`);
|
|
14
|
+
var root_6 = $.from_html(`<div class="smrt-product-card__root svelte-11ja2cl" data-smrt-component="ProductCard"><div class="smrt-product-card__header svelte-11ja2cl" data-smrt-part="header"><h3 class="smrt-product-card__name svelte-11ja2cl" data-smrt-part="title"> </h3> <!></div> <!> <!> <div class="smrt-product-card__meta svelte-11ja2cl" data-smrt-part="group"><!> <!></div> <div class="smrt-product-card__actions svelte-11ja2cl" data-smrt-part="actions"><!> <!></div></div>`);
|
|
15
15
|
function ProductCard($$anchor, $$props) {
|
|
16
16
|
$.push($$props, true);
|
|
17
17
|
var div = root_6();
|
|
@@ -121,9 +121,9 @@ function ProductCard($$anchor, $$props) {
|
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/lib/components/ProductForm.svelte
|
|
124
|
-
var root = $.from_html(`<span class="
|
|
125
|
-
var root_1 = $.from_html(`<div class="
|
|
126
|
-
var root_2 = $.from_html(`<div class="product-
|
|
124
|
+
var root = $.from_html(`<span class="smrt-product-form__error-message svelte-1hh5ovx" data-smrt-part="error"> </span>`);
|
|
125
|
+
var root_1 = $.from_html(`<div class="smrt-product-form__field svelte-1hh5ovx" data-smrt-part="field"><label for="name" class="svelte-1hh5ovx"> </label> <!> <!></div> <div class="smrt-product-form__field svelte-1hh5ovx" data-smrt-part="field"><label for="description" class="svelte-1hh5ovx">Description</label> <!></div> <div class="smrt-product-form__row svelte-1hh5ovx" data-smrt-part="row"><div class="smrt-product-form__field svelte-1hh5ovx" data-smrt-part="field"><label for="price" class="svelte-1hh5ovx">Price *</label> <!> <!></div> <div class="smrt-product-form__field svelte-1hh5ovx" data-smrt-part="field"><label for="category" class="svelte-1hh5ovx">Category</label> <!></div></div> <div class="smrt-product-form__field svelte-1hh5ovx" data-smrt-part="field"><label for="tags" class="svelte-1hh5ovx">Tags</label> <!> <small class="smrt-product-form__hint svelte-1hh5ovx" data-smrt-part="description"> </small></div> <div class="smrt-product-form__field svelte-1hh5ovx" data-smrt-part="field"><label class="smrt-product-form__checkbox-label svelte-1hh5ovx" data-smrt-part="label"><input type="checkbox" class="smrt-product-form__checkbox svelte-1hh5ovx" data-smrt-part="input"/> </label></div> <div class="smrt-product-form__actions svelte-1hh5ovx" data-smrt-part="actions"><!> <!></div>`, 1);
|
|
126
|
+
var root_2 = $.from_html(`<div class="smrt-product-form__root svelte-1hh5ovx" data-smrt-component="ProductForm"><!></div>`);
|
|
127
127
|
function ProductForm($$anchor, $$props) {
|
|
128
128
|
$.push($$props, true);
|
|
129
129
|
const { t } = useI18n();
|
|
@@ -164,7 +164,7 @@ function ProductForm($$anchor, $$props) {
|
|
|
164
164
|
var div = root_2();
|
|
165
165
|
Form($.child(div), {
|
|
166
166
|
onsubmit: handleSubmit,
|
|
167
|
-
class: "product-
|
|
167
|
+
class: "smrt-product-form__form",
|
|
168
168
|
children: ($$anchor, $$slotProps) => {
|
|
169
169
|
var fragment = root_1();
|
|
170
170
|
var div_1 = $.first_child(fragment);
|
|
@@ -172,7 +172,7 @@ function ProductForm($$anchor, $$props) {
|
|
|
172
172
|
var text = $.only_child(label, true);
|
|
173
173
|
var node_1 = $.sibling(label, 2);
|
|
174
174
|
{
|
|
175
|
-
let $0 = $.derived(() => $.get(errors).name ? "
|
|
175
|
+
let $0 = $.derived(() => $.get(errors).name ? "smrt-product-form__error" : "");
|
|
176
176
|
let $1 = $.derived(() => t(M["products.product_form.name_placeholder"]));
|
|
177
177
|
Input(node_1, {
|
|
178
178
|
id: "name",
|
|
@@ -231,7 +231,7 @@ function ProductForm($$anchor, $$props) {
|
|
|
231
231
|
var div_4 = $.child(div_3);
|
|
232
232
|
var node_4 = $.sibling($.child(div_4), 2);
|
|
233
233
|
{
|
|
234
|
-
let $0 = $.derived(() => $.get(errors).price ? "
|
|
234
|
+
let $0 = $.derived(() => $.get(errors).price ? "smrt-product-form__error" : "");
|
|
235
235
|
Input(node_4, {
|
|
236
236
|
id: "price",
|
|
237
237
|
type: "number",
|
|
@@ -389,4 +389,4 @@ function ProductForm($$anchor, $$props) {
|
|
|
389
389
|
//#endregion
|
|
390
390
|
export { ProductCard as n, ProductForm as t };
|
|
391
391
|
|
|
392
|
-
//# sourceMappingURL=components-
|
|
392
|
+
//# sourceMappingURL=components-j1pkLwKV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-j1pkLwKV.js","names":[],"sources":["../../../src/lib/components/ProductCard.svelte","../../../src/lib/components/ProductForm.svelte"],"sourcesContent":["<script lang=\"ts\">\nimport { Button } from '@happyvertical/smrt-ui/ui';\nimport type { ProductData } from '../types';\n\ninterface Props {\n /** The product to display. */\n product: ProductData;\n /** Fired when the user clicks to edit the product. */\n onEdit?: (product: ProductData) => void;\n /** Fired when the user clicks to delete the product. */\n onDelete?: (id: string) => void;\n}\n\nconst { product, onEdit, onDelete }: Props = $props();\n</script>\n\n<div class=\"smrt-product-card__root\" data-smrt-component=\"ProductCard\">\n <div class=\"smrt-product-card__header\" data-smrt-part=\"header\">\n <h3 class=\"smrt-product-card__name\" data-smrt-part=\"title\">{product.name}</h3>\n {#if product.manufacturer}\n <div class=\"smrt-product-card__manufacturer\" data-smrt-part=\"meta\">{product.manufacturer}</div>\n {/if}\n </div>\n\n {#if product.model}\n <div class=\"smrt-product-card__model\" data-smrt-part=\"meta\">Model: {product.model}</div>\n {/if}\n\n {#if product.description}\n <p class=\"smrt-product-card__description\" data-smrt-part=\"body\">{product.description}</p>\n {/if}\n\n <div class=\"smrt-product-card__meta\" data-smrt-part=\"group\">\n {#if product.category}\n <div class=\"smrt-product-card__category\" data-smrt-part=\"badge\">Category: {product.category}</div>\n {/if}\n \n {#if product.tags && product.tags.length > 0}\n <div class=\"smrt-product-card__tags\" data-smrt-part=\"list\">\n {#each product.tags as tag}\n <span class=\"smrt-product-card__tag\" data-smrt-part=\"item\">{tag}</span>\n {/each}\n </div>\n {/if}\n </div>\n \n <div class=\"smrt-product-card__actions\" data-smrt-part=\"actions\">\n {#if onEdit}\n <Button type=\"button\" variant=\"secondary\" size=\"sm\" onclick={() => onEdit?.(product)}>\n Edit\n </Button>\n {/if}\n\n {#if onDelete}\n <Button type=\"button\" variant=\"danger\" size=\"sm\" onclick={() => product.id && onDelete?.(product.id)}>\n Delete\n </Button>\n {/if}\n </div>\n</div>\n\n<style>\n@layer smrt.reset, smrt.structure, smrt.theme;\n@layer smrt.structure {\n .smrt-product-card__root {\n padding: 1rem;\n }\n .smrt-product-card__header {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n margin-bottom: 0.5rem;\n }\n .smrt-product-card__name {\n margin: 0;\n }\n .smrt-product-card__model {\n margin-bottom: 0.5rem;\n }\n .smrt-product-card__category {\n padding: 0.25rem 0.5rem;\n display: inline-block;\n margin-bottom: 0.5rem;\n }\n .smrt-product-card__description {\n margin: 0.5rem 0;\n }\n .smrt-product-card__meta {\n margin: 0.75rem 0;\n }\n .smrt-product-card__tags {\n margin-top: 0.5rem;\n display: flex;\n flex-wrap: wrap;\n gap: 0.25rem;\n }\n .smrt-product-card__tag {\n padding: 0.125rem 0.5rem;\n }\n .smrt-product-card__actions {\n display: flex;\n gap: 0.5rem;\n margin-top: 1rem;\n padding-top: 0.75rem;\n }\n}\n\n@layer smrt.theme {\n .smrt-product-card__root {\n border: var(--smrt-hairline);\n border-radius: var(--smrt-radius-md);\n background: var(--smrt-color-surface);\n box-shadow: var(--smrt-elevation-1, 0 1px 3px color-mix(in srgb, var(--smrt-color-shadow) 10%, transparent));\n transition: box-shadow 0.2s;\n }\n .smrt-product-card__root:hover {\n box-shadow: var(--smrt-elevation-2, 0 4px 6px color-mix(in srgb, var(--smrt-color-shadow) 10%, transparent));\n }\n .smrt-product-card__name {\n font-size: var(--smrt-typography-title-medium-size, 1.125rem);\n font-weight: var(--smrt-typography-weight-semibold, 600);\n color: var(--smrt-color-on-surface);\n }\n .smrt-product-card__manufacturer {\n font-size: var(--smrt-typography-title-small-size, 0.875rem);\n font-weight: var(--smrt-typography-weight-medium, 500);\n color: var(--smrt-color-on-surface-variant);\n }\n .smrt-product-card__model {\n font-size: var(--smrt-typography-body-medium-size, 0.875rem);\n color: var(--smrt-color-on-surface-variant);\n }\n .smrt-product-card__category {\n font-size: var(--smrt-typography-label-medium-size, 0.75rem);\n font-weight: var(--smrt-typography-weight-medium, 500);\n color: var(--smrt-color-on-surface);\n background: var(--smrt-color-surface-container);\n border-radius: var(--smrt-radius-sm);\n }\n .smrt-product-card__description {\n color: var(--smrt-color-on-surface-variant);\n font-size: var(--smrt-typography-body-medium-size, 0.875rem);\n line-height: var(--smrt-typography-body-medium-line-height, 1.4);\n }\n .smrt-product-card__tag {\n background: var(--smrt-color-surface-container);\n color: var(--smrt-color-on-surface);\n border-radius: var(--smrt-radius-full);\n font-size: var(--smrt-typography-label-medium-size, 0.75rem);\n }\n .smrt-product-card__actions {\n border-top: var(--smrt-hairline);\n }\n}\n\n</style>","<script lang=\"ts\">\nimport { Form, Input, Textarea } from '@happyvertical/smrt-ui/forms';\nimport { useI18n } from '@happyvertical/smrt-ui/i18n';\nimport { Button } from '@happyvertical/smrt-ui/ui';\nimport { M } from '../i18n.js';\nimport type { ProductData } from '../types';\n\nconst { t } = useI18n();\n\ninterface Props {\n /** Product to populate the form with. */\n product?: Partial<ProductData>;\n /** Fired when the user submits the form. */\n onSubmit: (product: Partial<ProductData>) => void;\n /** Fired when the user clicks the cancel button. */\n onCancel?: () => void;\n /** Disables all inputs and shows \"Saving...\" when true. */\n loading?: boolean;\n}\n\nconst { product = {}, onSubmit, onCancel, loading = false }: Props = $props();\n\nconst formData = $state({\n name: product.name || '',\n description: product.description || '',\n price: product.price || 0,\n inStock: product.inStock ?? true,\n category: product.category || '',\n tags: product.tags?.join(', ') || '',\n});\n\nlet errors = $state<Record<string, string>>({});\n\nfunction validateForm() {\n errors = {};\n\n if (!formData.name.trim()) {\n errors.name = 'Product name is required';\n }\n\n if (formData.price < 0) {\n errors.price = 'Price must be non-negative';\n }\n\n return Object.keys(errors).length === 0;\n}\n\nfunction handleSubmit(event: Event) {\n event.preventDefault();\n\n if (!validateForm()) {\n return;\n }\n\n const productData: Partial<ProductData> = {\n ...product,\n name: formData.name.trim(),\n description: formData.description.trim() || undefined,\n price: formData.price,\n inStock: formData.inStock,\n category: formData.category.trim(),\n tags: formData.tags\n ? formData.tags\n .split(',')\n .map((tag) => tag.trim())\n .filter(Boolean)\n : [],\n };\n\n onSubmit(productData);\n}\n</script>\n\n<div class=\"smrt-product-form__root\" data-smrt-component=\"ProductForm\">\n <Form onsubmit={handleSubmit} class=\"smrt-product-form__form\">\n <div class=\"smrt-product-form__field\" data-smrt-part=\"field\">\n <label for=\"name\">{t(M['products.product_form.name_label'])}</label>\n <Input\n id=\"name\"\n type=\"text\"\n bind:value={formData.name}\n disabled={loading}\n class={errors.name ? 'smrt-product-form__error' : ''}\n placeholder={t(M['products.product_form.name_placeholder'])}\n />\n {#if errors.name}\n <span class=\"smrt-product-form__error-message\" data-smrt-part=\"error\">{errors.name}</span>\n {/if}\n </div>\n\n <div class=\"smrt-product-form__field\" data-smrt-part=\"field\">\n <label for=\"description\">Description</label>\n <Textarea\n id=\"description\"\n bind:value={formData.description}\n disabled={loading}\n placeholder={t(M['products.product_form.description_placeholder'])}\n rows={3}\n ></Textarea>\n </div>\n\n <div class=\"smrt-product-form__row\" data-smrt-part=\"row\">\n <div class=\"smrt-product-form__field\" data-smrt-part=\"field\">\n <label for=\"price\">Price *</label>\n <Input\n id=\"price\"\n type=\"number\"\n step=\"0.01\"\n min=\"0\"\n bind:value={formData.price}\n disabled={loading}\n class={errors.price ? 'smrt-product-form__error' : ''}\n placeholder=\"0.00\"\n />\n {#if errors.price}\n <span class=\"smrt-product-form__error-message\" data-smrt-part=\"error\">{errors.price}</span>\n {/if}\n </div>\n\n <div class=\"smrt-product-form__field\" data-smrt-part=\"field\">\n <label for=\"category\">Category</label>\n <Input\n id=\"category\"\n type=\"text\"\n bind:value={formData.category}\n disabled={loading}\n placeholder={t(M['products.product_form.category_placeholder'])}\n />\n </div>\n </div>\n\n <div class=\"smrt-product-form__field\" data-smrt-part=\"field\">\n <label for=\"tags\">Tags</label>\n <Input\n id=\"tags\"\n type=\"text\"\n bind:value={formData.tags}\n disabled={loading}\n placeholder={t(M['products.product_form.tags_placeholder'])}\n />\n <small class=\"smrt-product-form__hint\" data-smrt-part=\"description\">{t(M['products.product_form.tags_hint'])}</small>\n </div>\n\n <div class=\"smrt-product-form__field\" data-smrt-part=\"field\">\n <label class=\"smrt-product-form__checkbox-label\" data-smrt-part=\"label\">\n <!-- raw-primitive-allow: native checkbox; no Provider-free checkbox primitive (Toggle is a switch with different semantics, CheckboxInput requires a Provider) -->\n <input\n type=\"checkbox\"\n bind:checked={formData.inStock}\n disabled={loading}\n class=\"smrt-product-form__checkbox\" data-smrt-part=\"input\"\n />\n {t(M['products.product_form.in_stock_label'])}\n </label>\n </div>\n\n <div class=\"smrt-product-form__actions\" data-smrt-part=\"actions\">\n {#if onCancel}\n <Button type=\"button\" variant=\"secondary\" onclick={onCancel} disabled={loading}>\n Cancel\n </Button>\n {/if}\n\n <Button type=\"submit\" variant=\"primary\" disabled={loading}>\n {#if loading}\n Saving...\n {:else}\n {product.id ? 'Update Product' : 'Create Product'}\n {/if}\n </Button>\n </div>\n </Form>\n</div>\n\n<style>\n@layer smrt.reset, smrt.structure, smrt.theme;\n@layer smrt.structure {\n .smrt-product-form__root :global([data-smrt-component=\"Form\"]) {\n max-width: 500px;\n padding: 1.5rem;\n }\n .smrt-product-form__field {\n margin-bottom: 1rem;\n }\n .smrt-product-form__row {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 1rem;\n }\n label {\n display: block;\n margin-bottom: 0.25rem;\n }\n .smrt-product-form__checkbox-label {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n cursor: pointer;\n }\n .smrt-product-form__checkbox {\n width: auto;\n }\n .smrt-product-form__hint {\n margin-top: 0.25rem;\n }\n .smrt-product-form__error-message {\n margin-top: 0.25rem;\n display: block;\n }\n .smrt-product-form__actions {\n display: flex;\n gap: 0.75rem;\n justify-content: flex-end;\n margin-top: 1.5rem;\n padding-top: 1rem;\n }\n}\n\n@layer smrt.theme {\n .smrt-product-form__root :global([data-smrt-component=\"Form\"]) {\n background: var(--smrt-color-surface);\n border-radius: var(--smrt-radius-md);\n border: var(--smrt-hairline);\n }\n label {\n font-weight: var(--smrt-typography-weight-medium, 500);\n color: var(--smrt-color-on-surface);\n font-size: var(--smrt-typography-label-large-size, 0.875rem);\n }\n /* Error border on the migrated <Input>. The primitive forwards `class` onto\n its root element, so the scoped rule can't reach it without :global (#1589). */\n .smrt-product-form__root :global([data-smrt-component=\"Input\"].smrt-product-form__error) {\n border-color: var(--smrt-color-error);\n }\n .smrt-product-form__hint {\n color: var(--smrt-color-on-surface-variant);\n font-size: var(--smrt-typography-body-small-size, 0.75rem);\n }\n .smrt-product-form__error-message {\n color: var(--smrt-color-error);\n font-size: var(--smrt-typography-label-medium-size, 0.75rem);\n }\n .smrt-product-form__actions {\n border-top: var(--smrt-hairline);\n }\n}\n\n</style>"],"mappings":";;;;;;;;;;;;;;wCAAA;;KAgBC,MAAG,OAAA;KACD,QAAG,EAAA,MADL,GAAG;KAEC,KAAE,EAAA,MADJ,KAAG;yBACD,IAAE,IAAA;sBAAF,IAAE,CAAA;;MAEA,QAAG,OAAA;4BAAH,OAAG,IAAA;6DAAwE,YAAY,CAAA;qBAAvF,KAAG;;;sBADO,cAAY,SAAA,UAAA;;SAF1B,KAAG;wBAAH,OAAG,CAAA;;MAQD,QAAG,SAAA;4BAAH,KAAG;uEAAwE,SAAK,IAAA,CAAA;qBAAhF,KAAG;;;sBADO,OAAK,SAAA,YAAA;;;;MAKf,IAAC,SAAA;4BAAD,GAAC,IAAA;6DAAuE,WAAW,CAAA;qBAAnF,CAAC;;;sBADS,aAAW,SAAA,YAAA;;KAIvB,QAAG,EAAA,QAAA,QAAA,CAAA;sBAAH,KAAG;;MAEC,QAAG,OAAA;4BAAH,KAAG;0EAA+E,YAAQ,IAAA,CAAA;qBAA1F,KAAG;;;sBADO,UAAQ,SAAA,YAAA;;;;MAKlB,QAAG,OAAA;SAAH,OAAG,UAAA,QAAA,QACa,MAAI,EAAA,QAAA,UAAI,QAAG;OACvB,OAAI,OAAA;6BAAJ,MAAI,IAAA;oDAAuD,GAAG,CAAA,CAAA;sBAA9D,IAAI;;UAFR,KAAG;qBAAH,KAAG;;;sBADO,QAAI,QAAA,QAAY,KAAK,SAAS,GAAC,SAAA,YAAA;;SAL7C,KAAG;KAcH,QAAG,EAAA,QAdH,OAAG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"./__smrt-register__-CfedXJ8n.js";
|
|
2
2
|
//#region src/lib/generated/index.ts
|
|
3
3
|
var autoGeneratedComponents = {};
|
|
4
4
|
//#endregion
|
|
5
5
|
export { autoGeneratedComponents as t };
|
|
6
6
|
|
|
7
|
-
//# sourceMappingURL=generated-
|
|
7
|
+
//# sourceMappingURL=generated-D6SpalT3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-
|
|
1
|
+
{"version":3,"file":"generated-D6SpalT3.js","names":[],"sources":["../../../src/lib/generated/index.ts"],"sourcesContent":["/**\n * Auto-generated SMRT Components\n *\n * This file is automatically generated by the SMRT Vite plugin.\n * It exports UI components that are auto-generated from @smrt() decorated classes.\n *\n * DO NOT EDIT THIS FILE MANUALLY - it will be overwritten.\n */\n\n// Self-register this package's manifest for consumers that import via this\n// subpath without the main entry. See src/__smrt-register__.ts (issue #1132).\nimport '../../__smrt-register__.js';\n\n// Auto-generated components will be exported here by the SMRT Vite plugin\n// Examples:\n// export { default as SmrtProductForm } from './SmrtProductForm.svelte';\n// export { default as SmrtProductTable } from './SmrtProductTable.svelte';\n// export { default as SmrtCategoryForm } from './SmrtCategoryForm.svelte';\n\n// For now, export an empty object to prevent import errors\nexport const autoGeneratedComponents = {};\n"],"mappings":";;AAoBA,IAAa,0BAA0B,CAAC"}
|
package/dist/lib/collections.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CategoryCollection, n as ProductVariantCollection, r as MaterialCollection, t as SkuCollection } from "./chunks/collections-
|
|
1
|
+
import { i as CategoryCollection, n as ProductVariantCollection, r as MaterialCollection, t as SkuCollection } from "./chunks/collections-CH8P9U_s.js";
|
|
2
2
|
import { t as ProductCollection } from "./chunks/ProductCollection-bcMIqMpy.js";
|
|
3
3
|
import { t as ProductAssetCollection } from "./chunks/ProductAssetCollection-CDwWlUxj.js";
|
|
4
4
|
export { CategoryCollection, MaterialCollection, ProductAssetCollection, ProductCollection, ProductVariantCollection, SkuCollection };
|
package/dist/lib/components.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ProductCard, t as ProductForm } from "./chunks/components-
|
|
1
|
+
import { n as ProductCard, t as ProductForm } from "./chunks/components-j1pkLwKV.js";
|
|
2
2
|
export { ProductCard, ProductForm };
|
package/dist/lib/generated.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as autoGeneratedComponents } from "./chunks/generated-
|
|
1
|
+
import { t as autoGeneratedComponents } from "./chunks/generated-D6SpalT3.js";
|
|
2
2
|
export { autoGeneratedComponents };
|
package/dist/lib/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunks/rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import "./chunks/__smrt-register__-
|
|
2
|
+
import "./chunks/__smrt-register__-CfedXJ8n.js";
|
|
3
3
|
import { a as Product, i as Material, n as ProductVariant, o as ProductType, r as ProductAsset, s as Category, t as Sku } from "./chunks/Sku-D9O8I6NV.js";
|
|
4
|
-
import { i as CategoryCollection, n as ProductVariantCollection, r as MaterialCollection, t as SkuCollection } from "./chunks/collections-
|
|
4
|
+
import { i as CategoryCollection, n as ProductVariantCollection, r as MaterialCollection, t as SkuCollection } from "./chunks/collections-CH8P9U_s.js";
|
|
5
5
|
import { t as ProductCollection } from "./chunks/ProductCollection-bcMIqMpy.js";
|
|
6
6
|
import { t as ProductAssetCollection } from "./chunks/ProductAssetCollection-CDwWlUxj.js";
|
|
7
|
-
import { n as ProductCard, t as ProductForm } from "./chunks/components-
|
|
8
|
-
import { t as autoGeneratedComponents } from "./chunks/generated-
|
|
9
|
-
import "./chunks/models-
|
|
7
|
+
import { n as ProductCard, t as ProductForm } from "./chunks/components-j1pkLwKV.js";
|
|
8
|
+
import { t as autoGeneratedComponents } from "./chunks/generated-D6SpalT3.js";
|
|
9
|
+
import "./chunks/models-trtehGCE.js";
|
|
10
10
|
import { n as productStore, t as ProductStoreClass } from "./chunks/stores-CB0SI1c5.js";
|
|
11
11
|
import { i as slugify, n as formatPrice, r as generateId, t as formatDate } from "./chunks/utils-BgTqlQoH.js";
|
|
12
12
|
import { SmrtRecipe, startRestServer } from "@happyvertical/smrt-core";
|
|
@@ -102,17 +102,17 @@ async function addProduct() {
|
|
|
102
102
|
}
|
|
103
103
|
</script>
|
|
104
104
|
|
|
105
|
-
<section class="live-
|
|
106
|
-
<header class="live-
|
|
105
|
+
<section class="smrt-live-product-list__root" aria-label={t(M['products.live_list.title'])} data-smrt-component="LiveProductList">
|
|
106
|
+
<header class="smrt-live-product-list__header" data-smrt-part="header">
|
|
107
107
|
<h2>{t(M['products.live_list.title'])}</h2>
|
|
108
|
-
<p class="live-
|
|
108
|
+
<p class="smrt-live-product-list__hint" data-smrt-part="meta">{t(M['products.live_list.hint'])}</p>
|
|
109
109
|
</header>
|
|
110
110
|
|
|
111
111
|
<Form
|
|
112
112
|
collection="products"
|
|
113
113
|
webmcp={{ name: 'create_product', description: 'Create a product from this form' }}
|
|
114
114
|
onsubmit={() => addProduct()}
|
|
115
|
-
class="live-
|
|
115
|
+
class="smrt-live-product-list__form"
|
|
116
116
|
>
|
|
117
117
|
<TextInput
|
|
118
118
|
name="name"
|
|
@@ -127,30 +127,30 @@ async function addProduct() {
|
|
|
127
127
|
</Form>
|
|
128
128
|
|
|
129
129
|
{#if lastError}
|
|
130
|
-
<p class="live-
|
|
130
|
+
<p class="smrt-live-product-list__error" data-smrt-part="error" role="alert">
|
|
131
131
|
{t(M['products.live_list.insert_failed'])} {lastError}
|
|
132
132
|
</p>
|
|
133
133
|
{/if}
|
|
134
134
|
|
|
135
135
|
{#if view.isLoading}
|
|
136
|
-
<p class="live-
|
|
136
|
+
<p class="smrt-live-product-list__status" data-smrt-part="status" role="status" aria-live="polite">
|
|
137
137
|
{t(M['products.live_list.loading'])}
|
|
138
138
|
</p>
|
|
139
139
|
{:else if view.isError}
|
|
140
|
-
<p class="live-
|
|
140
|
+
<p class="smrt-live-product-list__status" data-smrt-part="error" role="alert">
|
|
141
141
|
{t(M['products.live_list.load_failed'])} {String(view.error)}
|
|
142
142
|
</p>
|
|
143
143
|
{:else if view.rows.length === 0}
|
|
144
|
-
<p class="live-
|
|
144
|
+
<p class="smrt-live-product-list__status" data-smrt-part="status" role="status" aria-live="polite">
|
|
145
145
|
{t(M['products.live_list.empty'])}
|
|
146
146
|
</p>
|
|
147
147
|
{:else}
|
|
148
|
-
<ul class="live-
|
|
148
|
+
<ul class="smrt-live-product-list__list" data-smrt-part="list">
|
|
149
149
|
{#each view.rows as row (row.id)}
|
|
150
|
-
<li class="live-
|
|
151
|
-
<span class="live-
|
|
150
|
+
<li class="smrt-live-product-list__item" data-smrt-part="item">
|
|
151
|
+
<span class="smrt-live-product-list__item-name" data-smrt-part="label">{row.name}</span>
|
|
152
152
|
{#if row.price != null}
|
|
153
|
-
<span class="live-
|
|
153
|
+
<span class="smrt-live-product-list__item-price" data-smrt-part="value">${row.price}</span>
|
|
154
154
|
{/if}
|
|
155
155
|
</li>
|
|
156
156
|
{/each}
|
|
@@ -160,60 +160,40 @@ async function addProduct() {
|
|
|
160
160
|
|
|
161
161
|
<style>
|
|
162
162
|
@layer smrt.reset, smrt.structure, smrt.theme;
|
|
163
|
-
@layer smrt.
|
|
164
|
-
.live-
|
|
163
|
+
@layer smrt.structure {
|
|
164
|
+
.smrt-live-product-list__root {
|
|
165
165
|
max-width: 640px;
|
|
166
166
|
margin: 0 auto;
|
|
167
167
|
padding: 1.5rem;
|
|
168
|
-
background: var(--smrt-color-surface);
|
|
169
|
-
border: var(--smrt-hairline);
|
|
170
|
-
border-radius: var(--smrt-radius-md);
|
|
171
168
|
}
|
|
172
|
-
|
|
173
|
-
.live-products__header {
|
|
169
|
+
.smrt-live-product-list__header {
|
|
174
170
|
margin-bottom: 1rem;
|
|
175
171
|
}
|
|
176
|
-
|
|
177
|
-
.live-products__header h2 {
|
|
172
|
+
.smrt-live-product-list__header h2 {
|
|
178
173
|
margin: 0 0 0.25rem 0;
|
|
179
|
-
font-size: var(--smrt-typography-title-large-size, 1.25rem);
|
|
180
|
-
font-weight: var(--smrt-typography-weight-semibold, 600);
|
|
181
|
-
color: var(--smrt-color-on-surface);
|
|
182
174
|
}
|
|
183
|
-
|
|
184
|
-
.live-products__hint {
|
|
175
|
+
.smrt-live-product-list__hint {
|
|
185
176
|
margin: 0;
|
|
186
|
-
font-size: var(--smrt-typography-body-medium-size, 0.875rem);
|
|
187
|
-
color: var(--smrt-color-on-surface-variant);
|
|
188
177
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
.live-products :global(.live-products__form) {
|
|
178
|
+
/* smrt-svelte <Form> renders its own inner <form>; reach it through the
|
|
179
|
+
component hook because the scoped selector can't (#1589), same as
|
|
180
|
+
ProductForm.svelte's forwarded form class handling. */
|
|
181
|
+
.smrt-live-product-list__root :global([data-smrt-component="Form"]) {
|
|
194
182
|
display: flex;
|
|
195
183
|
gap: 0.75rem;
|
|
196
184
|
margin-bottom: 1rem;
|
|
197
185
|
}
|
|
198
|
-
|
|
199
|
-
.live-products :global(.live-products__form) :global(.live-products__name) {
|
|
186
|
+
.smrt-live-product-list__root :global([data-smrt-component="Form"]) :global([data-smrt-component="TextInput"]) {
|
|
200
187
|
flex: 1;
|
|
201
188
|
}
|
|
202
|
-
|
|
203
|
-
.live-products__error {
|
|
189
|
+
.smrt-live-product-list__error {
|
|
204
190
|
margin: 0 0 1rem 0;
|
|
205
|
-
color: var(--smrt-color-error);
|
|
206
|
-
font-size: var(--smrt-typography-body-medium-size, 0.875rem);
|
|
207
191
|
}
|
|
208
|
-
|
|
209
|
-
.live-products__status {
|
|
192
|
+
.smrt-live-product-list__status {
|
|
210
193
|
margin: 0;
|
|
211
194
|
padding: 1rem 0;
|
|
212
|
-
text-align: center;
|
|
213
|
-
color: var(--smrt-color-on-surface-variant);
|
|
214
195
|
}
|
|
215
|
-
|
|
216
|
-
.live-products__list {
|
|
196
|
+
.smrt-live-product-list__list {
|
|
217
197
|
list-style: none;
|
|
218
198
|
margin: 0;
|
|
219
199
|
padding: 0;
|
|
@@ -221,24 +201,49 @@ async function addProduct() {
|
|
|
221
201
|
flex-direction: column;
|
|
222
202
|
gap: 0.5rem;
|
|
223
203
|
}
|
|
224
|
-
|
|
225
|
-
.live-products__item {
|
|
204
|
+
.smrt-live-product-list__item {
|
|
226
205
|
display: flex;
|
|
227
206
|
align-items: center;
|
|
228
207
|
justify-content: space-between;
|
|
229
208
|
padding: 0.75rem 1rem;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@layer smrt.theme {
|
|
213
|
+
.smrt-live-product-list__root {
|
|
214
|
+
background: var(--smrt-color-surface);
|
|
215
|
+
border: var(--smrt-hairline);
|
|
216
|
+
border-radius: var(--smrt-radius-md);
|
|
217
|
+
}
|
|
218
|
+
.smrt-live-product-list__header h2 {
|
|
219
|
+
font-size: var(--smrt-typography-title-large-size, 1.25rem);
|
|
220
|
+
font-weight: var(--smrt-typography-weight-semibold, 600);
|
|
221
|
+
color: var(--smrt-color-on-surface);
|
|
222
|
+
}
|
|
223
|
+
.smrt-live-product-list__hint {
|
|
224
|
+
font-size: var(--smrt-typography-body-medium-size, 0.875rem);
|
|
225
|
+
color: var(--smrt-color-on-surface-variant);
|
|
226
|
+
}
|
|
227
|
+
.smrt-live-product-list__error {
|
|
228
|
+
color: var(--smrt-color-error);
|
|
229
|
+
font-size: var(--smrt-typography-body-medium-size, 0.875rem);
|
|
230
|
+
}
|
|
231
|
+
.smrt-live-product-list__status {
|
|
232
|
+
text-align: center;
|
|
233
|
+
color: var(--smrt-color-on-surface-variant);
|
|
234
|
+
}
|
|
235
|
+
.smrt-live-product-list__item {
|
|
230
236
|
background: var(--smrt-color-surface-container-low);
|
|
231
237
|
border-radius: var(--smrt-radius-sm);
|
|
232
238
|
}
|
|
233
|
-
|
|
234
|
-
.live-products__item-name {
|
|
239
|
+
.smrt-live-product-list__item-name {
|
|
235
240
|
font-weight: var(--smrt-typography-weight-medium, 500);
|
|
236
241
|
color: var(--smrt-color-on-surface);
|
|
237
242
|
}
|
|
238
|
-
|
|
239
|
-
.live-products__item-price {
|
|
243
|
+
.smrt-live-product-list__item-price {
|
|
240
244
|
color: var(--smrt-color-on-surface-variant);
|
|
241
245
|
font-size: var(--smrt-typography-body-medium-size, 0.875rem);
|
|
242
246
|
}
|
|
243
247
|
}
|
|
248
|
+
|
|
244
249
|
</style>
|
|
@@ -14,37 +14,37 @@ interface Props {
|
|
|
14
14
|
const { product, onEdit, onDelete }: Props = $props();
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
|
-
<div class="product-
|
|
18
|
-
<div class="product-header">
|
|
19
|
-
<h3 class="product-
|
|
17
|
+
<div class="smrt-product-card__root" data-smrt-component="ProductCard">
|
|
18
|
+
<div class="smrt-product-card__header" data-smrt-part="header">
|
|
19
|
+
<h3 class="smrt-product-card__name" data-smrt-part="title">{product.name}</h3>
|
|
20
20
|
{#if product.manufacturer}
|
|
21
|
-
<div class="product-
|
|
21
|
+
<div class="smrt-product-card__manufacturer" data-smrt-part="meta">{product.manufacturer}</div>
|
|
22
22
|
{/if}
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
25
|
{#if product.model}
|
|
26
|
-
<div class="product-
|
|
26
|
+
<div class="smrt-product-card__model" data-smrt-part="meta">Model: {product.model}</div>
|
|
27
27
|
{/if}
|
|
28
28
|
|
|
29
29
|
{#if product.description}
|
|
30
|
-
<p class="product-
|
|
30
|
+
<p class="smrt-product-card__description" data-smrt-part="body">{product.description}</p>
|
|
31
31
|
{/if}
|
|
32
32
|
|
|
33
|
-
<div class="product-
|
|
33
|
+
<div class="smrt-product-card__meta" data-smrt-part="group">
|
|
34
34
|
{#if product.category}
|
|
35
|
-
<div class="product-
|
|
35
|
+
<div class="smrt-product-card__category" data-smrt-part="badge">Category: {product.category}</div>
|
|
36
36
|
{/if}
|
|
37
37
|
|
|
38
38
|
{#if product.tags && product.tags.length > 0}
|
|
39
|
-
<div class="product-
|
|
39
|
+
<div class="smrt-product-card__tags" data-smrt-part="list">
|
|
40
40
|
{#each product.tags as tag}
|
|
41
|
-
<span class="
|
|
41
|
+
<span class="smrt-product-card__tag" data-smrt-part="item">{tag}</span>
|
|
42
42
|
{/each}
|
|
43
43
|
</div>
|
|
44
44
|
{/if}
|
|
45
45
|
</div>
|
|
46
46
|
|
|
47
|
-
<div class="product-actions">
|
|
47
|
+
<div class="smrt-product-card__actions" data-smrt-part="actions">
|
|
48
48
|
{#if onEdit}
|
|
49
49
|
<Button type="button" variant="secondary" size="sm" onclick={() => onEdit?.(product)}>
|
|
50
50
|
Edit
|
|
@@ -61,90 +61,96 @@ const { product, onEdit, onDelete }: Props = $props();
|
|
|
61
61
|
|
|
62
62
|
<style>
|
|
63
63
|
@layer smrt.reset, smrt.structure, smrt.theme;
|
|
64
|
+
@layer smrt.structure {
|
|
65
|
+
.smrt-product-card__root {
|
|
66
|
+
padding: 1rem;
|
|
67
|
+
}
|
|
68
|
+
.smrt-product-card__header {
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
align-items: flex-start;
|
|
72
|
+
margin-bottom: 0.5rem;
|
|
73
|
+
}
|
|
74
|
+
.smrt-product-card__name {
|
|
75
|
+
margin: 0;
|
|
76
|
+
}
|
|
77
|
+
.smrt-product-card__model {
|
|
78
|
+
margin-bottom: 0.5rem;
|
|
79
|
+
}
|
|
80
|
+
.smrt-product-card__category {
|
|
81
|
+
padding: 0.25rem 0.5rem;
|
|
82
|
+
display: inline-block;
|
|
83
|
+
margin-bottom: 0.5rem;
|
|
84
|
+
}
|
|
85
|
+
.smrt-product-card__description {
|
|
86
|
+
margin: 0.5rem 0;
|
|
87
|
+
}
|
|
88
|
+
.smrt-product-card__meta {
|
|
89
|
+
margin: 0.75rem 0;
|
|
90
|
+
}
|
|
91
|
+
.smrt-product-card__tags {
|
|
92
|
+
margin-top: 0.5rem;
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-wrap: wrap;
|
|
95
|
+
gap: 0.25rem;
|
|
96
|
+
}
|
|
97
|
+
.smrt-product-card__tag {
|
|
98
|
+
padding: 0.125rem 0.5rem;
|
|
99
|
+
}
|
|
100
|
+
.smrt-product-card__actions {
|
|
101
|
+
display: flex;
|
|
102
|
+
gap: 0.5rem;
|
|
103
|
+
margin-top: 1rem;
|
|
104
|
+
padding-top: 0.75rem;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
64
108
|
@layer smrt.theme {
|
|
65
|
-
.product-
|
|
109
|
+
.smrt-product-card__root {
|
|
66
110
|
border: var(--smrt-hairline);
|
|
67
111
|
border-radius: var(--smrt-radius-md);
|
|
68
|
-
padding: 1rem;
|
|
69
112
|
background: var(--smrt-color-surface);
|
|
70
113
|
box-shadow: var(--smrt-elevation-1, 0 1px 3px color-mix(in srgb, var(--smrt-color-shadow) 10%, transparent));
|
|
71
114
|
transition: box-shadow 0.2s;
|
|
72
115
|
}
|
|
73
|
-
|
|
74
|
-
.product-card:hover {
|
|
116
|
+
.smrt-product-card__root:hover {
|
|
75
117
|
box-shadow: var(--smrt-elevation-2, 0 4px 6px color-mix(in srgb, var(--smrt-color-shadow) 10%, transparent));
|
|
76
118
|
}
|
|
77
|
-
|
|
78
|
-
.product-header {
|
|
79
|
-
display: flex;
|
|
80
|
-
justify-content: space-between;
|
|
81
|
-
align-items: flex-start;
|
|
82
|
-
margin-bottom: 0.5rem;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.product-name {
|
|
86
|
-
margin: 0;
|
|
119
|
+
.smrt-product-card__name {
|
|
87
120
|
font-size: var(--smrt-typography-title-medium-size, 1.125rem);
|
|
88
121
|
font-weight: var(--smrt-typography-weight-semibold, 600);
|
|
89
122
|
color: var(--smrt-color-on-surface);
|
|
90
123
|
}
|
|
91
|
-
|
|
92
|
-
.product-manufacturer {
|
|
124
|
+
.smrt-product-card__manufacturer {
|
|
93
125
|
font-size: var(--smrt-typography-title-small-size, 0.875rem);
|
|
94
126
|
font-weight: var(--smrt-typography-weight-medium, 500);
|
|
95
127
|
color: var(--smrt-color-on-surface-variant);
|
|
96
128
|
}
|
|
97
|
-
|
|
98
|
-
.product-model {
|
|
129
|
+
.smrt-product-card__model {
|
|
99
130
|
font-size: var(--smrt-typography-body-medium-size, 0.875rem);
|
|
100
131
|
color: var(--smrt-color-on-surface-variant);
|
|
101
|
-
margin-bottom: 0.5rem;
|
|
102
132
|
}
|
|
103
|
-
|
|
104
|
-
.product-category {
|
|
133
|
+
.smrt-product-card__category {
|
|
105
134
|
font-size: var(--smrt-typography-label-medium-size, 0.75rem);
|
|
106
135
|
font-weight: var(--smrt-typography-weight-medium, 500);
|
|
107
136
|
color: var(--smrt-color-on-surface);
|
|
108
137
|
background: var(--smrt-color-surface-container);
|
|
109
|
-
padding: 0.25rem 0.5rem;
|
|
110
138
|
border-radius: var(--smrt-radius-sm);
|
|
111
|
-
display: inline-block;
|
|
112
|
-
margin-bottom: 0.5rem;
|
|
113
139
|
}
|
|
114
|
-
|
|
115
|
-
.product-description {
|
|
116
|
-
margin: 0.5rem 0;
|
|
140
|
+
.smrt-product-card__description {
|
|
117
141
|
color: var(--smrt-color-on-surface-variant);
|
|
118
142
|
font-size: var(--smrt-typography-body-medium-size, 0.875rem);
|
|
119
143
|
line-height: var(--smrt-typography-body-medium-line-height, 1.4);
|
|
120
144
|
}
|
|
121
|
-
|
|
122
|
-
.product-meta {
|
|
123
|
-
margin: 0.75rem 0;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.product-tags {
|
|
128
|
-
margin-top: 0.5rem;
|
|
129
|
-
display: flex;
|
|
130
|
-
flex-wrap: wrap;
|
|
131
|
-
gap: 0.25rem;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.tag {
|
|
145
|
+
.smrt-product-card__tag {
|
|
135
146
|
background: var(--smrt-color-surface-container);
|
|
136
147
|
color: var(--smrt-color-on-surface);
|
|
137
|
-
padding: 0.125rem 0.5rem;
|
|
138
148
|
border-radius: var(--smrt-radius-full);
|
|
139
149
|
font-size: var(--smrt-typography-label-medium-size, 0.75rem);
|
|
140
150
|
}
|
|
141
|
-
|
|
142
|
-
.product-actions {
|
|
143
|
-
display: flex;
|
|
144
|
-
gap: 0.5rem;
|
|
145
|
-
margin-top: 1rem;
|
|
146
|
-
padding-top: 0.75rem;
|
|
151
|
+
.smrt-product-card__actions {
|
|
147
152
|
border-top: var(--smrt-hairline);
|
|
148
153
|
}
|
|
149
154
|
}
|
|
155
|
+
|
|
150
156
|
</style>
|