@vio-live/web-sdk 0.3.0 → 0.4.1

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.
@@ -1,5 +1,6 @@
1
1
  import * as _lit_react from '@lit/react';
2
- import { V as VioCart$1, a as VioCheckout$1, b as VioProduct$1, c as VioProductCarousel$1, d as VioProductDetail$1 } from '../vio-checkout-T9R5hpDx.js';
2
+ import { V as VioCart$1, a as VioCheckout$1, b as VioProduct$1, c as VioProductCarousel$1, d as VioProductDetail$1 } from '../tokens-CvqQYURw.js';
3
+ export { e as VioThemeOverrides, f as VioTokens, g as applyVioTheme } from '../tokens-CvqQYURw.js';
3
4
  import 'lit-html';
4
5
  import 'lit';
5
6
 
@@ -1,4 +1,5 @@
1
- import { registerVioElements, VioProduct, VioProductCarousel, VioProductDetail, VioCart, VioCheckout } from '../chunk-NWORYWIL.js';
1
+ import { registerVioElements, VioProduct, VioProductCarousel, VioProductDetail, VioCart, VioCheckout } from '../chunk-V5ZQG2H5.js';
2
+ export { VioTokens, applyVioTheme } from '../chunk-V5ZQG2H5.js';
2
3
  import '../chunk-NP2KCM7X.js';
3
4
  import * as React from 'react';
