@foxy.io/elements 1.11.0-beta.3 → 1.11.0-beta.4
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/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +2 -2
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -0
- package/dist/cdn/foxy-customer-api.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +2 -2
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-nucleon-element.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -230
- package/dist/cdn/foxy-spinner.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +2 -2
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/{shared-bf28ab5e.js → shared-005e1fc5.js} +1 -1
- package/dist/cdn/{shared-84203d52.js → shared-00811efe.js} +1 -1
- package/dist/cdn/{shared-333c169c.js → shared-07867126.js} +1 -1
- package/dist/cdn/{shared-c70d9713.js → shared-09384e52.js} +1 -1
- package/dist/cdn/{shared-f01a1892.js → shared-1d138c7a.js} +1 -1
- package/dist/cdn/{shared-1a1aa39f.js → shared-2864fa12.js} +1 -1
- package/dist/cdn/{shared-525dd8c8.js → shared-420ef4a6.js} +1 -1
- package/dist/cdn/{shared-a7709d26.js → shared-423c0fb8.js} +1 -1
- package/dist/cdn/{shared-e058cb87.js → shared-50ff98d4.js} +1 -1
- package/dist/cdn/{shared-96de56d4.js → shared-524b3c41.js} +1 -1
- package/dist/cdn/{shared-bba615b8.js → shared-52d3b939.js} +19 -19
- package/dist/cdn/{shared-497fd63c.js → shared-670c194c.js} +1 -1
- package/dist/cdn/shared-7bc6d89f.js +1 -0
- package/dist/cdn/{shared-8057ee9c.js → shared-8dd2593f.js} +1 -1
- package/dist/cdn/{shared-17322a2a.js → shared-93df17fe.js} +5 -5
- package/dist/cdn/shared-957a60e1.js +1 -0
- package/dist/cdn/shared-96fcd96f.js +1 -0
- package/dist/cdn/{shared-9f78e096.js → shared-a4e05ba4.js} +1 -1
- package/dist/cdn/{shared-aac9fed8.js → shared-a6f0d39f.js} +1 -1
- package/dist/cdn/shared-b76c5f57.js +15 -0
- package/dist/cdn/{shared-23966eed.js → shared-c9e0b693.js} +1 -1
- package/dist/cdn/{shared-851b97ef.js → shared-d8160231.js} +1 -1
- package/dist/cdn/shared-dc5928e9.js +1 -0
- package/dist/cdn/{shared-a5fbfdc7.js → shared-e5ab982d.js} +1 -1
- package/dist/cdn/shared-f4119f12.js +230 -0
- package/dist/cdn/{shared-090432b4.js → shared-f62abcd5.js} +1 -1
- package/dist/cdn/{shared-bc29ada7.js → shared-f866a93f.js} +1 -1
- package/dist/cdn/{shared-f06d08d5.js → shared-fd05e1a1.js} +1 -1
- package/dist/cdn/translations/shared/de.json +1 -0
- package/dist/cdn/translations/shared/en.json +1 -0
- package/dist/cdn/translations/shared/es.json +1 -0
- package/dist/elements/public/CollectionPage/CollectionPage.d.ts +2 -0
- package/dist/elements/public/CollectionPage/CollectionPage.js +7 -0
- package/dist/elements/public/CollectionPage/CollectionPage.js.map +1 -1
- package/dist/elements/public/CollectionPage/types.d.ts +3 -0
- package/dist/elements/public/CollectionPage/types.js.map +1 -1
- package/dist/elements/public/CollectionPages/CollectionPages.d.ts +2 -0
- package/dist/elements/public/CollectionPages/CollectionPages.js +7 -0
- package/dist/elements/public/CollectionPages/CollectionPages.js.map +1 -1
- package/dist/elements/public/CollectionPages/types.d.ts +3 -0
- package/dist/elements/public/CollectionPages/types.js.map +1 -1
- package/dist/elements/public/CustomFieldForm/CustomFieldForm.d.ts +49 -0
- package/dist/elements/public/CustomFieldForm/CustomFieldForm.js +235 -0
- package/dist/elements/public/CustomFieldForm/CustomFieldForm.js.map +1 -0
- package/dist/elements/public/CustomFieldForm/index.d.ts +9 -0
- package/dist/elements/public/CustomFieldForm/index.js +11 -0
- package/dist/elements/public/CustomFieldForm/index.js.map +1 -0
- package/dist/elements/public/CustomFieldForm/types.d.ts +22 -0
- package/dist/elements/public/CustomFieldForm/types.js +2 -0
- package/dist/elements/public/CustomFieldForm/types.js.map +1 -0
- package/dist/elements/public/NucleonElement/NucleonElement.d.ts +8 -0
- package/dist/elements/public/NucleonElement/NucleonElement.js +40 -6
- package/dist/elements/public/NucleonElement/NucleonElement.js.map +1 -1
- package/dist/elements/public/index.d.ts +1 -0
- package/dist/elements/public/index.defined.d.ts +1 -0
- package/dist/elements/public/index.defined.js +1 -0
- package/dist/elements/public/index.defined.js.map +1 -1
- package/dist/elements/public/index.js +1 -0
- package/dist/elements/public/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/cdn/shared-306080cb.js +0 -1
- package/dist/cdn/shared-361d5d17.js +0 -15
- package/dist/cdn/shared-6872bf5c.js +0 -1
- package/dist/cdn/shared-69d0ca61.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NucleonElement.js","sourceRoot":"","sources":["../../../../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GAAG,CAAC","sourcesContent":["import { ComputedElementProperties, HALJSONResource, NucleonMachine, NucleonV8N } from './types';\nimport { LitElement, PropertyDeclarations } from 'lit-element';\nimport { Nucleon, Rumour } from '@foxy.io/sdk/core';\nimport { assign, interpret } from 'xstate';\n\nimport { API } from './API';\nimport { FetchEvent } from './FetchEvent';\nimport { UpdateEvent } from './UpdateEvent';\nimport memoize from 'lodash-es/memoize';\nimport { serveFromCache } from './serveFromCache';\n\n/**\n * Base class for custom elements working with remote HAL+JSON resources.\n *\n * @fires NucleonElement#update - Instance of `NucleonElement.UpdateEvent`. Dispatched on an element whenever it changes its state.\n * @fires NucleonElement#fetch - Instance of `NucleonElement.API.FetchEvent`. Emitted before each API request.\n *\n * @element foxy-nucleon\n * @since 1.1.0\n */\nexport class NucleonElement<TData extends HALJSONResource> extends LitElement {\n /**\n * Instances of this event are dispatched on an element whenever it changes its\n * state (e.g. when going from `busy` to `idle` or on `form` data change).\n * This event isn't cancelable, and it does not bubble.\n * @readonly\n */\n static readonly UpdateEvent = UpdateEvent;\n\n /**\n * Creates a tagged [Rumour](https://sdk.foxy.dev/classes/_core_index_.rumour.html)\n * instance if it doesn't exist or returns cached one otherwise. NucleonElements\n * use empty Rumour group by default.\n * @readonly\n */\n static readonly Rumour = memoize<(group: string) => Rumour>(() => new Rumour());\n\n /**\n * Universal [API](https://sdk.foxy.dev/classes/_core_index_.api.html) client\n * that dispatches cancellable `FetchEvent` on an element before each request.\n * @readonly\n */\n static readonly API = API;\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n related: { type: Array },\n parent: { type: String },\n group: { type: String, noAccessor: true },\n href: { type: String, noAccessor: true },\n lang: { type: String },\n };\n }\n\n /**\n * Array of validation functions. Each function accepts `element.form` and must return\n * either an error code string if form data fails the check or `true` otherwise.\n * Error codes are collected in `element.errors`. Empty by default.\n */\n static get v8n(): NucleonV8N<any> {\n return [];\n }\n\n /**\n * Optional ISO 639-1 code describing the language element content is written in.\n * Changing the `lang` attribute will update the value of this property.\n */\n lang = '';\n\n /**\n * Optional URL of the collection this element's resource belongs to.\n * Changing the `parent` attribute will update the value of this property.\n */\n parent = '';\n\n /**\n * Optional URI list of the related resources. If Rumour encounters a related\n * resource on creation or deletion, it will be reloaded from source.\n */\n related: string[] = [];\n\n private __href = '';\n\n private __group = '';\n\n private __unsubscribeFromRumour!: () => void;\n\n private __fetchEventHandler!: (evt: Event) => void;\n\n private readonly __service = interpret(\n (Nucleon.machine as NucleonMachine<TData>).withConfig({\n services: {\n sendDelete: () => this._sendDelete(),\n sendPatch: ({ edits }) => this._sendPatch(edits!),\n sendPost: ({ edits }) => this._sendPost(edits!),\n sendGet: () => this._sendGet(),\n },\n\n actions: {\n validate: assign<Nucleon.Context<TData, string>, Nucleon.Event<TData>>({\n errors: context => {\n const rules = (this.constructor as typeof NucleonElement).v8n;\n const form = { ...context.data, ...context.edits };\n\n return rules\n .map(validate => validate(form))\n .filter(v8nResult => typeof v8nResult === 'string')\n .filter((err, errIndex, errs) => errs.indexOf(err) === errIndex) as string[];\n },\n }),\n },\n })\n );\n\n /**\n * If network request returns non-2XX code, the entire error response\n * will be available via this getter.\n *\n * This property is readonly. Changing failure records via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override error status.\n *\n * @since 1.4.0\n */\n get failure(): Response | null {\n return this.__service.state.context.failure;\n }\n\n /**\n * Array of validation errors returned from `NucleonElement.v8n` checks.\n *\n * This property is readonly. Adding or removing error codes via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override validity status.\n */\n get errors(): string[] {\n return this.__service.state.context.errors;\n }\n\n /**\n * Resource snapshot with edits applied. Empty object if unavailable.\n *\n * This property and its value are readonly. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please use `element.edit({ foo: 'bar' })` instead.\n * If you need to replace the entire data object, consider using `element.data`.\n */\n get form(): Partial<TData> {\n const { data, edits } = this.__service.state.context;\n return { ...data, ...edits } as Partial<TData>;\n }\n\n /**\n * Resource snapshot as-is, no edits applied. Null if unavailable.\n *\n * Returned value is not reactive. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please set the property instead: `element.data = { ...element.data, foo: 'bar' }`.\n * If you're processing user input, consider using `element.form` and `element.edit()` instead.\n */\n get data(): TData | null {\n return this.__service.state.context.data;\n }\n\n set data(data: TData | null) {\n this.__service.send({ type: 'SET_DATA', data });\n this.__href = data?._links.self.href ?? '';\n }\n\n /**\n * Rumour group. Elements in different groups will not share updates. Empty by default.\n * @example element.group = 'my-group'\n */\n get group(): string {\n return this.__group;\n }\n\n set group(value: string) {\n this.__group = value;\n this.__destroyRumour();\n this.__createRumour();\n }\n\n /**\n * Optional URL of the resource to load. Switches element to `idle.template` state if empty (default).\n * @example element.href = 'https://demo.foxycart.com/s/customer/attributes/0'\n */\n get href(): string {\n return this.__href;\n }\n\n set href(value: string) {\n this.__href = value;\n\n if (value) {\n this.__service.send({ type: 'FETCH' });\n } else {\n this.__service.send({ type: 'SET_DATA', data: null });\n }\n }\n\n /**\n * Checks if this element is in the given state.\n * @example element.in({ idle: 'snapshot' })\n */\n in<TStateValue extends Nucleon.State<TData, string>['value']>(\n stateValue: TStateValue\n ): this is this & ComputedElementProperties<TData, TStateValue> {\n return this.__service.state.matches(stateValue);\n }\n\n /**\n * Clears all edits and emits the `update` event.\n * @example element.undo()\n */\n undo(): void {\n this.__service.send({ type: 'UNDO' });\n }\n\n /**\n * Applies an edit to the local resource snapshot or its template and emits the `update` event.\n * @example element.edit({ first_name: 'Alex' })\n */\n edit(data: Partial<TData>): void {\n this.__service.send({ type: 'EDIT', data });\n }\n\n /**\n * Submits the form, updating the resource if href isn't empty or creating it otherwise.\n * Emits multiple `update` events as element state changes. Has no effect on invalid forms.\n * @example element.submit()\n */\n submit(): void {\n this.__service.send({ type: 'SUBMIT' });\n }\n\n /**\n * Sends a DELETE request to `element.href` and clears local data on success.\n * Emits multiple update events as element state changes.\n * @example element.delete()\n */\n delete(): void {\n this.__service.send({ type: 'DELETE' });\n }\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n\n this.__createService();\n this.__createRumour();\n this.__createServer();\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.__destroyService();\n this.__destroyRumour();\n this.__destroyServer();\n }\n\n /** Sends API request. Throws an error on non-2XX response. */\n protected async _fetch(...args: Parameters<Window['fetch']>): Promise<TData> {\n const response = await new API(this).fetch(...args);\n if (!response.ok) throw response;\n return response.json();\n }\n\n /** POSTs to `element.parent`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPost(edits: Partial<TData>): Promise<TData> {\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.parent, { body, method: 'POST' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n this.__destroyRumour();\n rumour.share({ data, related, source: data._links.self.href });\n this.__createRumour();\n\n return data;\n }\n\n /** GETs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendGet(): Promise<TData> {\n const data = await this._fetch(this.href);\n const rumour = NucleonElement.Rumour(this.group);\n\n this.__destroyRumour();\n rumour.share({ data, source: this.href });\n this.__createRumour();\n\n return data;\n }\n\n /** PATCHes `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPatch(edits: Partial<TData>): Promise<TData> {\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.href, { body, method: 'PATCH' });\n const rumour = NucleonElement.Rumour(this.group);\n\n this.__destroyRumour();\n rumour.share({ data, source: this.href });\n this.__createRumour();\n\n return data;\n }\n\n /** DELETEs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendDelete(): Promise<TData> {\n const data = await this._fetch(this.href, { method: 'DELETE' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n this.__destroyRumour();\n rumour.share({ data: null, source: this.href, related });\n this.__createRumour();\n\n return data;\n }\n\n private __createService() {\n this.__service.onTransition(state => {\n if (!state.changed) return;\n\n const flags = state.toStrings().reduce((p, c) => [...p, ...c.split('.')], [] as string[]);\n this.setAttribute('state', [...new Set(flags)].join(' '));\n\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n });\n\n this.__service.onChange(() => {\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n });\n\n this.__service.start();\n }\n\n private __destroyService() {\n this.__service.stop();\n }\n\n private __createRumour() {\n const rumour = NucleonElement.Rumour(this.group);\n this.__unsubscribeFromRumour = rumour.track(update => this.__handleRumourUpdate(update));\n }\n\n private __destroyRumour() {\n this.__unsubscribeFromRumour?.();\n }\n\n private __createServer() {\n this.__fetchEventHandler = this.__handleFetchEvent.bind(this);\n this.addEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __destroyServer() {\n this.removeEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __handleRumourUpdate(update: (oldData: TData) => TData | null) {\n try {\n const oldData = this.__service.state?.context.data;\n if (!oldData) return;\n\n const newData = update(oldData);\n if (newData !== oldData) this.__service.send({ data: newData, type: 'SET_DATA' });\n } catch (err) {\n if (err instanceof Rumour.UpdateError) {\n this.__service.send({ type: 'FETCH' });\n } else {\n throw err;\n }\n }\n }\n\n private __handleFetchEvent(event: Event) {\n if (!(event instanceof FetchEvent)) return;\n if (event.request.method !== 'GET') return;\n\n const cacheResponse = serveFromCache(event.request.url, this.data);\n if (!cacheResponse.ok) return;\n\n event.respondWith(Promise.resolve(cacheResponse));\n console.debug(\n `%c@foxy.io/elements::${this.localName}\\n%c200%c GET ${event.request.url}`,\n 'color: gray',\n `background: gray; padding: 0 .2em; border-radius: .2em; color: white;`,\n ''\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NucleonElement.js","sourceRoot":"","sources":["../../../../src/elements/public/NucleonElement/NucleonElement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAwB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,M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ine, NucleonV8N } from './types';\nimport { LitElement, PropertyDeclarations } from 'lit-element';\nimport { Nucleon, Rumour } from '@foxy.io/sdk/core';\nimport { assign, interpret } from 'xstate';\n\nimport { API } from './API';\nimport { FetchEvent } from './FetchEvent';\nimport { UpdateEvent } from './UpdateEvent';\nimport memoize from 'lodash-es/memoize';\nimport { serveFromCache } from './serveFromCache';\n\n/**\n * Base class for custom elements working with remote HAL+JSON resources.\n *\n * @fires NucleonElement#update - Instance of `NucleonElement.UpdateEvent`. Dispatched on an element whenever it changes its state.\n * @fires NucleonElement#fetch - Instance of `NucleonElement.API.FetchEvent`. Emitted before each API request.\n *\n * @element foxy-nucleon\n * @since 1.1.0\n */\nexport class NucleonElement<TData extends HALJSONResource> extends LitElement {\n /**\n * Instances of this event are dispatched on an element whenever it changes its\n * state (e.g. when going from `busy` to `idle` or on `form` data change).\n * This event isn't cancelable, and it does not bubble.\n * @readonly\n */\n static readonly UpdateEvent = UpdateEvent;\n\n /**\n * Creates a tagged [Rumour](https://sdk.foxy.dev/classes/_core_index_.rumour.html)\n * instance if it doesn't exist or returns cached one otherwise. NucleonElements\n * use empty Rumour group by default.\n * @readonly\n */\n static readonly Rumour = memoize<(group: string) => Rumour>(() => new Rumour());\n\n /**\n * Universal [API](https://sdk.foxy.dev/classes/_core_index_.api.html) client\n * that dispatches cancellable `FetchEvent` on an element before each request.\n * @readonly\n */\n static readonly API = API;\n\n /** @readonly */\n static get properties(): PropertyDeclarations {\n return {\n related: { type: Array },\n parent: { type: String },\n group: { type: String, noAccessor: true },\n href: { type: String, noAccessor: true },\n lang: { type: String },\n };\n }\n\n /**\n * Array of validation functions. Each function accepts `element.form` and must return\n * either an error code string if form data fails the check or `true` otherwise.\n * Error codes are collected in `element.errors`. Empty by default.\n */\n static get v8n(): NucleonV8N<any> {\n return [];\n }\n\n /**\n * Optional ISO 639-1 code describing the language element content is written in.\n * Changing the `lang` attribute will update the value of this property.\n */\n lang = '';\n\n /**\n * Optional URL of the collection this element's resource belongs to.\n * Changing the `parent` attribute will update the value of this property.\n */\n parent = '';\n\n /**\n * Optional URI list of the related resources. If Rumour encounters a related\n * resource on creation or deletion, it will be reloaded from source.\n */\n related: string[] = [];\n\n private __href = '';\n\n private __group = '';\n\n private __unsubscribeFromRumour!: () => void;\n\n private __fetchEventHandler!: (evt: Event) => void;\n\n private __fetchEventQueue: FetchEvent[] = [];\n\n private readonly __service = interpret(\n (Nucleon.machine as NucleonMachine<TData>).withConfig({\n services: {\n sendDelete: () => this._sendDelete(),\n sendPatch: ({ edits }) => this._sendPatch(edits!),\n sendPost: ({ edits }) => this._sendPost(edits!),\n sendGet: () => this._sendGet(),\n },\n\n actions: {\n validate: assign<Nucleon.Context<TData, string>, Nucleon.Event<TData>>({\n errors: context => {\n const rules = (this.constructor as typeof NucleonElement).v8n;\n const form = { ...context.data, ...context.edits };\n\n return rules\n .map(validate => validate(form))\n .filter(v8nResult => typeof v8nResult === 'string')\n .filter((err, errIndex, errs) => errs.indexOf(err) === errIndex) as string[];\n },\n }),\n },\n })\n );\n\n /**\n * If network request returns non-2XX code, the entire error response\n * will be available via this getter.\n *\n * This property is readonly. Changing failure records via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override error status.\n *\n * @since 1.4.0\n */\n get failure(): Response | null {\n return this.__service.state.context.failure;\n }\n\n /**\n * Array of validation errors returned from `NucleonElement.v8n` checks.\n *\n * This property is readonly. Adding or removing error codes via this property is\n * not guaranteed to work. NucleonElement does not provide a way to override validity status.\n */\n get errors(): string[] {\n return this.__service.state.context.errors;\n }\n\n /**\n * Resource snapshot with edits applied. Empty object if unavailable.\n *\n * This property and its value are readonly. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please use `element.edit({ foo: 'bar' })` instead.\n * If you need to replace the entire data object, consider using `element.data`.\n */\n get form(): Partial<TData> {\n const { data, edits } = this.__service.state.context;\n return { ...data, ...edits } as Partial<TData>;\n }\n\n /**\n * Resource snapshot as-is, no edits applied. Null if unavailable.\n *\n * Returned value is not reactive. Assignments like `element.data.foo = 'bar'`\n * are not guaranteed to work. Please set the property instead: `element.data = { ...element.data, foo: 'bar' }`.\n * If you're processing user input, consider using `element.form` and `element.edit()` instead.\n */\n get data(): TData | null {\n return this.__service.state.context.data;\n }\n\n set data(data: TData | null) {\n this.__service.send({ type: 'SET_DATA', data });\n this.__href = data?._links.self.href ?? '';\n }\n\n /**\n * Rumour group. Elements in different groups will not share updates. Empty by default.\n * @example element.group = 'my-group'\n */\n get group(): string {\n return this.__group;\n }\n\n set group(value: string) {\n this.__group = value;\n this.__destroyRumour();\n this.__createRumour();\n }\n\n /**\n * Optional URL of the resource to load. Switches element to `idle.template` state if empty (default).\n * @example element.href = 'https://demo.foxycart.com/s/customer/attributes/0'\n */\n get href(): string {\n return this.__href;\n }\n\n set href(value: string) {\n this.__href = value;\n\n if (value) {\n this.__service.send({ type: 'FETCH' });\n } else {\n this.__service.send({ type: 'SET_DATA', data: null });\n }\n }\n\n /**\n * Checks if this element is in the given state.\n * @example element.in({ idle: 'snapshot' })\n */\n in<TStateValue extends Nucleon.State<TData, string>['value']>(\n stateValue: TStateValue\n ): this is this & ComputedElementProperties<TData, TStateValue> {\n return this.__service.state.matches(stateValue);\n }\n\n /**\n * Clears all edits and emits the `update` event.\n * @example element.undo()\n */\n undo(): void {\n this.__service.send({ type: 'UNDO' });\n }\n\n /**\n * Applies an edit to the local resource snapshot or its template and emits the `update` event.\n * @example element.edit({ first_name: 'Alex' })\n */\n edit(data: Partial<TData>): void {\n this.__service.send({ type: 'EDIT', data });\n }\n\n /**\n * Submits the form, updating the resource if href isn't empty or creating it otherwise.\n * Emits multiple `update` events as element state changes. Has no effect on invalid forms.\n * @example element.submit()\n */\n submit(): void {\n this.__service.send({ type: 'SUBMIT' });\n }\n\n /**\n * Sends a DELETE request to `element.href` and clears local data on success.\n * Emits multiple update events as element state changes.\n * @example element.delete()\n */\n delete(): void {\n this.__service.send({ type: 'DELETE' });\n }\n\n /**\n * Fetches data from `element.href` in background, keeping the edits and v8n errors.\n * @example element.refresh()\n */\n refresh(): void {\n this.__service.send({ type: 'REFRESH' });\n }\n\n /** @readonly */\n connectedCallback(): void {\n super.connectedCallback();\n\n this.__createService();\n this.__createRumour();\n this.__createServer();\n this.__processFetchEventQueue();\n }\n\n /** @readonly */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.__destroyService();\n this.__destroyRumour();\n this.__destroyServer();\n this.__flushFetchEventQueue('parent element was disconnected');\n }\n\n /** Sends API request. Throws an error on non-2XX response. */\n protected async _fetch(...args: Parameters<Window['fetch']>): Promise<TData> {\n const response = await new API(this).fetch(...args);\n if (!response.ok) throw response;\n return response.json();\n }\n\n /** POSTs to `element.parent`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPost(edits: Partial<TData>): Promise<TData> {\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.parent, { body, method: 'POST' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n this.__destroyRumour();\n rumour.share({ data, related, source: data._links.self.href });\n this.__createRumour();\n\n return data;\n }\n\n /** GETs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendGet(): Promise<TData> {\n const data = await this._fetch(this.href);\n const rumour = NucleonElement.Rumour(this.group);\n\n this.__destroyRumour();\n rumour.share({ data, source: this.href });\n this.__createRumour();\n\n return data;\n }\n\n /** PATCHes `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendPatch(edits: Partial<TData>): Promise<TData> {\n const body = JSON.stringify(edits);\n const data = await this._fetch(this.href, { body, method: 'PATCH' });\n const rumour = NucleonElement.Rumour(this.group);\n\n this.__destroyRumour();\n rumour.share({ data, source: this.href, related: this.related });\n this.__createRumour();\n\n return data;\n }\n\n /** DELETEs `element.href`, shares response with the Rumour group and returns parsed JSON. */\n protected async _sendDelete(): Promise<TData> {\n const data = await this._fetch(this.href, { method: 'DELETE' });\n const rumour = NucleonElement.Rumour(this.group);\n const related = [...this.related, this.parent];\n\n this.__destroyRumour();\n rumour.share({ data: null, source: this.href, related });\n this.__createRumour();\n\n return data;\n }\n\n private __createService() {\n this.__service.onTransition(state => {\n if (!state.changed) return;\n\n const flags = state.toStrings().reduce((p, c) => [...p, ...c.split('.')], [] as string[]);\n this.setAttribute('state', [...new Set(flags)].join(' '));\n\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n\n if (!state.matches('busy')) this.__processFetchEventQueue();\n });\n\n this.__service.onChange(() => {\n this.requestUpdate();\n this.dispatchEvent(new UpdateEvent());\n });\n\n this.__service.start();\n }\n\n private __destroyService() {\n this.__service.stop();\n }\n\n private __createRumour() {\n const rumour = NucleonElement.Rumour(this.group);\n this.__unsubscribeFromRumour = rumour.track(update => this.__handleRumourUpdate(update));\n }\n\n private __destroyRumour() {\n this.__unsubscribeFromRumour?.();\n }\n\n private __createServer() {\n this.__fetchEventHandler = this.__handleFetchEvent.bind(this);\n this.addEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __destroyServer() {\n this.removeEventListener('fetch', this.__fetchEventHandler);\n }\n\n private __handleRumourUpdate(update: (oldData: TData) => TData | null) {\n try {\n const oldData = this.__service.state?.context.data;\n if (!oldData) return;\n\n const newData = update(oldData);\n if (newData !== oldData) this.__service.send({ data: newData, type: 'SET_DATA' });\n } catch (err) {\n if (err instanceof Rumour.UpdateError) {\n this.__service.send({ type: 'REFRESH' });\n } else {\n throw err;\n }\n }\n }\n\n private __processFetchEventQueue() {\n const api = new NucleonElement.API(this);\n\n this.__fetchEventQueue.forEach(event => {\n const request = event.request;\n const cacheResponse = serveFromCache(request.url, this.data);\n const whenResponseReady = cacheResponse.ok ? cacheResponse : api.fetch(request);\n\n event.respondWith(Promise.resolve(whenResponseReady));\n\n if (cacheResponse.ok) {\n console.debug(\n `%c@foxy.io/elements::${this.localName}\\n%c200%c GET ${request.url}`,\n 'color: gray',\n `background: gray; padding: 0 .2em; border-radius: .2em; color: white;`,\n ''\n );\n }\n });\n\n this.__fetchEventQueue = [];\n }\n\n private __flushFetchEventQueue(errorMessage: string) {\n this.__fetchEventQueue.forEach(event => {\n event.respondWith(Promise.reject(new Error(errorMessage)));\n });\n\n this.__fetchEventQueue = [];\n }\n\n private __handleFetchEvent(event: Event) {\n if (!(event instanceof FetchEvent)) return;\n if (event.defaultPrevented) return;\n if (event.request.method !== 'GET') return;\n if (event.composedPath()[0] === this) return;\n\n event.preventDefault();\n this.__fetchEventQueue.push(event);\n\n if (!this.in('busy')) this.__processFetchEventQueue();\n }\n}\n"]}
|
|
@@ -12,6 +12,7 @@ export { CustomerForm } from './CustomerForm/CustomerForm';
|
|
|
12
12
|
export { CustomerPortal } from './CustomerPortal/CustomerPortal';
|
|
13
13
|
export { CustomerPortalSettings } from './CustomerPortalSettings/CustomerPortalSettings';
|
|
14
14
|
export { CustomersTable } from './CustomersTable/CustomersTable';
|
|
15
|
+
export { CustomFieldForm } from './CustomFieldForm/CustomFieldForm';
|
|
15
16
|
export { Donation } from './Donation/Donation';
|
|
16
17
|
export { ErrorEntryCard } from './ErrorEntryCard/ErrorEntryCard';
|
|
17
18
|
export { FormDialog } from './FormDialog/FormDialog';
|
|
@@ -12,6 +12,7 @@ export { CustomerForm } from './CustomerForm/index';
|
|
|
12
12
|
export { CustomerPortal } from './CustomerPortal/index';
|
|
13
13
|
export { CustomerPortalSettings } from './CustomerPortalSettings/index';
|
|
14
14
|
export { CustomersTable } from './CustomersTable/index';
|
|
15
|
+
export { CustomFieldForm } from './CustomFieldForm/index';
|
|
15
16
|
export { Donation } from './Donation/index';
|
|
16
17
|
export { ErrorEntryCard } from './ErrorEntryCard/index';
|
|
17
18
|
export { FormDialog } from './FormDialog/index';
|
|
@@ -12,6 +12,7 @@ export { CustomerForm } from "./CustomerForm/index.js";
|
|
|
12
12
|
export { CustomerPortal } from "./CustomerPortal/index.js";
|
|
13
13
|
export { CustomerPortalSettings } from "./CustomerPortalSettings/index.js";
|
|
14
14
|
export { CustomersTable } from "./CustomersTable/index.js";
|
|
15
|
+
export { CustomFieldForm } from "./CustomFieldForm/index.js";
|
|
15
16
|
export { Donation } from "./Donation/index.js";
|
|
16
17
|
export { ErrorEntryCard } from "./ErrorEntryCard/index.js";
|
|
17
18
|
export { FormDialog } from "./FormDialog/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.defined.js","sourceRoot":"","sources":["../../../src/elements/public/index.defined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sCAAmC;AAChE,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,EAAE,aAAa,EAAE,iCAA8B;AACtD,OAAO,EAAE,aAAa,EAAE,iCAA8B;AACtD,OAAO,EAAE,gBAAgB,EAAE,oCAAiC;AAC5D,OAAO,EAAE,cAAc,EAAE,kCAA+B;AACxD,OAAO,EAAE,eAAe,EAAE,mCAAgC;AAC1D,OAAO,EAAE,QAAQ,EAAE,4BAAyB;AAC5C,OAAO,EAAE,WAAW,EAAE,+BAA4B;AAClD,OAAO,EAAE,YAAY,EAAE,gCAA6B;AACpD,OAAO,EAAE,cAAc,EAAE,kCAA+B;AACxD,OAAO,EAAE,sBAAsB,EAAE,0CAAuC;AACxE,OAAO,EAAE,cAAc,EAAE,kCAA+B;AACxD,OAAO,EAAE,QAAQ,EAAE,4BAAyB;AAC5C,OAAO,EAAE,cAAc,EAAE,kCAA+B;AACxD,OAAO,EAAE,UAAU,EAAE,8BAA2B;AAChD,OAAO,EAAE,IAAI,EAAE,wBAAqB;AACpC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,6BAA0B;AACpD,OAAO,EAAE,cAAc,EAAE,kCAA+B;AACxD,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,UAAU,EAAE,8BAA2B;AAChD,OAAO,EAAE,OAAO,EAAE,2BAAwB;AAC1C,OAAO,EAAE,gBAAgB,EAAE,oCAAiC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,oCAAiC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,sCAAmC;AAChE,OAAO,EAAE,KAAK,EAAE,yBAAsB;AACtC,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,QAAQ,EAAE,4BAAyB;AAC5C,OAAO,EAAE,UAAU,EAAE,8BAA2B","sourcesContent":["export { AccessRecoveryForm } from './AccessRecoveryForm/index';\nexport { AddressCard } from './AddressCard/index';\nexport { AddressForm } from './AddressForm/index';\nexport { AttributeCard } from './AttributeCard/index';\nexport { AttributeForm } from './AttributeForm/index';\nexport { CancellationForm } from './CancellationForm/index';\nexport { CollectionPage } from './CollectionPage/index';\nexport { CollectionPages } from './CollectionPages/index';\nexport { Customer } from './Customer/index';\nexport { CustomerApi } from './CustomerApi/index';\nexport { CustomerForm } from './CustomerForm/index';\nexport { CustomerPortal } from './CustomerPortal/index';\nexport { CustomerPortalSettings } from './CustomerPortalSettings/index';\nexport { CustomersTable } from './CustomersTable/index';\nexport { Donation } from './Donation/index';\nexport { ErrorEntryCard } from './ErrorEntryCard/index';\nexport { FormDialog } from './FormDialog/index';\nexport { I18n } from './I18n/index';\nexport { ItemsForm, Item } from './ItemsForm/index';\nexport { NucleonElement } from './NucleonElement/index';\nexport { PaymentMethodCard } from './PaymentMethodCard/index';\nexport { SignInForm } from './SignInForm/index';\nexport { Spinner } from './Spinner/index';\nexport { SubscriptionCard } from './SubscriptionCard/index';\nexport { SubscriptionForm } from './SubscriptionForm/index';\nexport { SubscriptionsTable } from './SubscriptionsTable/index';\nexport { Table } from './Table/index';\nexport { TransactionsTable } from './TransactionsTable/index';\nexport { UserForm } from './UserForm/index';\nexport { UsersTable } from './UsersTable/index';\n"]}
|
|
1
|
+
{"version":3,"file":"index.defined.js","sourceRoot":"","sources":["../../../src/elements/public/index.defined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sCAAmC;AAChE,OAAO,EAAE,WAAW,EAA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AddressCard/index';\nexport { AddressForm } from './AddressForm/index';\nexport { AttributeCard } from './AttributeCard/index';\nexport { AttributeForm } from './AttributeForm/index';\nexport { CancellationForm } from './CancellationForm/index';\nexport { CollectionPage } from './CollectionPage/index';\nexport { CollectionPages } from './CollectionPages/index';\nexport { Customer } from './Customer/index';\nexport { CustomerApi } from './CustomerApi/index';\nexport { CustomerForm } from './CustomerForm/index';\nexport { CustomerPortal } from './CustomerPortal/index';\nexport { CustomerPortalSettings } from './CustomerPortalSettings/index';\nexport { CustomersTable } from './CustomersTable/index';\nexport { CustomFieldForm } from './CustomFieldForm/index';\nexport { Donation } from './Donation/index';\nexport { ErrorEntryCard } from './ErrorEntryCard/index';\nexport { FormDialog } from './FormDialog/index';\nexport { I18n } from './I18n/index';\nexport { ItemsForm, Item } from './ItemsForm/index';\nexport { NucleonElement } from './NucleonElement/index';\nexport { PaymentMethodCard } from './PaymentMethodCard/index';\nexport { SignInForm } from './SignInForm/index';\nexport { Spinner } from './Spinner/index';\nexport { SubscriptionCard } from './SubscriptionCard/index';\nexport { SubscriptionForm } from './SubscriptionForm/index';\nexport { SubscriptionsTable } from './SubscriptionsTable/index';\nexport { Table } from './Table/index';\nexport { TransactionsTable } from './TransactionsTable/index';\nexport { UserForm } from './UserForm/index';\nexport { UsersTable } from './UsersTable/index';\n"]}
|
|
@@ -12,6 +12,7 @@ export { CustomerForm } from "./CustomerForm/CustomerForm.js";
|
|
|
12
12
|
export { CustomerPortal } from "./CustomerPortal/CustomerPortal.js";
|
|
13
13
|
export { CustomerPortalSettings } from "./CustomerPortalSettings/CustomerPortalSettings.js";
|
|
14
14
|
export { CustomersTable } from "./CustomersTable/CustomersTable.js";
|
|
15
|
+
export { CustomFieldForm } from "./CustomFieldForm/CustomFieldForm.js";
|
|
15
16
|
export { Donation } from "./Donation/Donation.js";
|
|
16
17
|
export { ErrorEntryCard } from "./ErrorEntryCard/ErrorEntryCard.js";
|
|
17
18
|
export { FormDialog } from "./FormDialog/FormDialog.js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AAO,EAAE,QAAQ,EAAE,+BAA4B;AAC/C,OAAO,EAAE,UAAU,EAAE,mCAAgC","sourcesContent":["export { AccessRecoveryForm } from './AccessRecoveryForm/AccessRecoveryForm';\nexport { AddressCard } from './AddressCard/AddressCard';\nexport { AddressForm } from './AddressForm/AddressForm';\nexport { AttributeCard } from './AttributeCard/AttributeCard';\nexport { AttributeForm } from './AttributeForm/AttributeForm';\nexport { CancellationForm } from './CancellationForm/CancellationForm';\nexport { CollectionPage } from './CollectionPage/CollectionPage';\nexport { CollectionPages } from './CollectionPages/CollectionPages';\nexport { Customer } from './Customer/Customer';\nexport { CustomerApi } from './CustomerApi/CustomerApi';\nexport { CustomerForm } from './CustomerForm/CustomerForm';\nexport { CustomerPortal } from './CustomerPortal/CustomerPortal';\nexport { CustomerPortalSettings } from './CustomerPortalSettings/CustomerPortalSettings';\nexport { CustomersTable } from './CustomersTable/CustomersTable';\nexport { Donation } from './Donation/Donation';\nexport { ErrorEntryCard } from './ErrorEntryCard/ErrorEntryCard';\nexport { FormDialog } from './FormDialog/FormDialog';\nexport { I18n } from './I18n/I18n';\nexport { ItemsForm, Item } from './ItemsForm/ItemsForm';\nexport { NucleonElement } from './NucleonElement/NucleonElement';\nexport { PaymentMethodCard } from './PaymentMethodCard/PaymentMethodCard';\nexport { SignInForm } from './SignInForm/SignInForm';\nexport { Spinner } from './Spinner/Spinner';\nexport { SubscriptionCard } from './SubscriptionCard/SubscriptionCard';\nexport { SubscriptionForm } from './SubscriptionForm/SubscriptionForm';\nexport { SubscriptionsTable } from './SubscriptionsTable/SubscriptionsTable';\nexport { Table } from './Table/Table';\nexport { TransactionsTable } from './TransactionsTable/TransactionsTable';\nexport { UserForm } from './UserForm/UserForm';\nexport { UsersTable } from './UsersTable/UsersTable';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/elements/public/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mDAAgD;AAC7E,OAA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ccessRecoveryForm';\nexport { AddressCard } from './AddressCard/AddressCard';\nexport { AddressForm } from './AddressForm/AddressForm';\nexport { AttributeCard } from './AttributeCard/AttributeCard';\nexport { AttributeForm } from './AttributeForm/AttributeForm';\nexport { CancellationForm } from './CancellationForm/CancellationForm';\nexport { CollectionPage } from './CollectionPage/CollectionPage';\nexport { CollectionPages } from './CollectionPages/CollectionPages';\nexport { Customer } from './Customer/Customer';\nexport { CustomerApi } from './CustomerApi/CustomerApi';\nexport { CustomerForm } from './CustomerForm/CustomerForm';\nexport { CustomerPortal } from './CustomerPortal/CustomerPortal';\nexport { CustomerPortalSettings } from './CustomerPortalSettings/CustomerPortalSettings';\nexport { CustomersTable } from './CustomersTable/CustomersTable';\nexport { CustomFieldForm } from './CustomFieldForm/CustomFieldForm';\nexport { Donation } from './Donation/Donation';\nexport { ErrorEntryCard } from './ErrorEntryCard/ErrorEntryCard';\nexport { FormDialog } from './FormDialog/FormDialog';\nexport { I18n } from './I18n/I18n';\nexport { ItemsForm, Item } from './ItemsForm/ItemsForm';\nexport { NucleonElement } from './NucleonElement/NucleonElement';\nexport { PaymentMethodCard } from './PaymentMethodCard/PaymentMethodCard';\nexport { SignInForm } from './SignInForm/SignInForm';\nexport { Spinner } from './Spinner/Spinner';\nexport { SubscriptionCard } from './SubscriptionCard/SubscriptionCard';\nexport { SubscriptionForm } from './SubscriptionForm/SubscriptionForm';\nexport { SubscriptionsTable } from './SubscriptionsTable/SubscriptionsTable';\nexport { Table } from './Table/Table';\nexport { TransactionsTable } from './TransactionsTable/TransactionsTable';\nexport { UserForm } from './UserForm/UserForm';\nexport { UsersTable } from './UsersTable/UsersTable';\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxy.io/elements",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.11.0-beta.
|
|
4
|
+
"version": "1.11.0-beta.4",
|
|
5
5
|
"description": "E-commerce web components by Foxy.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prepack": "npm run lint && rimraf dist && node ./.build/compile-for-npm.js && rollup -c"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@foxy.io/sdk": "^1.
|
|
30
|
+
"@foxy.io/sdk": "^1.6.0",
|
|
31
31
|
"@open-wc/lit-helpers": "^0.3.11",
|
|
32
32
|
"@open-wc/scoped-elements": "1.2.1",
|
|
33
33
|
"@polymer/iron-icons": "^3.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e,L as t,m as s,b as r,_ as i,R as n,F as o,e as h}from"./shared-84203d52.js";import{A as a}from"./shared-497fd63c.js";import{U as _}from"./shared-7684cb05.js";import{i as d}from"./shared-9f78e096.js";function c(t,s){let r=null;return e(s).forEach((function(){var e,s,i,n,o;if((null===(i=null===(s=null===(e=this.node)||void 0===e?void 0:e._links)||void 0===s?void 0:s.self)||void 0===i?void 0:i.href)===t)return r=JSON.stringify(this.node),void this.stop();Object.entries(null!==(o=null===(n=this.node)||void 0===n?void 0:n._links)&&void 0!==o?o:{}).some((([e,s])=>{var i,n;if(s.href!==t)return!1;const o=null===(n=null===(i=this.node)||void 0===i?void 0:i._embedded)||void 0===n?void 0:n[e];if(!o||!Array.isArray(o))return!1;const h=o.length<20?o.length:21,a=new URL(t),_=new URL(t);return a.searchParams.set("offset",o.length.toString()),_.searchParams.set("offset",h.toString()),r=JSON.stringify({returned_items:o.length,total_items:h,offset:0,limit:20,_embedded:{[e]:o},_links:{curies:this.node._links.curies,first:{href:t},last:{href:_.toString()},prev:{href:t},next:{href:a.toString()},self:{href:t}}}),this.stop(),!0}))})),new Response(r,{status:r?200:404})}class u extends t{constructor(){super(...arguments),this.lang="",this.parent="",this.related=[],this.__href="",this.__group="",this.__service=d(s.withConfig({services:{sendDelete:()=>this._sendDelete(),sendPatch:({edits:e})=>this._sendPatch(e),sendPost:({edits:e})=>this._sendPost(e),sendGet:()=>this._sendGet()},actions:{validate:r({errors:e=>{const t=this.constructor.v8n,s=i(i({},e.data),e.edits);return t.map((e=>e(s))).filter((e=>"string"==typeof e)).filter(((e,t,s)=>s.indexOf(e)===t))}})}}))}static get properties(){return{related:{type:Array},parent:{type:String},group:{type:String,noAccessor:!0},href:{type:String,noAccessor:!0},lang:{type:String}}}static get v8n(){return[]}get failure(){return this.__service.state.context.failure}get errors(){return this.__service.state.context.errors}get form(){const{data:e,edits:t}=this.__service.state.context;return i(i({},e),t)}get data(){return this.__service.state.context.data}set data(e){var t;this.__service.send({type:"SET_DATA",data:e}),this.__href=null!==(t=null==e?void 0:e._links.self.href)&&void 0!==t?t:""}get group(){return this.__group}set group(e){this.__group=e,this.__destroyRumour(),this.__createRumour()}get href(){return this.__href}set href(e){this.__href=e,e?this.__service.send({type:"FETCH"}):this.__service.send({type:"SET_DATA",data:null})}in(e){return this.__service.state.matches(e)}undo(){this.__service.send({type:"UNDO"})}edit(e){this.__service.send({type:"EDIT",data:e})}submit(){this.__service.send({type:"SUBMIT"})}delete(){this.__service.send({type:"DELETE"})}connectedCallback(){super.connectedCallback(),this.__createService(),this.__createRumour(),this.__createServer()}disconnectedCallback(){super.disconnectedCallback(),this.__destroyService(),this.__destroyRumour(),this.__destroyServer()}async _fetch(...e){const t=await new a(this).fetch(...e);if(!t.ok)throw t;return t.json()}async _sendPost(e){const t=JSON.stringify(e),s=await this._fetch(this.parent,{body:t,method:"POST"}),r=u.Rumour(this.group),i=[...this.related,this.parent];return this.__destroyRumour(),r.share({data:s,related:i,source:s._links.self.href}),this.__createRumour(),s}async _sendGet(){const e=await this._fetch(this.href),t=u.Rumour(this.group);return this.__destroyRumour(),t.share({data:e,source:this.href}),this.__createRumour(),e}async _sendPatch(e){const t=JSON.stringify(e),s=await this._fetch(this.href,{body:t,method:"PATCH"}),r=u.Rumour(this.group);return this.__destroyRumour(),r.share({data:s,source:this.href}),this.__createRumour(),s}async _sendDelete(){const e=await this._fetch(this.href,{method:"DELETE"}),t=u.Rumour(this.group),s=[...this.related,this.parent];return this.__destroyRumour(),t.share({data:null,source:this.href,related:s}),this.__createRumour(),e}__createService(){this.__service.onTransition((e=>{if(!e.changed)return;const t=e.toStrings().reduce(((e,t)=>[...e,...t.split(".")]),[]);this.setAttribute("state",[...new Set(t)].join(" ")),this.requestUpdate(),this.dispatchEvent(new _)})),this.__service.onChange((()=>{this.requestUpdate(),this.dispatchEvent(new _)})),this.__service.start()}__destroyService(){this.__service.stop()}__createRumour(){const e=u.Rumour(this.group);this.__unsubscribeFromRumour=e.track((e=>this.__handleRumourUpdate(e)))}__destroyRumour(){var e;null===(e=this.__unsubscribeFromRumour)||void 0===e||e.call(this)}__createServer(){this.__fetchEventHandler=this.__handleFetchEvent.bind(this),this.addEventListener("fetch",this.__fetchEventHandler)}__destroyServer(){this.removeEventListener("fetch",this.__fetchEventHandler)}__handleRumourUpdate(e){var t;try{const s=null===(t=this.__service.state)||void 0===t?void 0:t.context.data;if(!s)return;const r=e(s);r!==s&&this.__service.send({data:r,type:"SET_DATA"})}catch(e){if(!(e instanceof n.UpdateError))throw e;this.__service.send({type:"FETCH"})}}__handleFetchEvent(e){if(!(e instanceof o))return;if("GET"!==e.request.method)return;const t=c(e.request.url,this.data);t.ok&&(e.respondWith(Promise.resolve(t)),console.debug(`%c@foxy.io/elements::${this.localName}\n%c200%c GET ${e.request.url}`,"color: gray","background: gray; padding: 0 .2em; border-radius: .2em; color: white;",""))}}u.UpdateEvent=_,u.Rumour=h((()=>new n)),u.API=a;export{u as N,c as s};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import"./foxy-spinner.js";import{d as e,as as t,at as s,au as n,av as o,_ as r,h as i,F as l}from"./shared-84203d52.js";import{C as a}from"./shared-23966eed.js";import{N as d}from"./shared-306080cb.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
5
|
-
* This code may only be used under the BSD style license found at
|
|
6
|
-
* http://polymer.github.io/LICENSE.txt
|
|
7
|
-
* The complete set of authors may be found at
|
|
8
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
9
|
-
* The complete set of contributors may be found at
|
|
10
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
11
|
-
* Code distributed by Google as part of the polymer project is also
|
|
12
|
-
* subject to an additional IP rights grant found at
|
|
13
|
-
* http://polymer.github.io/PATENTS.txt
|
|
14
|
-
*/
|
|
15
|
-
const h=(e,n)=>{const o=e.startNode.parentNode,r=void 0===n?e.endNode:n.startNode,i=o.insertBefore(s(),r);o.insertBefore(s(),r);const l=new t(e.options);return l.insertAfterNode(i),l},c=(e,t)=>(e.setValue(t),e.commit(),e),f=(e,t,s)=>{const o=e.startNode.parentNode,r=s?s.startNode:e.endNode,i=t.endNode.nextSibling;i!==r&&n(o,t.startNode,i,r)},p=e=>{o(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},u=(e,t,s)=>{const n=new Map;for(let o=t;o<=s;o++)n.set(e[o],o);return n},m=new WeakMap,g=new WeakMap,_=e(((e,s,n)=>{let o;return void 0===n?n=s:void 0!==s&&(o=s),s=>{if(!(s instanceof t))throw new Error("repeat can only be used in text bindings");const r=m.get(s)||[],i=g.get(s)||[],l=[],a=[],d=[];let _,y,x=0;for(const t of e)d[x]=o?o(t,x):x,a[x]=n(t,x),x++;let v=0,b=r.length-1,N=0,$=a.length-1;for(;v<=b&&N<=$;)if(null===r[v])v++;else if(null===r[b])b--;else if(i[v]===d[N])l[N]=c(r[v],a[N]),v++,N++;else if(i[b]===d[$])l[$]=c(r[b],a[$]),b--,$--;else if(i[v]===d[$])l[$]=c(r[v],a[$]),f(s,r[v],l[$+1]),v++,$--;else if(i[b]===d[N])l[N]=c(r[b],a[N]),f(s,r[b],r[v]),b--,N++;else if(void 0===_&&(_=u(d,N,$),y=u(i,v,b)),_.has(i[v]))if(_.has(i[b])){const e=y.get(d[N]),t=void 0!==e?r[e]:null;if(null===t){const e=h(s,r[v]);c(e,a[N]),l[N]=e}else l[N]=c(t,a[N]),f(s,t,r[v]),r[e]=null;N++}else p(r[b]),b--;else p(r[v]),v++;for(;N<=$;){const e=h(s,l[$+1]);c(e,a[N]),l[N++]=e}for(;v<=b;){const e=r[v++];null!==e&&p(e)}m.set(s,l),g.set(s,d)}}));let y,x=e=>e;class v extends(a(d)){constructor(){super(),this.ns="",this.__pageFetchEventHandler=e=>this.__handlePageFetchEvent(e),this.item="foxy-null"}static get properties(){return r(r({},super.properties),{},{item:{type:String},ns:{type:String}})}get item(){return this.__item}set item(e){this.__renderItem="string"==typeof e?new Function("ctx",`return ctx.html\`\n <${e}\n disabledcontrols=\${ctx.disabledControls.toString()}\n readonlycontrols=\${ctx.readonlyControls.toString()}\n hiddencontrols=\${ctx.hiddenControls.toString()}\n data-testclass="items"\n parent=\${ctx.parent}\n group=\${ctx.group}\n href=\${ctx.href}\n lang=\${ctx.lang}\n ns="\${ctx.ns} \${customElements.get('${e}')?.defaultNS ?? ''}"\n ?disabled=\${ctx.disabled}\n ?readonly=\${ctx.readonly}\n ?hidden=\${ctx.hidden}\n .templates=\${ctx.templates}\n >\n </${e}>\``):e,this.__item=e,this.requestUpdate()}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.addEventListener("fetch",this.__pageFetchEventHandler)}render(){const e=this.__items.map((e=>({key:e._links.self.href,href:e._links.self.href,data:e})));return this.in("busy")?e.push({key:"stalled",href:"foxy://collection-page/stall",data:null}):this.in("fail")?e.push({key:"failed",href:"foxy://collection-page/fail",data:null}):(this.in({idle:"template"})||0===this.__items.length)&&e.push({key:"empty",href:"",data:null}),i(y||(y=x`${0}`),_(e,(e=>e.key),(e=>{var t;return null===(t=this.__renderItem)||void 0===t?void 0:t.call(this,{disabledControls:this.disabledControls,readonlyControls:this.readonlyControls,hiddenControls:this.hiddenControls,templates:this.templates,disabled:this.disabled,readonly:this.readonly,hidden:this.hidden,parent:this.href,group:this.group,lang:this.lang,data:e.data,href:e.href,ns:this.ns,html:i})})))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("fetch",this.__pageFetchEventHandler)}get __items(){var e,t;return Array.from(Object.values(null!==(t=null===(e=this.form)||void 0===e?void 0:e._embedded)&&void 0!==t?t:{})).reduce(((e,t)=>[...e,...t]),[])}__handlePageFetchEvent(e){if(!(e instanceof l)||e.target===this)return;const{method:t,url:s}=e.request;return"GET"===t?"foxy://collection-page/stall"===s?this.__stallRequest(e):"foxy://collection-page/fail"===s?this.__failRequest(e):void 0:void 0}__stallRequest(e){e.stopImmediatePropagation(),e.respondWith(new Promise((()=>{})))}__failRequest(e){e.stopImmediatePropagation(),e.respondWith(Promise.resolve(new Response(null,{status:500})))}}customElements.define("foxy-collection-page",v);export{v as C,_ as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{L as t,_ as e,c as i,h as s}from"./shared-84203d52.js";import"./shared-b98f88c9.js";import{p as r}from"./shared-87ca7818.js";import"./shared-45d647e4.js";import"./shared-e0248713.js";import{b as a,S as n,c as o}from"./shared-8057ee9c.js";import{s as c,I as l,D as h}from"./shared-bba615b8.js";import"./shared-851b97ef.js";import{E as d}from"./shared-e058cb87.js";import"./shared-54c485d2.js";import"./shared-3ae39e52.js";import"./foxy-i18n.js";import"./shared-cd700eac.js";class u extends CustomEvent{constructor(t){super("change",{detail:t})}}class m extends CustomEvent{constructor(t){super("submit",{detail:t,cancelable:!0})}}let _,p,g=t=>t;var y;!function(t){t[t.Excluded=0]="Excluded",t[t.BeforeEnter=1]="BeforeEnter",t[t.Default=2]="Default",t[t.Previous=3]="Previous",t[t.BeforeExit=4]="BeforeExit"}(y||(y={}));class f extends t{constructor(){super(...arguments),this.quantity=0,this.image=""}static get properties(){return e(e({},super.properties),{},{quantity:{attribute:!1},image:{attribute:!1}})}static get styles(){return[a.styles,i(_||(_=g`.ease-out-back{transition-timing-function:cubic-bezier(.34,1.56,.64,1)}.blur-1{filter:blur(1px)}.blur-2{filter:blur(2px)}.grayscale{filter:grayscale()}.rotate-12{--tw-rotate:12deg}.-rotate-12{--tw-rotate:-12deg}.-rotate-24{--tw-rotate:-24deg}.translate-y-half{--tw-translate-y:50%}`))]}set empty(t){this.updateComplete.then((()=>{if(t){const[,...t]=this.__stack;t.forEach((t=>t.remove()))}else this.quantity>1&&this.__stack.length<2&&this.__insertImage(y.Previous,this.__stack[0])}))}set data({quantity:t,image:e}){this.quantity=t,this.image=e}render(){return s(p||(p=g`<div id="image" class="w-full h-full relative"></div>`))}firstUpdated(){const t=this.__insertImage(y.Default);this.quantity>1&&this.__insertImage(y.Previous,t)}updated(t){if(t.has("quantity")){const e=t.get("quantity");void 0!==e&&(this.quantity>e?this.__add():this.__remove())}t.has("image")&&this.__stack.forEach((t=>t.src=this.image))}get __container(){return this.shadowRoot.getElementById("image")}get __stack(){var t,e;return[...null!==(e=null===(t=this.__container)||void 0===t?void 0:t.querySelectorAll(":not(.opacity-0)"))&&void 0!==e?e:[]].reverse()}__add(){const[t,e]=this.__stack;this.quantity>1?(t&&this.__setImageState(t,y.Previous),e&&(this.__setImageState(e,y.BeforeExit),e.ontransitionend=()=>e.remove()),this.__setImageState(this.__insertImage(y.BeforeEnter),y.Default)):t&&this.__setImageState(t,y.Default)}__remove(){const[t,e]=this.__stack;let i;if(this.quantity>0?(e&&this.__setImageState(e,y.Default),i=t):(t&&this.__setImageState(t,y.Excluded),i=e),i&&(this.__setImageState(i,y.BeforeEnter),i.ontransitionend=()=>i.remove()),this.quantity>1){const t=this.__insertImage(y.BeforeExit,this.__container.firstElementChild);this.__setImageState(t,y.Previous)}}__insertImage(t,e=null){const i=new Image;return i.src=this.image,i.setAttribute("part","picture"),this.__setImageState(i,t),this.__container.insertBefore(i,e),i}__setImageState(t,e){t.offsetHeight,t.className=["absolute inset-0 w-full h-full object-cover rounded transform transition duration-700 ease-out-back",["grayscale","shadow-m translate-y-half scale-110 rotate-12 opacity-0","shadow-m","blur-1 -rotate-12 opacity-25","blur-2 -rotate-24 opacity-0"][e]].join(" ")}}let v,b,w,x,q,I,$,E,S=t=>t;class D extends(n(t)){constructor(){super(...arguments),this.empty=!1,this.data=[]}static get properties(){return e(e({},super.properties),{},{empty:{attribute:!1},data:{attribute:!1}})}static get styles(){return[a.styles,i(v||(v=S`.w-preview{width:5.5rem}.h-preview{height:5.5rem}.ease-out-back{transition-timing-function:cubic-bezier(.34,1.56,.64,1)}.grayscale{filter:grayscale()}.grid-2>:nth-child(1),.grid-3>:nth-child(1),.grid-4-plus>:nth-child(1),.grid-4>:nth-child(1){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-1>:nth-child(2){opacity:0;--tw-translate-x:100%;--tw-translate-y:var(--tw-translate-x)}.grid-2>:nth-child(2),.grid-3>:nth-child(2),.grid-4-plus>:nth-child(2),.grid-4>:nth-child(2){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-3>:nth-child(2),.grid-4-plus>:nth-child(2),.grid-4>:nth-child(2){transform-origin:top right}.grid-1>:nth-child(3),.grid-2>:nth-child(3),.grid-3>:nth-child(3),.grid-4-plus>:nth-child(3),.grid-4>:nth-child(3){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-1>:nth-child(3),.grid-2>:nth-child(3){opacity:0;--tw-translate-y:100%}.grid-3>:nth-child(3){transform-origin:bottom right}.grid-4-plus>:nth-child(3),.grid-4>:nth-child(3){transform-origin:bottom left}.grid-1>:nth-child(4),.grid-2>:nth-child(4),.grid-3>:nth-child(4),.grid-4-plus>:nth-child(4),.grid-4>:nth-child(4){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-1>:nth-child(4),.grid-2>:nth-child(4),.grid-3>:nth-child(4){opacity:0;transform-origin:bottom left;--tw-translate-x:100%}.grid-1>:nth-child(4)>:first-child,.grid-2>:nth-child(4)>:first-child,.grid-3>:nth-child(4)>:first-child,.grid-4>:nth-child(4)>:first-child{transform:perspective(250px) rotateX(-90deg)}.grid-4-plus>:nth-child(4)>:first-child,.grid-4>:nth-child(4)>:last-child{transition-delay:.15s;transition-timing-function:ease-out}.grid-4-plus>:nth-child(4)>:last-child,.grid-4>:nth-child(4)>:first-child{transition-timing-function:ease-in}.grid-4-plus>:nth-child(4)>:last-child{transform:perspective(250px) rotateX(90deg)}.grid-1>:nth-child(5),.grid-3>:nth-child(5),.grid-4-plus>:nth-child(5),.grid-4>:nth-child(5){opacity:0}.grid-1>:nth-child(5){--tw-translate-x:100%}.grid-2>:nth-child(5),.grid-3>:nth-child(5),.grid-4-plus>:nth-child(5),.grid-4>:nth-child(5){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-3>:nth-child(5),.grid-4-plus>:nth-child(5),.grid-4>:nth-child(5){--tw-translate-y:-100%}.grid-1>:nth-child(6),.grid-4-plus>:nth-child(6),.grid-4>:nth-child(6){opacity:0}.grid-1>:nth-child(6){--tw-translate-y:100%}.grid-2>:nth-child(6),.grid-3>:nth-child(6),.grid-4-plus>:nth-child(6),.grid-4>:nth-child(6){--tw-scale-x:calc(2.5 / 5.5);--tw-scale-y:var(--tw-scale-x)}.grid-4-plus>:nth-child(6),.grid-4>:nth-child(6){--tw-translate-x:-100%}`))]}render(){const t=this.data.length,e="rounded bg-contrast-10",i="transition-all duration-700 ease-out-back transform absolute inset-0",r=this.empty?"grayscale":"",a=t>4?"grid-4-plus":`grid-${Math.max(1,t)}`,n=c({exportparts:"picture",class:"w-full h-full",".empty":this.empty}),[o,l,h,d]=this.data;return s(b||(b=S` <div class="${0} w-preview h-preview relative font-lumo"> <div class="${0} ${0} origin-top-left"> ${0} </div> <div class="${0} ${0} origin-bottom-right"> ${0} </div> <div class="${0} ${0} origin-top-right"> ${0} </div> <div class="${0} ${0} origin-bottom-right"> <div class="${0} flex text-body transition duration-150 absolute inset-0"> ${0} </div> <div class="transition duration-150 absolute inset-0"> ${0} </div> </div> <div class="${0} ${0} origin-top-right"></div> <div class="${0} ${0} origin-bottom-left"></div> </div> `),a,i,r,o?s(w||(w=S`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,o):"",i,r,l?s(x||(x=S`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,l):"",i,r,h?s(q||(q=S`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,h):"",i,r,e,t>102?s(I||(I=S`<iron-icon icon="icons:more-horiz" class="m-auto w-xl h-xl"></iron-icon>`)):s($||($=S`<div class="m-auto text-xxxl">+${0}</div>`),t-3),d?s(E||(E=S`<x-pic ...="${0}" .data="${0}"></x-pic>`),n,d):"",i,e,i,e)}}let k,C,A=t=>t;class N extends D{static get scopedElements(){return{"x-pic":f}}}class P extends D{static get scopedElements(){return{"x-pic":N}}}class F extends(n(t)){constructor(){super(...arguments),this.quantity=0,this.items=[]}static get scopedElements(){return{"x-picture":f,"x-bundle-grid":P}}static get properties(){return{quantity:{attribute:!1},image:{attribute:!1},items:{attribute:!1}}}static get styles(){return a.styles}render(){const{quantity:t,image:e=""}=this,i=0===t,r=c({class:"w-full h-full",exportparts:"picture"});if(0===this.items.length)return s(k||(k=A`<x-picture ...="${0}" .data="${0}"></x-picture>`),r,{quantity:t,image:e});{const e=new Array(Math.max(1,t)).fill(this.items);return s(C||(C=A`<x-bundle-grid ...="${0}" .empty="${0}" .data="${0}"></x-bundle-grid>`),r,i,e)}}}class T extends o{static get properties(){return e(e({},super.properties),{},{open:{type:Object},signatures:{type:Object,converter:t=>{const e=JSON.parse(t);for(const t of Object.keys(e))64!=e[t].length&&console.error("There is something wrong with the signature. It should have 64 characters.");return e}}})}signedName(t){return this.signatures&&this.signatures[t]?`${t}||${this.signatures[t]}${this.isOpen(t)?"||open":""}`:t}isOpen(t){return!(!this.open||!this.open[t])}}let j,O,B,L,R,z,V,M=t=>t;class Q extends T{constructor(){super("items-form"),this.rel="product_item",this.readonly=!1,this.quantity=0,this.total=this.__computeTotalPrice(),this.currency="",this.isItem=!0,this.isChildItem=!1,this.pid=Q.__newId(),this.__modified=!1,this.__childPrices=[],this.__images=[],this.__childrenCount=0,this.__itemDescription="",this.__handleQuantity={handleEvent:t=>{const e=Number(t.target.value);this.quantity=e,this.__modified=!0,this.__images=[this.getImageDescription()].concat(this.__images.slice(1,this.__images.length))}},this.__childItemsObserver=new MutationObserver(this.__observeItems.bind(this)),this.__childItemsObserver.observe(this,{childList:!0,attributes:!1,subtree:!0}),this.updateComplete.then((()=>{this.__setCode(),this.__acknowledgeChildItems(),this.__changedChildItem(),this.__isValid()||console.error("Invalid item",this.value)}))}static get styles(){return[super.styles,i(j||(j=M`:host{--quantity-width:6.5rem;--preview-size:5.5rem;--threshold:20rem}.min-w-description::before{content:'';width:var(--threshold);display:block;overflow:hidden}.ml-description{--min-width:calc(var(--threshold) + var(--preview-size) + var(--lumo-space-l));--free-space:calc(100% - var(--min-width));--max-margin-left:calc(var(--preview-size) + var(--lumo-space-l));--final-margin-left:clamp(0rem, var(--free-space) * 999999999, var(--max-margin-left));margin-left:var(--final-margin-left)}.mr-quantity{--min-width:var(--threshold);--free-space:calc(100% - var(--min-width));--max-margin-right:calc(var(--quantity-width) + var(--lumo-space-l));--final-margin-right:clamp(0rem, var(--free-space) * 999999999, var(--max-margin-right));margin-right:var(--final-margin-right)}:host([data-bundled]:not(:last-of-type)) .separator::after{content:' ';display:block;position:absolute;width:100vw;border-bottom:solid thin var(--lumo-shade-10pct);left:0;bottom:0}.w-quantity{width:var(--quantity-width)}.w-preview{width:var(--preview-size)}.h-preview{height:var(--preview-size)}`))]}static get scopedElements(){return{"vaadin-integer-field":customElements.get("vaadin-integer-field"),"x-error-screen":d,"x-preview":F,"x-i18n":l}}static get properties(){return e(e({},super.properties),{},{__modified:{},readonly:{type:Boolean,reflect:!0},currency:{type:String},category:{type:String},code:{type:String,reflect:!0},expires:{type:String},height:{type:Number},image:{type:String},length:{type:Number},name:{type:String},parent_code:{type:String},price:{type:Number},quantity:{type:Number,reflect:!0},quantity_max:{type:Number},quantity_min:{type:String},shipto:{type:String},total:{type:Number,reflect:!0,attribute:"total"},url:{type:String},value:{type:Object},weight:{type:Number},width:{type:Number},__childPrices:{},__childrenCount:{},__images:{},alt:{type:String},isChildItem:{type:Boolean,reflect:!0,attribute:"data-bundled"},isItem:{type:Boolean,reflect:!0,attribute:"data-item"},open:{type:Object},pid:{type:Number,reflect:!0},items:{type:Array}})}get items(){const t=[];return this.__onEachChildItem([e=>t.push(e.value)]),t}set items(t){this.__createItems(t)}get value(){const t={};for(let e=0;e<this.attributes.length;e++)t[this.attributes[e].name]=this.attributes[e].value;return t.items=this.items,t}set value(t){this.__itemDescription="";for(const e in t){let i="";if("description"!=e){if("object"==typeof t[e])i=JSON.stringify(t[e]);else{const s=e;(t[s]&&"undefined"!==t[s]||0===t[s])&&(i=t[e].toString())}this.setAttribute(e,t[e]?i:"")}else this.__itemDescription=t[e]}}updated(t){t.forEach(((t,e)=>{"__itemDescription"!=e&&"isChildItem"!=e||this.__updateDescriptionEl()})),this.__setTotalPrice(),this.dispatchEvent(new Event("change"))}render(){var t;if(!this.__isValid())return s(O||(O=M`<x-error-screen type="setup_needed" class="relative"></x-error-screen>`));const e=`font-lumo text-body text-s leading-m transition duration-100 ${this.quantity?"":"removed opacity-50"}`;if(this.isChildItem)return s(B||(B=M` <article part="item" class="py-s w-full relative separator item-summary flex justify-between ${0}"> <div class="description flex-1"> <h1 class="text-header font-medium">${0}</h1> <section class="description text-secondary"> <slot></slot> </section> </div> ${0} </article> `),e,this.name,this.quantity<2?"":s(L||(L=M` <section class="quantity font-medium text-tertiary whitespace-nowrap"> ${0} </section> `),this._t("item.items",{quantity:this.quantity})));{const i=(null!==(t=this.price)&&void 0!==t?t:0)+this.__childPrices.reduce(((t,e)=>t+e),0),r=this.__translateAmount(i*this.quantity),a=this.__translateAmount(i);return s(R||(R=M` <article part="item" class="p-l relative item ${0} ${0}"> <x-preview class="preview float-left w-preview h-preview mr-l mb-l" exportparts="picture" .image="${0}" .quantity="${0}" .items="${0}"> </x-preview> <section class="description min-w-description ml-description"> <h1 class="text-header font-medium text-l leading-none mr-quantity mb-s"> ${0} </h1> <div class="item-description text-secondary mr-quantity mb-s"> <slot></slot> </div> <div class="child-items mb-s"> <slot name="items"></slot> </div> ${0} </section> <section class="quantity w-quantity absolute top-0 right-0 m-l"> <vaadin-integer-field class="w-full p-0" name="quantity" @change="${0}" value="${0}" min="0" has-controls ?readonly="${0}"> </vaadin-integer-field> ${0} </section> </article> `),e,this.__modified?"modified":"",this.image,this.quantity,[...this.querySelectorAll("[data-bundled]")].map((t=>{var e;return{quantity:t.quantity,image:null!==(e=t.image)&&void 0!==e?e:""}})),this.name,a?s(z||(z=M`<div class="font-medium price text-l">${0}</div>`),a):"",this.__handleQuantity,this.quantity,this.readonly,this.quantity>1?s(V||(V=M` <x-i18n .ns="${0}" .lang="${0}" .opts="${0}" class="price-total text-secondary text-xs text-center block mt-xs" key="price.total"> </x-i18n> `),this.ns,this.lang,{amount:r}):"")}}getImageDescription(){return{src:this.image,alt:this.alt,quantity:this.quantity}}signedName(t){const e=super.signedName(t);return`${this.pid.toString()}:${e}`}static __newId(){const t=Q.__existingIds.reduce(((t,e)=>e>t?e:t),0)+1;return Q.__existingIds.push(t),t}__updateDescriptionEl(){if(this.__itemDescription){let t=this.shadowRoot.querySelector("data-item-description");t||(t=document.createElement("p"),t.dataset.itemDescription="true",this.__addSlottedEl(t)),t.innerText=this.__itemDescription}else{const t=this.shadowRoot.querySelector("data-item-description");t&&t.remove()}}__addSlottedEl(t){const e=this.shadowRoot.querySelector("article");e&&e.appendChild(t)}__setCode(){this.code||(this.code=`RAND${Math.random()}`)}__createItems(t){t.forEach((t=>{const e=document.createElement(this.tagName);e.value=t,e.currency=this.currency,e.__computeTotalPrice(),this.__acknowledgeItem(e),this.appendChild(e)}))}__setTotalPrice(){this.total=this.__computeTotalPrice()}__computeTotalPrice(){if(!this.__childPrices)return this.price?this.price*this.quantity:0;let t=0;return this.__childPrices.forEach((e=>{t+=e})),t+=this.price,t*=this.quantity,t}__isValid(){const t=[];return this.name&&this.name.length||t.push("The name attribute of an item is required."),this.price||0===this.price||t.push("The price attribute of an item is required."),this.price&&this.price<0&&t.push("Item added with negative price."),this.quantity_min&&this.quantity&&this.quantity<this.quantity_min&&t.push("Quantity amount is less than minimum quantity."),this.quantity_max&&this.quantity&&this.quantity>this.quantity_max&&t.push("Quantity amount is more than maximum quantity."),console.error(...t),!t.length}__translateAmount(t){return this.currency?t.toLocaleString(this.lang,{minimumFractionDigits:2,currency:this.currency,style:"currency"}):""}__observeItems(t){t.forEach((t=>{"childList"==t.type&&t.addedNodes.forEach((t=>{t.nodeType===Node.DOCUMENT_NODE&&this.__acknowledgeItem(t)}))})),this.__setTotalPrice()}__acknowledgeChildItems(){var t;null===(t=this.shadowRoot)||void 0===t||t.querySelectorAll("[data-item]").forEach((t=>this.__acknowledgeItem(t))),this.querySelectorAll("[data-item]").forEach((t=>this.__acknowledgeItem(t)))}__acknowledgeItem(t){t.addEventListener("change",this.__changedChildItem.bind(this)),t.currency=this.currency,t.isItem=!1,t.isChildItem=!0,this.code&&(t.parent_code=this.code)}__changedChildItem(){const t=[],e=[];let i=0;this.__onEachChildItem([e=>{void 0!==e.total&&t.push(e.total)},t=>{e.push(t.getImageDescription())},()=>i+=1]),this.image&&0===e.length&&e.push(this.getImageDescription()),this.__childPrices=t,this.__images=e,this.__childrenCount=i,this.__setTotalPrice()}__onEachChildItem(t){const e=this.querySelectorAll("[data-bundled]");for(const i of e)for(const e of t)e(i)}}Q.__existingIds=[];let W,J,U,X,H,G,K=t=>t;class Y extends T{constructor(){super("items-form"),this.readonly=!1,this.target="_top",this.cart="checkout",this.sub_modify="replace",this.sub_restart="auto",this.frequencies=[],this.handleSubmit={handleEvent:()=>{null!==this.__data&&this.dispatchEvent(new m(this.__data))&&this.shadowRoot.querySelector("form").submit()}},this.__hasValidItems=!1,this.__total=0,this.__handleFrequency={handleEvent:t=>{const e=t.detail.replace(/([wydm])\w*/,"$1").replace(/ /g,"").replace(/^0/,"");Y.__validFrequency(e)?this.sub_frequency=e:this.sub_frequency="",this.__updateData()}},this.__data=new FormData,this.__childItemsObserver=new MutationObserver(this.__observeChildren.bind(this)),this.__childItemsObserver.observe(this,{childList:!0,attributes:!1,subtree:!0}),this.updateComplete.then((()=>{this.__acknowledgeItemElements(),this.__computeTotalPrice(),this.__updateData()}))}static get scopedElements(){return{"x-error-screen":d,"vaadin-button":customElements.get("vaadin-button"),"x-dropdown":h,"x-item":Q}}static get properties(){return e(e({},super.properties),{},{currency:{type:String},readonly:{type:Boolean},cart:{type:String,converter:t=>t&&!["checkout","add"].includes(t)?null:t},target:{type:String},store:{type:String,attribute:"store"},sub_frequency:{type:String},sub_startdate:{type:String,converter:t=>Y.__validDate(t)?t:(console.error("Invalid start date",t),"")},sub_enddate:{type:String,converter:t=>Y.__validDateFuture(t)?t:(console.error("Invalid end date",t),"")},sub_token:{type:String},sub_modify:{type:String,converter:t=>""===t||"append"===t?"":"replace"},sub_restart:{type:String,converter:t=>"true"===t?t:"auto"},frequencies:{converter:(t,e)=>{if(!t)return[];const i=JSON.parse(t);if(!Array.isArray(i))return console.error("Invalid frequency","Frequency options must be an array."),[];for(const t of i)if(!Y.__validFrequency(t))return console.error("Invalid frequency","Invalid frequency option.\n Please, check https://wiki.foxycart.com/v/2.0/products#subscription_product_options for possible values.\n Each frequency must be a in the format:\n - 1d (a number followed by d, for day)\n - 1w (a number followed by w, for week)\n - 1m (a number followed by m, for month)\n - 1y (a number followed by y, for year)\n or .5m (no other decimals are allowed, and this is only for months)\n ",t),[];return i.filter(Y.__validFrequency)}},items:{type:Array},__hasValidItems:{attribute:!1},__total:{attribute:!1},__data:{attribute:!1}})}get items(){const t=[];return this.__itemElements.forEach((e=>{const i=new Proxy(e,{set:function(t,e,i){const s=Object.keys(t.value);return!("string"!=typeof e||!s.includes(e))&&(t[e]=i,!0)},get:function(t,e){return t.value[e]}});t.push(i)})),t}set items(t){this.__removeItems(),this.__createItemsFromItemArray(t)}get total(){return this.__total}render(){var t;return this.store&&this.currency?s(J||(J=K` <div> <form class="overflow-hidden" method="POST" target="${0}" action="https://${0}/cart" data-testid="form" class="hidden" hidden> ${0} </form> <section class="items"> <slot></slot> </section> ${0} </div> `),this.target,this.store,this.__data?s(U||(U=K` ${0}`),[...this.__data.entries()].map((([t,e])=>s(X||(X=K`<input type="hidden" name="${0}" value="${0}">`),t,e)))):"",this.readonly?"":s(H||(H=K` <section class="actions flex flex-wrap justify-end m-m"> ${0} <vaadin-button class="m-s w-full sm-w-auto" theme="primary" data-testid="submit" ?disabled="${0}" @click="${0}"> <span class="total"> ${0} </span> </vaadin-button> </section> `),this.frequencies&&this.frequencies.length?s(G||(G=K` <x-dropdown type="text" name="frequency" class="subscription m-s w-full sm-w-auto" lang="${0}" .value="${0}" .items="${0}" .getText="${0}" @change="${0}"> </x-dropdown> `),this.lang,null!==(t=this.sub_frequency)&&void 0!==t?t:"0",this.frequencies.concat(["0"]),this.__translateFrequency.bind(this),this.__handleFrequency):"",!this.__hasValidItems,this.handleSubmit,this.__submitBtnText(this.__translateAmount(this.total)))):s(W||(W=K`<x-error-screen type="setup_needed" class="relative"></x-error-screen>`))}addItems(t){for(const e of t){const t=this.createItem(e);this.appendChild(t),this.__acknowledgeItemElement(t)}}removeItems(t){this.__removeItems((e=>t.includes(e.pid)))}updated(){this.dispatchEvent(new u(this.__data))}createItem(t){const e=this.constructor.getScopedTagName("x-item"),i=document.createElement(e);return i.value=t,i.currency=this.currency,i.readonly=this.readonly,i}__submitBtnText(t){if(this.sub_frequency&&"0"!=this.sub_frequency){const e=r(this.sub_frequency);return 1===e.count?this._t("checkout.subscribe_single_unit",{value:t,period:this._t(e.units).toLowerCase()}):this._t("checkout.subscribe_muiltiple_units",{value:t,period:this.__translateFrequency(this.sub_frequency).toLowerCase()})}return this._t("checkout.buy",{value:t})}get __itemElements(){return this.querySelectorAll("[data-item]")}__createItemsFromItemArray(t){this.addItems(t)}__removeItems(t=(t=>!0)){this.__itemElements.forEach((e=>{t(e)&&e.remove()}))}__addSignature(t,e,i){return`${t}||${e}${i?"||open":""}`}__formDataFill(t){let e=0;return this.__itemElements.forEach((i=>{e+=this.__formDataAddItem(t,i)})),this.__formDataAddCartWideSubscriptionFields(t),e}__formDataCustomInputs(t){this.querySelectorAll("[name]").forEach((e=>{const i=e;"INPUT"==i.tagName&&["checkbox","radio"].includes(i.type)&&!i.checked||"OPTION"!=i.tagName&&i.value&&["number","string"].includes(typeof i.value)&&t.set(i.name,i.value)}))}__isAttributeReserved(t){return["alt","currency","description","isChildren","isItem","items","open","pid","signatures","slot","total"].includes(t)}__formDataAddItem(t,e,i=null){let s=0;if(this.__validItem(e)){if(!e.value.pid)throw new Error("Attempt to convert a item without a propper ID");i&&i.getAttribute("code")&&e.setAttribute("parent_code",i.getAttribute("code"));for(let s=0;s<e.attributes.length;s++){const r=e.attributes[s];if(!this.__isAttributeReserved(r.name)&&!r.name.startsWith("data-")){let s=e[r.name];e.code&&["string","number"].includes(typeof s)&&(i&&"quantity"==r.name&&(s=Number(r.value)*i.quantity),t.set(e.signedName(r.name),s.toString()))}}s+=1,this.__formDataAddSubscriptionFields(t,e)}const r=e.querySelectorAll("[data-bundled]");if(r&&e.quantity>0)for(const i of r)s+=this.__formDataAddItem(t,i,e);return s}__formDataAddSubscriptionFields(t,e){if(this.sub_frequency)for(const i of["sub_frequency","sub_startdate","sub_enddate"])this[i]&&t.set(e.signedName(i),this[i])}__formDataAddCartWideSubscriptionFields(t){this.sub_frequency&&(this.sub_token&&t.set(this.signedName("sub_token"),this.sub_token),t.set(this.signedName("sub_modify"),this.sub_modify),t.set(this.signedName("sub_restart"),this.sub_restart))}__formDataAddCartFields(t){this.cart?t.set("cart",this.cart):t.delete("cart")}static __validDate(t){return null!=t&&(t.match(/^(\d{1,2}|\d{8})$/)?!(t.match(/^\d{2}$/)&&Number(t)>31):!(t.match(/^\.5m/)||!Y.__validFrequency(t)))}static __validDateFuture(t){let e=!1;if(Y.__validDate(t))if(t.match(/^\d{8}/)){e=(new Date).toISOString().replace(/(-|T.*)/g,"")<=t}else e=!0;return e}static __validFrequency(t){return!!t&&!!t.match(/^(\.5m|\d+[dwmy])$/)}__observeChildren(t){t.forEach((t=>{"childList"==t.type&&t.addedNodes.forEach((t=>{t.addEventListener("change",this.__itemChange.bind(this))}))})),this.__acknowledgeItemElements(),this.__computeTotalPrice(),this.__updateData()}__itemChange(){this.__computeTotalPrice(),this.__updateData()}__computeTotalPrice(){let t=0;this.__itemElements.forEach((e=>{const i=e;i.total&&(t+=Number(i.total))})),this.__total=Number(t.toFixed(2))}__acknowledgeItemElements(){this.__itemElements.forEach((t=>{const e=t;this.__acknowledgeItemElement(e)}))}__acknowledgeItemElement(t){t.addEventListener("change",this.__itemChange.bind(this)),t.currency=this.currency}__validItem(t){const e=t.getAttribute("pid"),i=Number(t.getAttribute("quantity")),s=Number(t.getAttribute("price"));return!!(e&&i>0&&s>=0)}__translateFrequency(t){if(t.startsWith("0"))return this._t("frequency_once");if(".5m"===t)return this._t("frequency_0_5m");const{count:e,units:i}=r(t);return this._t("frequency",{units:this._t(i,{count:e}),count:e})}__translateAmount(t){return t.toLocaleString(this.lang,{minimumFractionDigits:2,currency:this.currency,style:"currency"})}__updateData(){this.__data=null;if(!this.shadowRoot.querySelector("form"))return;const t=new FormData,e=this.__formDataFill(t);this.__hasValidItems=!!e,this.__formDataAddCartFields(t),this.__formDataCustomInputs(t),this.__data=t}}customElements.define("foxy-items-form",Y),customElements.define("foxy-item",Q);export{Y as I,F as P,Q as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as r}from"./shared-84203d52.js";import{p as s}from"./shared-87ca7818.js";function t(t){var a;const n=s(t),o=null!==(a={y:"yearly",m:"monthly",w:"weekly",d:"daily"}[n.units])&&void 0!==a?a:n.units;return r(r({},n),{},{units:o})}export{t as p};
|