4
5
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../node_modules/@lit/react/src/create-component.ts","../../src/react/index.ts"],"names":["reservedReactProperties","Set","createComponent","react","React","tagName","elementClass","events","displayName","eventProps","Object","keys","ReactComponent","forwardRef","props","ref","useRef","Map","elementRef","reactProps","elementProps","k","v","entries","has","prototype","createElement","name","globalThis","litSsrReactEnabled","length","useCallback","node","current","VioProduct","VioProductCarousel","VioProductDetail","VioCart","VioCheckout"],"mappings":";;;;;AAgHA,IAAMA,CAAAA,uBAA8BC,GAAAA,CAAI,CACtC,YACA,WAAA,EACA,KAAA,EACA,OAAA,EACA,WAAA,CAAA,CAAA;AALF,IAwGaC,CAAAA,GAAkB,CAAA,EAI7BC,KAAAA,EAAOC,EAAAA,EACPC,OAAAA,EAAAA,CAAAA,E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AAA,EAAgB;AAAA;AAEpB,CAAC;AAEM,IAAMC,eAAc,CAAA,CAAgB;AAAA,EACzC,KAAA,EAAO,KAAA;AAAA,EACP,OAAA,EAAS,cAAA;AAAA,EACT,YAAA,EAAc,WAAA;AAAA,EACd,MAAA,EAAQ;AAAA,IACN,gBAAA,EAAkB;AAAA;AAEtB,CAAC","file":"index.js","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type React from 'react';\n\nconst NODE_MODE = false;\nconst DEV_MODE = true;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype DistributiveOmit<T, K extends string | number | symbol> = T extends any\n ? K extends keyof T\n ? Omit<T, K>\n : T\n : T;\ntype PropsWithoutRef<T> = DistributiveOmit<T, 'ref'>;\n\n/**\n * Creates a type to be used for the props of a web component used directly in\n * React JSX.\n *\n * Example:\n *\n * ```ts\n * declare module \"react\" {\n * namespace JSX {\n * interface IntrinsicElements {\n * 'x-foo': WebComponentProps<XFoo>;\n * }\n * }\n * }\n * ```\n */\nexport type WebComponentProps<I extends HTMLElement> = React.DetailedHTMLProps<\n React.HTMLAttributes<I>,\n I\n> &\n ElementProps<I>;\n\n/**\n * Type of the React component wrapping the web component. This is the return\n * type of `createComponent`.\n */\nexport type ReactWebComponent<\n I extends HTMLElement,\n E extends EventNames = {},\n> = React.ForwardRefExoticComponent<\n // TODO(augustjk): Remove and use `React.PropsWithoutRef` when\n // https://github.com/preactjs/preact/issues/4124 is fixed.\n PropsWithoutRef<ComponentProps<I, E>> & React.RefAttributes<I>\n>;\n\n// Props derived from custom element class. Currently has limitations of making\n// all properties optional and also surfaces life cycle methods in autocomplete.\n// TODO(augustjk) Consider omitting keyof LitElement to remove \"internal\"\n// lifecycle methods or allow user to explicitly provide props.\ntype ElementProps<I> = Partial<Omit<I, keyof HTMLElement>>;\n\n// Acceptable props to the React component.\ntype ComponentProps<I, E extends EventNames = {}> = Omit<\n React.HTMLAttributes<I>,\n // Prefer type of provided event handler props or those on element over\n // built-in HTMLAttributes\n keyof E | keyof ElementProps<I>\n> &\n EventListeners<E> &\n ElementProps<I>;\n\n/**\n * Type used to cast an event name with an event type when providing the\n * `events` option to `createComponent` for better typing of the event handler\n * prop.\n *\n * Example:\n *\n * ```ts\n * const FooComponent = createComponent({\n * ...\n * events: {\n * onfoo: 'foo' as EventName<FooEvent>,\n * }\n * });\n * ```\n *\n * `onfoo` prop will have the type `(e: FooEvent) => void`.\n */\nexport type EventName<T extends Event = Event> = string & {\n __eventType: T;\n};\n\n// A key value map matching React prop names to event names.\ntype EventNames = Record<string, EventName | string>;\n\n// A map of expected event listener types based on EventNames.\ntype EventListeners<R extends EventNames> = {\n [K in keyof R]?: R[K] extends EventName\n ? (e: R[K]['__eventType']) => void\n : (e: Event) => void;\n};\n\nexport interface Options<I extends HTMLElement, E extends EventNames = {}> {\n react: typeof React;\n tagName: string;\n elementClass: Constructor<I>;\n events?: E;\n displayName?: string;\n}\n\ntype Constructor<T> = {new (): T};\n\nconst reservedReactProperties = new Set([\n 'children',\n 'localName',\n 'ref',\n 'style',\n 'className',\n]);\n\nconst listenedEvents = new WeakMap<Element, Map<string, EventListenerObject>>();\n\n/**\n * Adds an event listener for the specified event to the given node. In the\n * React setup, there should only ever be one event listener. Thus, for\n * efficiency only one listener is added and the handler for that listener is\n * updated to point to the given listener function.\n */\nconst addOrUpdateEventListener = (\n node: Element,\n event: string,\n listener: (event?: Event) => void\n) => {\n let events = listenedEvents.get(node);\n if (events === undefined) {\n listenedEvents.set(node, (events = new Map()));\n }\n let handler = events.get(event);\n if (listener !== undefined) {\n // If necessary, add listener and track handler\n if (handler === undefined) {\n events.set(event, (handler = {handleEvent: listener}));\n node.addEventListener(event, handler);\n // Otherwise just update the listener with new value\n } else {\n handler.handleEvent = listener;\n }\n // Remove listener if one exists and value is undefined\n } else if (handler !== undefined) {\n events.delete(event);\n node.removeEventListener(event, handler);\n }\n};\n\n/**\n * Sets properties and events on custom elements. These properties and events\n * have been pre-filtered so we know they should apply to the custom element.\n */\nconst setProperty = <E extends Element>(\n node: E,\n name: string,\n value: unknown,\n old: unknown,\n events?: EventNames\n) => {\n const event = events?.[name];\n // Dirty check event value.\n if (event !== undefined) {\n if (value !== old) {\n addOrUpdateEventListener(node, event, value as (e?: Event) => void);\n }\n return;\n }\n // But don't dirty check properties; elements are assumed to do this.\n node[name as keyof E] = value as E[keyof E];\n\n // This block is to replicate React's behavior for attributes of native\n // elements where `undefined` or `null` values result in attributes being\n // removed.\n // https://github.com/facebook/react/blob/899cb95f52cc83ab5ca1eb1e268c909d3f0961e7/packages/react-dom-bindings/src/client/DOMPropertyOperations.js#L107-L141\n //\n // It's only needed here for native HTMLElement properties that reflect\n // attributes of the same name but don't have that behavior like \"id\" or\n // \"draggable\".\n if (\n (value === undefined || value === null) &&\n name in HTMLElement.prototype\n ) {\n node.removeAttribute(name);\n }\n};\n\n/**\n * Creates a React component for a custom element. Properties are distinguished\n * from attributes automatically, and events can be configured so they are added\n * to the custom element as event listeners.\n *\n * @param options An options bag containing the parameters needed to generate a\n * wrapped web component.\n *\n * @param options.react The React module, typically imported from the `react`\n * npm package.\n * @param options.tagName The custom element tag name registered via\n * `customElements.define`.\n * @param options.elementClass The custom element class registered via\n * `customElements.define`.\n * @param options.events An object listing events to which the component can\n * listen. The object keys are the event property names passed in via React\n * props and the object values are the names of the corresponding events\n * generated by the custom element. For example, given `{onactivate:\n * 'activate'}` an event function may be passed via the component's `onactivate`\n * prop and will be called when the custom element fires its `activate` event.\n * @param options.displayName A React component display name, used in debugging\n * messages. Default value is inferred from the name of custom element class\n * registered via `customElements.define`.\n */\nexport const createComponent = <\n I extends HTMLElement,\n E extends EventNames = {},\n>({\n react: React,\n tagName,\n elementClass,\n events,\n displayName,\n}: Options<I, E>): ReactWebComponent<I, E> => {\n const eventProps = new Set(Object.keys(events ?? {}));\n\n if (DEV_MODE && !NODE_MODE) {\n for (const p of reservedReactProperties) {\n if (p in elementClass.prototype && !(p in HTMLElement.prototype)) {\n // Note, this effectively warns only for `ref` since the other\n // reserved props are on HTMLElement.prototype. To address this\n // would require crawling down the prototype, which doesn't feel worth\n // it since implementing these properties on an element is extremely\n // rare.\n console.warn(\n `${tagName} contains property ${p} which is a React reserved ` +\n `property. It will be used by React and not set on the element.`\n );\n }\n }\n }\n\n type Props = ComponentProps<I, E>;\n\n const ReactComponent = React.forwardRef<I, Props>((props, ref) => {\n const prevElemPropsRef = React.useRef(new Map());\n const elementRef = React.useRef<I | null>(null);\n\n // Props to be passed to React.createElement\n const reactProps: Record<string, unknown> = {};\n // Props to be set on element with setProperty\n const elementProps: Record<string, unknown> = {};\n\n for (const [k, v] of Object.entries(props)) {\n if (reservedReactProperties.has(k)) {\n // React does *not* handle `className` for custom elements so\n // coerce it to `class` so it's handled correctly.\n reactProps[k === 'className' ? 'class' : k] = v;\n continue;\n }\n\n if (eventProps.has(k) || k in elementClass.prototype) {\n elementProps[k] = v;\n continue;\n }\n\n reactProps[k] = v;\n }\n\n // useLayoutEffect produces warnings during server rendering.\n if (!NODE_MODE) {\n // This one has no dependency array so it'll run on every re-render.\n React.useLayoutEffect(() => {\n if (elementRef.current === null) {\n return;\n }\n const newElemProps = new Map();\n for (const key in elementProps) {\n setProperty(\n elementRef.current,\n key,\n props[key],\n prevElemPropsRef.current.get(key),\n events\n );\n prevElemPropsRef.current.delete(key);\n newElemProps.set(key, props[key]);\n }\n // \"Unset\" any props from previous render that no longer exist.\n // Setting to `undefined` seems like the correct thing to \"unset\"\n // but currently React will set it as `null`.\n // See https://github.com/facebook/react/issues/28203\n for (const [key, value] of prevElemPropsRef.current) {\n setProperty(elementRef.current, key, undefined, value, events);\n }\n prevElemPropsRef.current = newElemProps;\n });\n\n // Empty dependency array so this will only run once after first render.\n React.useLayoutEffect(() => {\n elementRef.current?.removeAttribute('defer-hydration');\n }, []);\n }\n\n if (NODE_MODE) {\n // If component is to be server rendered with `@lit/ssr-react`, pass\n // element properties in a special bag to be set by the server-side\n // element renderer.\n if (\n (React.createElement.name === 'litPatchedCreateElement' ||\n globalThis.litSsrReactEnabled) &&\n Object.keys(elementProps).length\n ) {\n // This property needs to remain unminified.\n reactProps['_$litProps$'] = elementProps;\n }\n } else {\n // Suppress hydration warning for server-rendered attributes.\n // This property needs to remain unminified.\n reactProps['suppressHydrationWarning'] = true;\n }\n\n return React.createElement(tagName, {\n ...reactProps,\n ref: React.useCallback(\n (node: I) => {\n elementRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref !== null) {\n ref.current = node;\n }\n },\n [ref]\n ),\n });\n });\n\n ReactComponent.displayName = displayName ?? elementClass.name;\n\n return ReactComponent;\n};\n","/**\n * Vio React adapter — typed React wrappers for the `<vio-*>` web components.\n *\n * Built on `@lit/react`'s `createComponent`, which gives each wrapper:\n * - typed props derived from the element's reactive properties, and\n * - typed event props (the `vio:*` CustomEvents below) as `onX` callbacks.\n *\n * Importing this entry also REGISTERS the custom elements (via the\n * `registerVioElements()` call below), so you do NOT need a separate\n * `import '@vio-live/web-sdk/ui'` when you use these.\n *\n * React 18+ is an (optional) peer dependency — only required if you import this\n * entry. `@lit/react` is bundled in, so consumers install nothing extra.\n *\n * import { Vio } from '@vio-live/web-sdk'\n * import { VioProductCarousel } from '@vio-live/web-sdk/react'\n * Vio.init({ apiKey, apiBase, graphqlBase, stripePublishableKey })\n * <VioProductCarousel onProductAdd={(e) => console.log(e.detail)} />\n */\n\nimport * as React from 'react'\nimport { createComponent } from '@lit/react'\nimport {\n registerVioElements,\n VioProduct as VioProductEl,\n VioProductCarousel as VioProductCarouselEl,\n VioProductDetail as VioProductDetailEl,\n VioCart as VioCartEl,\n VioCheckout as VioCheckoutEl,\n} from '../ui/elements.js'\n\n// Register the underlying custom elements when this entry is imported.\nregisterVioElements()\n\nexport const VioProduct = createComponent({\n react: React,\n tagName: 'vio-product',\n elementClass: VioProductEl,\n events: {\n onProductClick: 'vio:product-click',\n onProductAdd: 'vio:product-add',\n },\n})\n\nexport const VioProductCarousel = createComponent({\n react: React,\n tagName: 'vio-product-carousel',\n elementClass: VioProductCarouselEl,\n events: {},\n})\n\nexport const VioProductDetail = createComponent({\n react: React,\n tagName: 'vio-product-detail',\n elementClass: VioProductDetailEl,\n events: {\n onAddedToCart: 'vio:added-to-cart',\n onCheckoutOpen: 'vio:checkout-open',\n },\n})\n\nexport const VioCart = createComponent({\n react: React,\n tagName: 'vio-cart',\n elementClass: VioCartEl,\n events: {\n onPaymentSuccess: 'vio:payment-success',\n onCheckoutOpen: 'vio:checkout-open',\n },\n})\n\nexport const VioCheckout = createComponent({\n react: React,\n tagName: 'vio-checkout',\n elementClass: VioCheckoutEl,\n events: {\n onPaymentSuccess: 'vio:payment-success',\n },\n})\n"]}
1
+ {"version":3,"sources":["../../node_modules/@lit/react/src/create-component.ts","../../src/react/index.ts"],"names":["reservedReactProperties","Set","createComponent","react","React","tagName","elementClass","events","displayName","eventProps","Object","keys","ReactComponent","forwardRef","props","ref","useRef","Map","elementRef","reactProps","elementProps","k","v","entries","has","prototype","createElement","name","globalThis","litSsrReactEnabled","length","useCallback","node","current","VioProduct","VioProductCarousel","VioProductDetail","VioCart","VioCheckout"],"mappings":";;;;;;AAgHA,IAAMA,CAAAA,uBAA8BC,GAAAA,CAAI,CACtC,YACA,WAAA,EACA,KAAA,EACA,OAAA,EACA,WAAA,CAAA,CAAA;AALF,IAwGaC,CAAAA,GAAkB,CAAA,EAI7BC,KAAAA,EAAOC,EAAAA,EACPC,OAAAA,EAAAA,CAAAA,EACAC,YAAAA,EAAAA,CAAAA,EACAC,MAAAA,EAAAA,CAAAA,EACAC,WAAAA,EAAAA,GAAAA,KAAAA;AAEA,EAAA,MAAMC,CAAAA,GAAa,IAAIR,GAAAA,CAAIS,MAAAA,CAAOC,KAAKJ,CAAAA,IAAU,EAAE,CAAA,GAoB7CK,CAAAA,GAAiBR,EAAAA,CAAMS,UAAAA,EAAqB,CAACC,IAAOC,EAAAA,KAAAA;AAC/BX,IAAAA,E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-Clause\n */\n\nimport type React from 'react';\n\nconst NODE_MODE = false;\nconst DEV_MODE = true;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype DistributiveOmit<T, K extends string | number | symbol> = T extends any\n ? K extends keyof T\n ? Omit<T, K>\n : T\n : T;\ntype PropsWithoutRef<T> = DistributiveOmit<T, 'ref'>;\n\n/**\n * Creates a type to be used for the props of a web component used directly in\n * React JSX.\n *\n * Example:\n *\n * ```ts\n * declare module \"react\" {\n * namespace JSX {\n * interface IntrinsicElements {\n * 'x-foo': WebComponentProps<XFoo>;\n * }\n * }\n * }\n * ```\n */\nexport type WebComponentProps<I extends HTMLElement> = React.DetailedHTMLProps<\n React.HTMLAttributes<I>,\n I\n> &\n ElementProps<I>;\n\n/**\n * Type of the React component wrapping the web component. This is the return\n * type of `createComponent`.\n */\nexport type ReactWebComponent<\n I extends HTMLElement,\n E extends EventNames = {},\n> = React.ForwardRefExoticComponent<\n // TODO(augustjk): Remove and use `React.PropsWithoutRef` when\n // https://github.com/preactjs/preact/issues/4124 is fixed.\n PropsWithoutRef<ComponentProps<I, E>> & React.RefAttributes<I>\n>;\n\n// Props derived from custom element class. Currently has limitations of making\n// all properties optional and also surfaces life cycle methods in autocomplete.\n// TODO(augustjk) Consider omitting keyof LitElement to remove \"internal\"\n// lifecycle methods or allow user to explicitly provide props.\ntype ElementProps<I> = Partial<Omit<I, keyof HTMLElement>>;\n\n// Acceptable props to the React component.\ntype ComponentProps<I, E extends EventNames = {}> = Omit<\n React.HTMLAttributes<I>,\n // Prefer type of provided event handler props or those on element over\n // built-in HTMLAttributes\n keyof E | keyof ElementProps<I>\n> &\n EventListeners<E> &\n ElementProps<I>;\n\n/**\n * Type used to cast an event name with an event type when providing the\n * `events` option to `createComponent` for better typing of the event handler\n * prop.\n *\n * Example:\n *\n * ```ts\n * const FooComponent = createComponent({\n * ...\n * events: {\n * onfoo: 'foo' as EventName<FooEvent>,\n * }\n * });\n * ```\n *\n * `onfoo` prop will have the type `(e: FooEvent) => void`.\n */\nexport type EventName<T extends Event = Event> = string & {\n __eventType: T;\n};\n\n// A key value map matching React prop names to event names.\ntype EventNames = Record<string, EventName | string>;\n\n// A map of expected event listener types based on EventNames.\ntype EventListeners<R extends EventNames> = {\n [K in keyof R]?: R[K] extends EventName\n ? (e: R[K]['__eventType']) => void\n : (e: Event) => void;\n};\n\nexport interface Options<I extends HTMLElement, E extends EventNames = {}> {\n react: typeof React;\n tagName: string;\n elementClass: Constructor<I>;\n events?: E;\n displayName?: string;\n}\n\ntype Constructor<T> = {new (): T};\n\nconst reservedReactProperties = new Set([\n 'children',\n 'localName',\n 'ref',\n 'style',\n 'className',\n]);\n\nconst listenedEvents = new WeakMap<Element, Map<string, EventListenerObject>>();\n\n/**\n * Adds an event listener for the specified event to the given node. In the\n * React setup, there should only ever be one event listener. Thus, for\n * efficiency only one listener is added and the handler for that listener is\n * updated to point to the given listener function.\n */\nconst addOrUpdateEventListener = (\n node: Element,\n event: string,\n listener: (event?: Event) => void\n) => {\n let events = listenedEvents.get(node);\n if (events === undefined) {\n listenedEvents.set(node, (events = new Map()));\n }\n let handler = events.get(event);\n if (listener !== undefined) {\n // If necessary, add listener and track handler\n if (handler === undefined) {\n events.set(event, (handler = {handleEvent: listener}));\n node.addEventListener(event, handler);\n // Otherwise just update the listener with new value\n } else {\n handler.handleEvent = listener;\n }\n // Remove listener if one exists and value is undefined\n } else if (handler !== undefined) {\n events.delete(event);\n node.removeEventListener(event, handler);\n }\n};\n\n/**\n * Sets properties and events on custom elements. These properties and events\n * have been pre-filtered so we know they should apply to the custom element.\n */\nconst setProperty = <E extends Element>(\n node: E,\n name: string,\n value: unknown,\n old: unknown,\n events?: EventNames\n) => {\n const event = events?.[name];\n // Dirty check event value.\n if (event !== undefined) {\n if (value !== old) {\n addOrUpdateEventListener(node, event, value as (e?: Event) => void);\n }\n return;\n }\n // But don't dirty check properties; elements are assumed to do this.\n node[name as keyof E] = value as E[keyof E];\n\n // This block is to replicate React's behavior for attributes of native\n // elements where `undefined` or `null` values result in attributes being\n // removed.\n // https://github.com/facebook/react/blob/899cb95f52cc83ab5ca1eb1e268c909d3f0961e7/packages/react-dom-bindings/src/client/DOMPropertyOperations.js#L107-L141\n //\n // It's only needed here for native HTMLElement properties that reflect\n // attributes of the same name but don't have that behavior like \"id\" or\n // \"draggable\".\n if (\n (value === undefined || value === null) &&\n name in HTMLElement.prototype\n ) {\n node.removeAttribute(name);\n }\n};\n\n/**\n * Creates a React component for a custom element. Properties are distinguished\n * from attributes automatically, and events can be configured so they are added\n * to the custom element as event listeners.\n *\n * @param options An options bag containing the parameters needed to generate a\n * wrapped web component.\n *\n * @param options.react The React module, typically imported from the `react`\n * npm package.\n * @param options.tagName The custom element tag name registered via\n * `customElements.define`.\n * @param options.elementClass The custom element class registered via\n * `customElements.define`.\n * @param options.events An object listing events to which the component can\n * listen. The object keys are the event property names passed in via React\n * props and the object values are the names of the corresponding events\n * generated by the custom element. For example, given `{onactivate:\n * 'activate'}` an event function may be passed via the component's `onactivate`\n * prop and will be called when the custom element fires its `activate` event.\n * @param options.displayName A React component display name, used in debugging\n * messages. Default value is inferred from the name of custom element class\n * registered via `customElements.define`.\n */\nexport const createComponent = <\n I extends HTMLElement,\n E extends EventNames = {},\n>({\n react: React,\n tagName,\n elementClass,\n events,\n displayName,\n}: Options<I, E>): ReactWebComponent<I, E> => {\n const eventProps = new Set(Object.keys(events ?? {}));\n\n if (DEV_MODE && !NODE_MODE) {\n for (const p of reservedReactProperties) {\n if (p in elementClass.prototype && !(p in HTMLElement.prototype)) {\n // Note, this effectively warns only for `ref` since the other\n // reserved props are on HTMLElement.prototype. To address this\n // would require crawling down the prototype, which doesn't feel worth\n // it since implementing these properties on an element is extremely\n // rare.\n console.warn(\n `${tagName} contains property ${p} which is a React reserved ` +\n `property. It will be used by React and not set on the element.`\n );\n }\n }\n }\n\n type Props = ComponentProps<I, E>;\n\n const ReactComponent = React.forwardRef<I, Props>((props, ref) => {\n const prevElemPropsRef = React.useRef(new Map());\n const elementRef = React.useRef<I | null>(null);\n\n // Props to be passed to React.createElement\n const reactProps: Record<string, unknown> = {};\n // Props to be set on element with setProperty\n const elementProps: Record<string, unknown> = {};\n\n for (const [k, v] of Object.entries(props)) {\n if (reservedReactProperties.has(k)) {\n // React does *not* handle `className` for custom elements so\n // coerce it to `class` so it's handled correctly.\n reactProps[k === 'className' ? 'class' : k] = v;\n continue;\n }\n\n if (eventProps.has(k) || k in elementClass.prototype) {\n elementProps[k] = v;\n continue;\n }\n\n reactProps[k] = v;\n }\n\n // useLayoutEffect produces warnings during server rendering.\n if (!NODE_MODE) {\n // This one has no dependency array so it'll run on every re-render.\n React.useLayoutEffect(() => {\n if (elementRef.current === null) {\n return;\n }\n const newElemProps = new Map();\n for (const key in elementProps) {\n setProperty(\n elementRef.current,\n key,\n props[key],\n prevElemPropsRef.current.get(key),\n events\n );\n prevElemPropsRef.current.delete(key);\n newElemProps.set(key, props[key]);\n }\n // \"Unset\" any props from previous render that no longer exist.\n // Setting to `undefined` seems like the correct thing to \"unset\"\n // but currently React will set it as `null`.\n // See https://github.com/facebook/react/issues/28203\n for (const [key, value] of prevElemPropsRef.current) {\n setProperty(elementRef.current, key, undefined, value, events);\n }\n prevElemPropsRef.current = newElemProps;\n });\n\n // Empty dependency array so this will only run once after first render.\n React.useLayoutEffect(() => {\n elementRef.current?.removeAttribute('defer-hydration');\n }, []);\n }\n\n if (NODE_MODE) {\n // If component is to be server rendered with `@lit/ssr-react`, pass\n // element properties in a special bag to be set by the server-side\n // element renderer.\n if (\n (React.createElement.name === 'litPatchedCreateElement' ||\n globalThis.litSsrReactEnabled) &&\n Object.keys(elementProps).length\n ) {\n // This property needs to remain unminified.\n reactProps['_$litProps$'] = elementProps;\n }\n } else {\n // Suppress hydration warning for server-rendered attributes.\n // This property needs to remain unminified.\n reactProps['suppressHydrationWarning'] = true;\n }\n\n return React.createElement(tagName, {\n ...reactProps,\n ref: React.useCallback(\n (node: I) => {\n elementRef.current = node;\n if (typeof ref === 'function') {\n ref(node);\n } else if (ref !== null) {\n ref.current = node;\n }\n },\n [ref]\n ),\n });\n });\n\n ReactComponent.displayName = displayName ?? elementClass.name;\n\n return ReactComponent;\n};\n","/**\n * Vio React adapter — typed React wrappers for the `<vio-*>` web components.\n *\n * Built on `@lit/react`'s `createComponent`, which gives each wrapper:\n * - typed props derived from the element's reactive properties, and\n * - typed event props (the `vio:*` CustomEvents below) as `onX` callbacks.\n *\n * Importing this entry also REGISTERS the custom elements (via the\n * `registerVioElements()` call below), so you do NOT need a separate\n * `import '@vio-live/web-sdk/ui'` when you use these.\n *\n * React 18+ is an (optional) peer dependency — only required if you import this\n * entry. `@lit/react` is bundled in, so consumers install nothing extra.\n *\n * import { Vio } from '@vio-live/web-sdk'\n * import { VioProductCarousel } from '@vio-live/web-sdk/react'\n * Vio.init({ apiKey, apiBase, graphqlBase, stripePublishableKey })\n * <VioProductCarousel onProductAdd={(e) => console.log(e.detail)} />\n */\n\nimport * as React from 'react'\nimport { createComponent } from '@lit/react'\nimport {\n registerVioElements,\n VioProduct as VioProductEl,\n VioProductCarousel as VioProductCarouselEl,\n VioProductDetail as VioProductDetailEl,\n VioCart as VioCartEl,\n VioCheckout as VioCheckoutEl,\n} from '../ui/elements.js'\n// Not just for the re-export below — the import itself injects the default\n// design tokens as CSS custom properties on `:root` (see tokens.ts). Without\n// it, `elements.js` alone never pulls tokens.ts in, so this entry (the one\n// the Vev bundle actually goes through) never ran that injection.\nimport '../ui/tokens.js'\n\n// Register the underlying custom elements when this entry is imported.\nregisterVioElements()\n\nexport const VioProduct = createComponent({\n react: React,\n tagName: 'vio-product',\n elementClass: VioProductEl,\n events: {\n onProductClick: 'vio:product-click',\n onProductAdd: 'vio:product-add',\n },\n})\n\nexport const VioProductCarousel = createComponent({\n react: React,\n tagName: 'vio-product-carousel',\n elementClass: VioProductCarouselEl,\n events: {},\n})\n\nexport const VioProductDetail = createComponent({\n react: React,\n tagName: 'vio-product-detail',\n elementClass: VioProductDetailEl,\n events: {\n onAddedToCart: 'vio:added-to-cart',\n onCheckoutOpen: 'vio:checkout-open',\n },\n})\n\nexport const VioCart = createComponent({\n react: React,\n tagName: 'vio-cart',\n elementClass: VioCartEl,\n events: {\n onPaymentSuccess: 'vio:payment-success',\n onCheckoutOpen: 'vio:checkout-open',\n },\n})\n\nexport const VioCheckout = createComponent({\n react: React,\n tagName: 'vio-checkout',\n elementClass: VioCheckoutEl,\n events: {\n onPaymentSuccess: 'vio:payment-success',\n },\n})\n\nexport { VioTokens, applyVioTheme, type VioThemeOverrides } from '../ui/tokens.js'\n"]}
@@ -425,4 +425,131 @@ declare global {
425
425
  }
426
426
  }
427
427
 
428
- export { VioCart as V, VioCheckout as a, VioProduct as b, VioProductCarousel as c, VioProductDetail as d };
428
+ /**
429
+ * Vio Design Tokens — editorial commerce aesthetic.
430
+ *
431
+ * Extracted from the Allermedia "Mote & Livsstil" reference (the target
432
+ * pilot site). Mood: Vogue-like fashion magazine — serif headlines,
433
+ * sans-serif body, near-monochrome palette, terracotta accent for
434
+ * editorial labels ("REDAKSJONENS FAVORITTER").
435
+ *
436
+ * Tokens are exposed both as a typed TS object (`VioTokens`) and as
437
+ * CSS custom properties on `:root` (auto-injected when this module is
438
+ * imported in a browser). Consumers can override individual variables
439
+ * to re-skin without touching SDK source.
440
+ */
441
+ declare const VioTokens: {
442
+ readonly color: {
443
+ readonly text: {
444
+ readonly primary: "#0a0a0a";
445
+ readonly secondary: "#666666";
446
+ readonly tertiary: "#999999";
447
+ readonly onPrimary: "#ffffff";
448
+ };
449
+ readonly accent: {
450
+ readonly editorial: "#c14a3b";
451
+ };
452
+ readonly surface: {
453
+ readonly base: "#ffffff";
454
+ readonly muted: "#f2f2f2";
455
+ readonly hover: "#fafafa";
456
+ };
457
+ readonly border: {
458
+ readonly subtle: "#e5e5e5";
459
+ readonly default: "#cccccc";
460
+ };
461
+ };
462
+ readonly font: {
463
+ readonly serif: "\"Tinos\", \"Playfair Display\", Georgia, serif";
464
+ readonly sans: "\"Inter\", -apple-system, \"Helvetica Neue\", Arial, sans-serif";
465
+ };
466
+ readonly size: {
467
+ readonly xs: "12px";
468
+ readonly sm: "14px";
469
+ readonly md: "16px";
470
+ readonly lg: "20px";
471
+ readonly xl: "24px";
472
+ readonly '2xl': "32px";
473
+ readonly '3xl': "40px";
474
+ };
475
+ readonly weight: {
476
+ readonly regular: 400;
477
+ readonly medium: 500;
478
+ readonly semibold: 600;
479
+ readonly bold: 700;
480
+ };
481
+ readonly tracking: {
482
+ readonly label: "0.1em";
483
+ readonly title: "0";
484
+ };
485
+ readonly lineHeight: {
486
+ readonly tight: 1.1;
487
+ readonly snug: 1.3;
488
+ readonly normal: 1.5;
489
+ };
490
+ readonly space: {
491
+ readonly xs: "4px";
492
+ readonly sm: "8px";
493
+ readonly md: "16px";
494
+ readonly lg: "24px";
495
+ readonly xl: "32px";
496
+ readonly '2xl': "48px";
497
+ readonly '3xl': "64px";
498
+ };
499
+ readonly radius: {
500
+ readonly none: "0";
501
+ readonly sm: "2px";
502
+ readonly md: "4px";
503
+ readonly lg: "8px";
504
+ readonly full: "9999px";
505
+ };
506
+ };
507
+ /**
508
+ * Theming — override design tokens without touching SDK source.
509
+ *
510
+ * Every `<vio-*>` component reads colors/fonts via `var(--vio-color-accent,
511
+ * …)` etc. (shadow DOM inherits CSS custom properties from the light DOM,
512
+ * so this reaches every component including Apple Pay/Klarna/Vipps panels).
513
+ * `applyVioTheme` is the one supported way to set them: an inline style on
514
+ * `:root` (or a scoped element) always wins over the stylesheet rule
515
+ * `injectTokens` installs above, regardless of import/injection order — no
516
+ * specificity fights, no reaching for `!important`.
517
+ *
518
+ * A curated subset on purpose: colors + fonts are what a merchant/publisher
519
+ * actually wants a "brand settings" panel for. Spacing/radius/sizes stay
520
+ * internal — expose them here later if a real need shows up, don't
521
+ * speculatively surface the whole token set as public API.
522
+ *
523
+ * Host integrations (the Vio Config panel in Vev, a future Replit CMS
524
+ * panel, anything else) should call this ONE function — never set
525
+ * `--vio-*` custom properties by hand. If the injection mechanism changes
526
+ * later, only this function needs updating, not every panel that theme.
527
+ */
528
+ interface VioThemeOverrides {
529
+ colorText?: string;
530
+ colorTextSecondary?: string;
531
+ colorTextTertiary?: string;
532
+ colorTextOnPrimary?: string;
533
+ colorAccent?: string;
534
+ colorSurface?: string;
535
+ colorSurfaceMuted?: string;
536
+ colorSurfaceHover?: string;
537
+ colorBorder?: string;
538
+ colorBorderDefault?: string;
539
+ fontSerif?: string;
540
+ fontSans?: string;
541
+ }
542
+ /**
543
+ * Apply (or clear) theme overrides. Pass `null`/`undefined` for a key to
544
+ * revert it to the SDK default instead of leaving a stale override behind
545
+ * — lets a host re-apply a full overrides object on every save without
546
+ * having to track which keys it previously set.
547
+ *
548
+ * `target` defaults to `document.documentElement` (`:root`, matching where
549
+ * `injectTokens` installs the defaults). Pass a specific element to scope
550
+ * the theme to one subtree instead of the whole page — e.g. multiple
551
+ * differently-branded sponsors on the same page.
552
+ */
553
+ declare function applyVioTheme(overrides: VioThemeOverrides, target?: HTMLElement | null): void;
554
+
555
+ export { VioCart as V, VioCheckout as a, VioProduct as b, VioProductCarousel as c, VioProductDetail as d, type VioThemeOverrides as e, VioTokens as f, applyVioTheme as g };
@@ -1,4 +1,4 @@
1
- export { V as VioCart, a as VioCheckout, b as VioProduct, c as VioProductCarousel, d as VioProductDetail } from '../vio-checkout-T9R5hpDx.js';
1
+ export { V as VioCart, a as VioCheckout, b as VioProduct, c as VioProductCarousel, d as VioProductDetail, e as VioThemeOverrides, f as VioTokens, g as applyVioTheme } from '../tokens-CvqQYURw.js';
2
2
  import 'lit-html';
3
3
  import 'lit';
4
4
 
@@ -24,86 +24,6 @@ import 'lit';
24
24
  */
25
25
  declare function registerVioElements(): void;
26
26
 
27
- /**
28
- * Vio Design Tokens — editorial commerce aesthetic.
29
- *
30
- * Extracted from the Allermedia "Mote & Livsstil" reference (the target
31
- * pilot site). Mood: Vogue-like fashion magazine — serif headlines,
32
- * sans-serif body, near-monochrome palette, terracotta accent for
33
- * editorial labels ("REDAKSJONENS FAVORITTER").
34
- *
35
- * Tokens are exposed both as a typed TS object (`VioTokens`) and as
36
- * CSS custom properties on `:root` (auto-injected when this module is
37
- * imported in a browser). Consumers can override individual variables
38
- * to re-skin without touching SDK source.
39
- */
40
- declare const VioTokens: {
41
- readonly color: {
42
- readonly text: {
43
- readonly primary: "#0a0a0a";
44
- readonly secondary: "#666666";
45
- readonly tertiary: "#999999";
46
- readonly onPrimary: "#ffffff";
47
- };
48
- readonly accent: {
49
- readonly editorial: "#c14a3b";
50
- };
51
- readonly surface: {
52
- readonly base: "#ffffff";
53
- readonly muted: "#f2f2f2";
54
- readonly hover: "#fafafa";
55
- };
56
- readonly border: {
57
- readonly subtle: "#e5e5e5";
58
- readonly default: "#cccccc";
59
- };
60
- };
61
- readonly font: {
62
- readonly serif: "\"Tinos\", \"Playfair Display\", Georgia, serif";
63
- readonly sans: "\"Inter\", -apple-system, \"Helvetica Neue\", Arial, sans-serif";
64
- };
65
- readonly size: {
66
- readonly xs: "12px";
67
- readonly sm: "14px";
68
- readonly md: "16px";
69
- readonly lg: "20px";
70
- readonly xl: "24px";
71
- readonly '2xl': "32px";
72
- readonly '3xl': "40px";
73
- };
74
- readonly weight: {
75
- readonly regular: 400;
76
- readonly medium: 500;
77
- readonly semibold: 600;
78
- readonly bold: 700;
79
- };
80
- readonly tracking: {
81
- readonly label: "0.1em";
82
- readonly title: "0";
83
- };
84
- readonly lineHeight: {
85
- readonly tight: 1.1;
86
- readonly snug: 1.3;
87
- readonly normal: 1.5;
88
- };
89
- readonly space: {
90
- readonly xs: "4px";
91
- readonly sm: "8px";
92
- readonly md: "16px";
93
- readonly lg: "24px";
94
- readonly xl: "32px";
95
- readonly '2xl': "48px";
96
- readonly '3xl': "64px";
97
- };
98
- readonly radius: {
99
- readonly none: "0";
100
- readonly sm: "2px";
101
- readonly md: "4px";
102
- readonly lg: "8px";
103
- readonly full: "9999px";
104
- };
105
- };
106
-
107
27
  /**
108
28
  * Vio UI — Web Components + design tokens.
109
29
  *
@@ -118,6 +38,6 @@ declare const VioTokens: {
118
38
  * SSR-safe: every side-effect guards on `typeof document !== 'undefined'`.
119
39
  */
120
40
 
121
- declare const VIO_UI_VERSION = "0.2.0";
41
+ declare const VIO_UI_VERSION = "0.3.0";
122
42
 
123
- export { VIO_UI_VERSION, VioTokens, registerVioElements };
43
+ export { VIO_UI_VERSION, registerVioElements };
package/dist/ui/index.js CHANGED
@@ -1,138 +1,11 @@
1
- import { registerVioElements } from '../chunk-NWORYWIL.js';
2
- export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, registerVioElements } from '../chunk-NWORYWIL.js';
1
+ import { registerVioElements } from '../chunk-V5ZQG2H5.js';
2
+ export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements } from '../chunk-V5ZQG2H5.js';
3
3
  import '../chunk-NP2KCM7X.js';
4
4
 
5
- // src/ui/tokens.ts
6
- var VioTokens = {
7
- color: {
8
- text: {
9
- primary: "#0a0a0a",
10
- secondary: "#666666",
11
- tertiary: "#999999",
12
- onPrimary: "#ffffff"
13
- },
14
- accent: {
15
- editorial: "#c14a3b"
16
- // "REDAKSJONENS FAVORITTER" red
17
- },
18
- surface: {
19
- base: "#ffffff",
20
- muted: "#f2f2f2",
21
- // product image background
22
- hover: "#fafafa"
23
- },
24
- border: {
25
- subtle: "#e5e5e5",
26
- default: "#cccccc"
27
- }
28
- },
29
- font: {
30
- serif: '"Tinos", "Playfair Display", Georgia, serif',
31
- sans: '"Inter", -apple-system, "Helvetica Neue", Arial, sans-serif'
32
- },
33
- size: {
34
- xs: "12px",
35
- sm: "14px",
36
- md: "16px",
37
- lg: "20px",
38
- xl: "24px",
39
- "2xl": "32px",
40
- "3xl": "40px"
41
- },
42
- weight: {
43
- regular: 400,
44
- medium: 500,
45
- semibold: 600,
46
- bold: 700
47
- },
48
- tracking: {
49
- label: "0.1em",
50
- // uppercase labels (BRAND, RETAILER, REDAKSJONENS FAVORITTER)
51
- title: "0"
52
- },
53
- lineHeight: {
54
- tight: 1.1,
55
- snug: 1.3,
56
- normal: 1.5
57
- },
58
- space: {
59
- xs: "4px",
60
- sm: "8px",
61
- md: "16px",
62
- lg: "24px",
63
- xl: "32px",
64
- "2xl": "48px",
65
- "3xl": "64px"
66
- },
67
- radius: {
68
- none: "0",
69
- sm: "2px",
70
- md: "4px",
71
- lg: "8px",
72
- full: "9999px"
73
- }
74
- };
75
- var VIO_TOKENS_CSS = `
76
- :root {
77
- /* color \u2014 text */
78
- --vio-color-text: ${VioTokens.color.text.primary};
79
- --vio-color-text-secondary: ${VioTokens.color.text.secondary};
80
- --vio-color-text-tertiary: ${VioTokens.color.text.tertiary};
81
- --vio-color-text-on-primary:${VioTokens.color.text.onPrimary};
82
-
83
- /* color \u2014 accent */
84
- --vio-color-accent: ${VioTokens.color.accent.editorial};
85
-
86
- /* color \u2014 surface */
87
- --vio-color-surface: ${VioTokens.color.surface.base};
88
- --vio-color-surface-muted: ${VioTokens.color.surface.muted};
89
- --vio-color-surface-hover: ${VioTokens.color.surface.hover};
90
-
91
- /* color \u2014 border */
92
- --vio-color-border: ${VioTokens.color.border.subtle};
93
- --vio-color-border-default: ${VioTokens.color.border.default};
94
-
95
- /* font */
96
- --vio-font-serif: ${VioTokens.font.serif};
97
- --vio-font-sans: ${VioTokens.font.sans};
98
-
99
- /* size */
100
- --vio-size-xs: ${VioTokens.size.xs};
101
- --vio-size-sm: ${VioTokens.size.sm};
102
- --vio-size-md: ${VioTokens.size.md};
103
- --vio-size-lg: ${VioTokens.size.lg};
104
- --vio-size-xl: ${VioTokens.size.xl};
105
-
106
- /* tracking (uppercase letterspacing) */
107
- --vio-tracking-label: ${VioTokens.tracking.label};
108
-
109
- /* space */
110
- --vio-space-xs: ${VioTokens.space.xs};
111
- --vio-space-sm: ${VioTokens.space.sm};
112
- --vio-space-md: ${VioTokens.space.md};
113
- --vio-space-lg: ${VioTokens.space.lg};
114
- --vio-space-xl: ${VioTokens.space.xl};
115
-
116
- /* radius */
117
- --vio-radius-sm: ${VioTokens.radius.sm};
118
- --vio-radius-md: ${VioTokens.radius.md};
119
- --vio-radius-lg: ${VioTokens.radius.lg};
120
- }
121
- `;
122
- function injectTokens() {
123
- if (typeof document === "undefined") return;
124
- if (document.querySelector('style[data-vio="tokens"]') !== null) return;
125
- const style = document.createElement("style");
126
- style.setAttribute("data-vio", "tokens");
127
- style.textContent = VIO_TOKENS_CSS;
128
- document.head.appendChild(style);
129
- }
130
- injectTokens();
131
-
132
5
  // src/ui/index.ts
133
6
  registerVioElements();
134
- var VIO_UI_VERSION = "0.2.0";
7
+ var VIO_UI_VERSION = "0.3.0";
135
8
 
136
- export { VIO_UI_VERSION, VioTokens };
9
+ export { VIO_UI_VERSION };
137
10
  //# sourceMappingURL=index.js.map
138
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/tokens.ts","../../src/ui/index.ts"],"names":[],"mappings":";;;;;AAcO,IAAM,SAAA,GAAY;AAAA,EACvB,KAAA,EAAO;AAAA,IACL,IAAA,EAAM;AAAA,MACJ,OAAA,EAAS,SAAA;AAAA,MACT,SAAA,EAAW,SAAA;AAAA,MACX,QAAA,EAAU,SAAA;AAAA,MACV,SAAA,EAAW;AAAA,KACb;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,SAAA,EAAW;AAAA;AAAA,KACb;AAAA,IACA,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,SAAA;AAAA,MACN,KAAA,EAAO,SAAA;AAAA;AAAA,MACP,KAAA,EAAO;AAAA,KACT;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,MAAA,EAAQ,SAAA;AAAA,MACR,OAAA,EAAS;AAAA;AACX,GACF;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,KAAA,EAAO,6CAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA,IAAA,EAAM;A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,qBAAA,EACnB,SAAA,CAAU,OAAO,EAAE,CAAA;AAAA,qBAAA,EACnB,SAAA,CAAU,OAAO,EAAE,CAAA;AAAA;AAAA,CAAA;AAI1C,SAAS,YAAA,GAAqB;AAC5B,EAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,EAAA,IAAI,QAAA,CAAS,aAAA,CAAc,0BAA0B,CAAA,KAAM,IAAA,EAAM;AACjE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,aAAA,CAAc,OAAO,CAAA;AAC5C,EAAA,KAAA,CAAM,YAAA,CAAa,YAAY,QAAQ,CAAA;AACvC,EAAA,KAAA,CAAM,WAAA,GAAc,cAAA;AACpB,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,KAAK,CAAA;AACjC;AAEA,YAAA,EAAa;;;AC5Hb,mBAAA,EAAoB;AAYb,IAAM,cAAA,GAAiB","file":"index.js","sourcesContent":["/**\n * Vio Design Tokens — editorial commerce aesthetic.\n *\n * Extracted from the Allermedia \"Mote & Livsstil\" reference (the target\n * pilot site). Mood: Vogue-like fashion magazine — serif headlines,\n * sans-serif body, near-monochrome palette, terracotta accent for\n * editorial labels (\"REDAKSJONENS FAVORITTER\").\n *\n * Tokens are exposed both as a typed TS object (`VioTokens`) and as\n * CSS custom properties on `:root` (auto-injected when this module is\n * imported in a browser). Consumers can override individual variables\n * to re-skin without touching SDK source.\n */\n\nexport const VioTokens = {\n color: {\n text: {\n primary: '#0a0a0a',\n secondary: '#666666',\n tertiary: '#999999',\n onPrimary: '#ffffff',\n },\n accent: {\n editorial: '#c14a3b', // \"REDAKSJONENS FAVORITTER\" red\n },\n surface: {\n base: '#ffffff',\n muted: '#f2f2f2', // product image background\n hover: '#fafafa',\n },\n border: {\n subtle: '#e5e5e5',\n default: '#cccccc',\n },\n },\n font: {\n serif: '\"Tinos\", \"Playfair Display\", Georgia, serif',\n sans: '\"Inter\", -apple-system, \"Helvetica Neue\", Arial, sans-serif',\n },\n size: {\n xs: '12px',\n sm: '14px',\n md: '16px',\n lg: '20px',\n xl: '24px',\n '2xl': '32px',\n '3xl': '40px',\n },\n weight: {\n regular: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\n },\n tracking: {\n label: '0.1em', // uppercase labels (BRAND, RETAILER, REDAKSJONENS FAVORITTER)\n title: '0',\n },\n lineHeight: {\n tight: 1.1,\n snug: 1.3,\n normal: 1.5,\n },\n space: {\n xs: '4px',\n sm: '8px',\n md: '16px',\n lg: '24px',\n xl: '32px',\n '2xl': '48px',\n '3xl': '64px',\n },\n radius: {\n none: '0',\n sm: '2px',\n md: '4px',\n lg: '8px',\n full: '9999px',\n },\n} as const\n\n/**\n * CSS Custom Properties — generated from VioTokens. Injected once into\n * the document head on first import. Consumers can override any\n * `--vio-*` var on their root or component selector to customise.\n */\nconst VIO_TOKENS_CSS = `\n :root {\n /* color — text */\n --vio-color-text: ${VioTokens.color.text.primary};\n --vio-color-text-secondary: ${VioTokens.color.text.secondary};\n --vio-color-text-tertiary: ${VioTokens.color.text.tertiary};\n --vio-color-text-on-primary:${VioTokens.color.text.onPrimary};\n\n /* color — accent */\n --vio-color-accent: ${VioTokens.color.accent.editorial};\n\n /* color — surface */\n --vio-color-surface: ${VioTokens.color.surface.base};\n --vio-color-surface-muted: ${VioTokens.color.surface.muted};\n --vio-color-surface-hover: ${VioTokens.color.surface.hover};\n\n /* color — border */\n --vio-color-border: ${VioTokens.color.border.subtle};\n --vio-color-border-default: ${VioTokens.color.border.default};\n\n /* font */\n --vio-font-serif: ${VioTokens.font.serif};\n --vio-font-sans: ${VioTokens.font.sans};\n\n /* size */\n --vio-size-xs: ${VioTokens.size.xs};\n --vio-size-sm: ${VioTokens.size.sm};\n --vio-size-md: ${VioTokens.size.md};\n --vio-size-lg: ${VioTokens.size.lg};\n --vio-size-xl: ${VioTokens.size.xl};\n\n /* tracking (uppercase letterspacing) */\n --vio-tracking-label: ${VioTokens.tracking.label};\n\n /* space */\n --vio-space-xs: ${VioTokens.space.xs};\n --vio-space-sm: ${VioTokens.space.sm};\n --vio-space-md: ${VioTokens.space.md};\n --vio-space-lg: ${VioTokens.space.lg};\n --vio-space-xl: ${VioTokens.space.xl};\n\n /* radius */\n --vio-radius-sm: ${VioTokens.radius.sm};\n --vio-radius-md: ${VioTokens.radius.md};\n --vio-radius-lg: ${VioTokens.radius.lg};\n }\n`\n\nfunction injectTokens(): void {\n if (typeof document === 'undefined') return\n if (document.querySelector('style[data-vio=\"tokens\"]') !== null) return\n const style = document.createElement('style')\n style.setAttribute('data-vio', 'tokens')\n style.textContent = VIO_TOKENS_CSS\n document.head.appendChild(style)\n}\n\ninjectTokens()\n","/**\n * Vio UI — Web Components + design tokens.\n *\n * Importing this file (directly or via the main `vio` entry) has two\n * side-effects:\n * 1. Injects design tokens as CSS custom properties on `:root`\n * 2. Registers all `<vio-*>` custom elements (via `registerVioElements()`)\n *\n * Registration goes through an explicit function call (see ./elements) so it\n * survives tree-shaking while keeping `./core` tree-shakeable.\n *\n * SSR-safe: every side-effect guards on `typeof document !== 'undefined'`.\n */\n\nimport './tokens.js'\nimport { registerVioElements } from './elements.js'\n\n// Auto-register on import, so the conventional `import '@vio-live/web-sdk/ui'`\n// keeps working. This call is what pins the registration into this entry.\nregisterVioElements()\n\nexport { VioTokens } from './tokens.js'\nexport {\n registerVioElements,\n VioProduct,\n VioProductCarousel,\n VioProductDetail,\n VioCart,\n VioCheckout,\n} from './elements.js'\n\nexport const VIO_UI_VERSION = '0.2.0'\n"]}
1
+ {"version":3,"sources":["../../src/ui/index.ts"],"names":[],"mappings":";;;;;AAmBA,mBAAA,EAAoB;AAYb,IAAM,cAAA,GAAiB","file":"index.js","sourcesContent":["/**\n * Vio UI — Web Components + design tokens.\n *\n * Importing this file (directly or via the main `vio` entry) has two\n * side-effects:\n * 1. Injects design tokens as CSS custom properties on `:root`\n * 2. Registers all `<vio-*>` custom elements (via `registerVioElements()`)\n *\n * Registration goes through an explicit function call (see ./elements) so it\n * survives tree-shaking while keeping `./core` tree-shakeable.\n *\n * SSR-safe: every side-effect guards on `typeof document !== 'undefined'`.\n */\n\nimport './tokens.js'\nimport { registerVioElements } from './elements.js'\n\n// Auto-register on import, so the conventional `import '@vio-live/web-sdk/ui'`\n// keeps working. This call is what pins the registration into this entry.\nregisterVioElements()\n\nexport { VioTokens, applyVioTheme, type VioThemeOverrides } from './tokens.js'\nexport {\n registerVioElements,\n VioProduct,\n VioProductCarousel,\n VioProductDetail,\n VioCart,\n VioCheckout,\n} from './elements.js'\n\nexport const VIO_UI_VERSION = '0.3.0'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vio-live/web-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Vio Web SDK — in-site shoppable + native checkout, designed for editorial commerce sites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",