@foxy.io/elements 1.59.1 → 1.60.2
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 +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-admin-transaction-card.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.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-billing-address-card.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-card.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-card.js +1 -1
- package/dist/cdn/foxy-client-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-copy-to-clipboard.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-api.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-downloadable-card.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-card.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-i18n-editor.js +1 -1
- package/dist/cdn/foxy-integration-card.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-category-card.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-native-integration-card.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-nucleon-element.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-passkey-card.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-card-embed.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-report-form.js +1 -1
- package/dist/cdn/foxy-reports-table.js +6 -6
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-container-card.js +1 -1
- package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-card.js +1 -1
- package/dist/cdn/foxy-shipping-service-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-store-card.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-store-transaction-folder-card.js +1 -1
- package/dist/cdn/foxy-store-transaction-folder-form.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-card.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-card.js +1 -1
- package/dist/cdn/foxy-user-invitation-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-card.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/foxy-webhook-log-card.js +1 -1
- package/dist/cdn/foxy-webhook-status-card.js +1 -1
- package/dist/cdn/{shared-7b6a899b.js → shared-091e97f3.js} +1 -1
- package/dist/cdn/shared-0996f4d0.js +1 -0
- package/dist/cdn/{shared-3991076b.js → shared-0b0ab3d2.js} +1 -1
- package/dist/cdn/{shared-14713ead.js → shared-18707481.js} +1 -1
- package/dist/cdn/{shared-336e73ce.js → shared-222b23bb.js} +1 -1
- package/dist/cdn/shared-2fbff8e7.js +1 -0
- package/dist/cdn/{shared-8ec1b077.js → shared-32a39c0b.js} +1 -1
- package/dist/cdn/shared-345b07f1.js +1 -0
- package/dist/cdn/{shared-bc74cd11.js → shared-3a61d8a6.js} +1 -1
- package/dist/cdn/{shared-1e9df11c.js → shared-3ef23488.js} +1 -1
- package/dist/cdn/{shared-33d770fe.js → shared-40a2705c.js} +1 -1
- package/dist/cdn/{shared-cb5305b9.js → shared-41f93e6c.js} +1 -1
- package/dist/cdn/{shared-45649d84.js → shared-4ab85bea.js} +1 -1
- package/dist/cdn/{shared-28fa98d7.js → shared-4ed4b075.js} +1 -1
- package/dist/cdn/{shared-20841d9c.js → shared-56278a3c.js} +1 -1
- package/dist/cdn/{shared-d743ec15.js → shared-5e7defee.js} +1 -1
- package/dist/cdn/{shared-59dfee2c.js → shared-7b15217c.js} +1 -1
- package/dist/cdn/{shared-1a814f90.js → shared-7e28c953.js} +1 -1
- package/dist/cdn/shared-8062bbb8.js +1 -0
- package/dist/cdn/{shared-2652e98e.js → shared-8292d44e.js} +1 -1
- package/dist/cdn/shared-87e17c02.js +1 -0
- package/dist/cdn/{shared-a1bec4a0.js → shared-88f841ff.js} +1 -1
- package/dist/cdn/{shared-3eca56ee.js → shared-8be109a9.js} +1 -1
- package/dist/cdn/{shared-9f8b593b.js → shared-8f5c8c08.js} +1 -1
- package/dist/cdn/{shared-be20875c.js → shared-9b290320.js} +1 -1
- package/dist/cdn/{shared-b84996e5.js → shared-a95a66b8.js} +1 -1
- package/dist/cdn/{shared-4cc16cdf.js → shared-ac536c67.js} +1 -1
- package/dist/cdn/{shared-38e0a818.js → shared-af4f71bf.js} +1 -1
- package/dist/cdn/{shared-50ef1d5a.js → shared-c85c1864.js} +1 -1
- package/dist/cdn/{shared-760a2243.js → shared-cda51ccf.js} +1 -1
- package/dist/cdn/{shared-db17c9ee.js → shared-d2f777dc.js} +1 -1
- package/dist/cdn/{shared-fdf6df5c.js → shared-e9f9face.js} +1 -1
- package/dist/cdn/{shared-3baa9cc9.js → shared-eb349085.js} +1 -1
- package/dist/cdn/{shared-19b475f7.js → shared-f9c8881a.js} +1 -1
- package/dist/cdn/translations/customer/en.json +1 -1
- package/dist/cdn/translations/customer-form/en.json +3 -2
- package/dist/cdn/translations/customer-portal/en.json +3 -2
- package/dist/cdn/translations/user-invitation-form/en.json +4 -0
- package/dist/elements/public/CustomerForm/CustomerForm.d.ts +2 -0
- package/dist/elements/public/CustomerForm/CustomerForm.js +16 -3
- package/dist/elements/public/CustomerForm/CustomerForm.js.map +1 -1
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.d.ts +5 -2
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.js +28 -8
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.js.map +1 -1
- package/dist/utils/group-invitation-scopes.d.ts +1 -1
- package/dist/utils/group-invitation-scopes.js +4 -2
- package/dist/utils/group-invitation-scopes.js.map +1 -1
- package/dist/utils/invitation-scope.d.ts +1 -1
- package/dist/utils/invitation-scope.js +9 -10
- package/dist/utils/invitation-scope.js.map +1 -1
- package/dist/utils/user-scope.js +2 -2
- package/dist/utils/user-scope.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-36f1e29f.js +0 -1
- package/dist/cdn/shared-559b648a.js +0 -1
- package/dist/cdn/shared-a44fcc6a.js +0 -1
- package/dist/cdn/shared-ab1f5f1f.js +0 -1
- package/dist/cdn/shared-da3393a5.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalUserInvitationFormScopeControl.js","sourceRoot":"","sources":["../../../../../../src/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,gFAA6E;AAC/G,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,wDAAqD;AACvF,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,GACf,iDAA8C;AAI/C;;;;;;;;;GASG;AACH,MAAM,OAAO,sCAAuC,SAAQ,uBAAuB;IAAnF;;QAsEE,4EAA4E;QAC5E,iBAAY,GAAkB,IAAI,CAAC;QAEnC;;;;WAIG;QACK,qBAAgB,GAAG,KAAK,CAAC;QAEjC;;;;WAIG;QACK,eAAU,GAAG,KAAK,CAAC;IAiW7B,CAAC;IArbC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,YAAY,EAAE,EAAE,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../../internal/InternalSelectControl/types';\nimport type { Level, Selection } from '../../../../../utils/invitation-scope';\n\nimport { InternalEditableControl } from '../../../../internal/InternalEditableControl/InternalEditableControl';\nimport { COLLECTIONS, RESENDABLE } from '../../../../../utils/group-invitation-scopes';\nimport { css } from 'lit-element';\nimport { html } from 'lit-html';\n\nimport {\n canGrantLevel,\n canGrantReadPreset,\n canGrantResend,\n getGrantable,\n parseScope,\n serializeScope,\n} from '../../../../../utils/invitation-scope';\n\ntype Preset = 'store' | 'read' | 'custom';\n\n/**\n * Lets an admin choose which scopes an invitation grants, offering only what the granting\n * user already holds.\n *\n * Bound to the invitation's `scope` string through `infer=\"scope\"`. The server is the real\n * enforcement boundary; this control exists so the UI\n * never offers a grant that would be rejected.\n *\n * @element foxy-internal-user-invitation-form-scope-control\n */\nexport class InternalUserInvitationFormScopeControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n granterScope: { attribute: 'granter-scope' },\n __customSelected: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n /*\n * \\`foxy-internal-summary-control\\` puts \\`::slotted(*) { min-width: 100% }\\` on\n * whatever it slots, and (outside \\`layout=\"section\"\\`) a background/padding on each\n * slotted element too -- both aimed at a vertical list of full-width summary-items, and\n * both outside this control's reach: they're declared against the *slotted* elements\n * from the summary control's own shadow tree, not against anything inside this one, so\n * there is no selector this control's own \\`static styles\\` could write that would stop\n * a slotted element from being full-width, and the grid that would need a second\n * \\`grid-template-columns\\` track lives inside the summary control's own shadow root --\n * not reachable at all from here (confirmed: a \\`::slotted(*)\\` rule only ever targets\n * the slotted elements themselves, never the host's own internal structure around the\n * \\`<slot>\\`). So overriding a rule of ours against the slotted elements, per CSS\n * Scoping's normal-declarations-in-the-tree-the-element-lives-in-beat-::slotted()-rule\n * precedence, can only ever affect how each *individual* slotted box is sized -- it\n * cannot make the summary control itself lay two of them out side by side, because nothing\n * this control writes can reach that summary control's own internal grid container.\n *\n * So there is exactly one slotted child here: \\`.matrix\\`, a wrapper \\`<div>\\` (see\n * \\`renderControl\\`) that lays its own 20 real children out in a grid this control fully\n * owns. \\`layout=\"section\"\\` on the summary control (see \\`renderControl\\`) opts out of its\n * background/padding-on-slotted-child rule, since that would otherwise tint the *whole*\n * wrapper as one block; this control re-creates the summary-item tile look itself, on\n * each *individual* row, below.\n */\n .matrix {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 1px;\n border-radius: var(--lumo-border-radius);\n overflow: hidden;\n }\n\n @media all and (min-width: 640px) {\n .matrix {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n }\n }\n\n /*\n * Each row is one \\`foxy-internal-select-control[layout=\"summary-item\"]\\`, a single\n * self-contained element (see \\`__renderLevelControl\\`) -- no more per-row wrapper,\n * sibling label, or separate checkbox. Its own background here (rather than\n * \\`::slotted(*)\\`'s, opted out of above) is what recreates the individual-tile look;\n * the 1px \\`.matrix\\` gap on top of \\`var(--lumo-contrast-10pct)\\` shows through between\n * every row *and* column as a hairline divider, in both directions -- a container-level\n * \\`divide-y\\` (this control's previous approach, before the summary-item rework) only\n * ever divides one axis, which draws a confusing line between the two columns' cells of\n * the same visual row; a grid gap does not have that problem.\n */\n .matrix > foxy-internal-select-control {\n background-color: var(--lumo-contrast-5pct);\n padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px);\n }\n `,\n ];\n }\n\n /** Space-separated scope of the user creating or editing the invitation. */\n granterScope: string | null = null;\n\n /**\n * Set when the admin picks `Custom` explicitly. Needed because an empty scope parses to a\n * `null` preset, so without this the radio would snap back to nothing selected the moment\n * `Custom` was chosen but before any row was set.\n */\n private __customSelected = false;\n\n /**\n * Cached outcome of `__hasUnreachableGrant` from the most recently completed `renderControl()`\n * pass. Read by `updated()` below -- see its doc comment for why the lock needs to land on\n * `this.readonly` itself rather than staying a `renderControl()`-local variable.\n */\n private __isLocked = false;\n\n renderControl(): TemplateResult {\n const selection = parseScope(this.__scope);\n const grantable = getGrantable(this.granterScope ?? void 0);\n const currentPreset = this.__preset(selection);\n const presets: Preset[] = [];\n\n if (grantable.storeFullAccess) presets.push('store');\n if (canGrantReadPreset(grantable)) presets.push('read');\n presets.push('custom');\n\n // The invitation can already hold a preset this granter couldn't offer themselves --\n // e.g. a full-access admin created it, and a narrower admin is now editing it. Omitting\n // it would make an existing grant look like no grant at all, so it's still listed as an\n // option (the same treatment `__renderLevelControl` gives an out-of-reach row level) --\n // otherwise `summary-item`'s displayed value would fall back to its placeholder instead\n // of showing the invitation's actual preset. `custom` is always offered and `null`\n // selects nothing, so only `store` and `read` can end up here.\n const mismatchedPreset =\n currentPreset && !presets.includes(currentPreset) ? currentPreset : null;\n\n const renderedPresets: Preset[] = (['store', 'read', 'custom'] as const).filter(\n preset => presets.includes(preset) || preset === mismatchedPreset\n );\n\n // The invitation can hold a grant this granter cannot themselves re-grant (see\n // `__hasUnreachableGrant`, which treats a mismatched preset as grounds to lock on its\n // own). The API validates the *entire* submitted `scope` string\n // whenever it's dirty, not just the delta, so any edit here would re-serialize and\n // resubmit that out-of-reach value and the server would reject the whole save -- a\n // failure the admin cannot fix, because there is no way to *only* change the preset\n // without touching the rest. Locking the whole control instead means no edit, and\n // therefore no failing save, can be attempted. The out-of-reach value stays visible,\n // same as always -- only editability changes. Because a mismatched preset already forces\n // `isLocked` (and therefore `readonly`) below, no separate per-option disabling is needed\n // here either -- the same reasoning `__renderLevelControl` and `__renderResendSwitches`\n // already rely on for their own mismatches.\n const isLocked = this.__hasUnreachableGrant(selection, grantable, !!mismatchedPreset);\n\n // Read by `updated()` below -- see its doc comment for why the lock also needs to land on\n // the `readonly` *property* itself, not just this render pass's local variable.\n this.__isLocked = isLocked;\n\n const readonly = this.readonly || isLocked;\n const helperText = isLocked ? this.t('helper_text_locked') : this.helperText;\n\n const presetOptions: Option[] = renderedPresets.map(preset => ({\n label: `preset_${preset}`,\n value: preset,\n }));\n\n return html`\n <div class=\"grid gap-m\">\n <foxy-internal-summary-control infer=\"\" label=${this.label} helper-text=${helperText}>\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t('preset_label')}\n helper-text=\"\"\n data-preset=\"\"\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${presetOptions}\n .getValue=${() => currentPreset ?? undefined}\n .setValue=${(newValue: unknown) => this.__selectPreset(newValue as Preset)}\n >\n </foxy-internal-select-control>\n </foxy-internal-summary-control>\n ${currentPreset === 'custom'\n ? html`\n <div class=\"matrix\">\n ${COLLECTIONS.map(collection =>\n this.__renderLevelControl(collection, selection, grantable, readonly)\n )}\n </div>\n ${this.__renderResendSwitches(selection, grantable, readonly)}\n `\n : ''}\n </div>\n `;\n }\n\n /**\n * Reflects a lock onto the real `readonly` property (in addition to whatever `updated()`\n * itself, e.g. `renderControl()`'s own `?readonly=` bindings, already did with the local\n * variable) once the initial render has committed.\n *\n * This exists because each row is now a nested `foxy-internal-select-control`.\n * `ConfigurableMixin` makes every such control infer its own `readonly` from the nearest\n * ancestor that has one (this control), by reading `this.readonly` directly during an async\n * walk (`InferrableMixin.inferFromElement`'s `key in element` check) -- not from whatever a\n * template attribute happened to bind on the row. That walk re-runs on every one of this\n * control's own updates (`InferrableMixin.updated()` calls `inferPropertiesInDescendants()`\n * unconditionally), so a row bound only via `?readonly=${this.readonly || isLocked}` in\n * `renderControl()` is overwritten back to whatever `this.readonly` was moments later --\n * confirmed empirically by a probe test, see this task's report. Setting `this.readonly`\n * itself is what the row's own inference actually reads, so this is not a workaround so much\n * as the property meaning what it says: locked really does mean the whole control, including\n * everything nested inside it, is readonly.\n *\n * Assigning inside `updated()` rather than `renderControl()`/`render()` matters too: mutating\n * a reactive property mid-render is what triggers lit's \"scheduled an update... during\n * update\" warning (and the `does not warn on a fresh empty-scope render` test would catch\n * it); `updated()` is the lifecycle hook lit itself documents for deriving follow-up state\n * from a completed render, and setting a property there does not warn.\n *\n * Never resets `this.readonly` back to `false` on its own -- the externally-imposed half\n * (e.g. the form's own `readonlycontrols` selector matching `scope`) is owned entirely by\n * `ConfigurableMixin`'s own inheritance, which keeps re-asserting its own value on every\n * update independently of this method.\n */\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (this.__isLocked && !this.readonly) this.readonly = true;\n }\n\n /**\n * `true` when the invitation already holds something this granter could not themselves\n * grant: the current preset isn't among the ones offered, a collection's current level\n * isn't grantable at that level, or a collection currently has a resend grant the granter\n * cannot extend. Reuses `canGrantLevel` / `canGrantResend` rather than reimplementing\n * grantability -- see `renderControl` for why this forces the whole control readonly.\n */\n private __hasUnreachableGrant(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n hasMismatchedPreset: boolean\n ): boolean {\n if (hasMismatchedPreset) return true;\n\n const hasUnreachableLevel = COLLECTIONS.some(collection => {\n return !canGrantLevel(grantable, collection, selection.levels[collection] ?? 'none');\n });\n\n if (hasUnreachableLevel) return true;\n\n return selection.resend.some(collection => !canGrantResend(grantable, collection));\n }\n\n /**\n * Renders one collection's level picker as a self-contained `foxy-internal-select-control`\n * in `summary-item` layout: a native `<select>` with a real `<label for=\"select\">` (the\n * collection name, passed via `label`, replacing both the old sibling `foxy-i18n` and the\n * `aria-label` workaround that stood in for a proper accessible name before this control had\n * one) plus the current value shown as compact text. `data-collection` moves onto this\n * element directly -- there's no separate row wrapper left to carry it (see the control's\n * `styles` for why one output element per collection, not a wrapper `<div>` per row, is what\n * lets this control own its own two-column grid).\n */\n private __renderLevelControl(\n collection: string,\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult {\n const allLevels: Level[] = ['none', 'read', 'full'];\n const currentLevel = selection.levels[collection] ?? 'none';\n\n // `stores_read` is what authorizes `GET /stores/{id}` and the `/stores` listing --\n // without it a user cannot load the store page or the store picker, so \"no store access\"\n // is not a real choice for this row going forward: this row's own select can only ever be\n // set to `read` or `full` from here on. This narrows what a user can newly *choose*, not\n // what a scope string already contains -- an invitation whose stores row has simply never\n // been touched (imported via the API, or edited only through a different row) still\n // parses `stores` as `none` and is written that way; see `mismatchedLevel` below for how\n // that value stays displayable without being treated as an unreachable grant.\n const offerable: Level[] = collection === 'stores' ? ['read', 'full'] : allLevels;\n const available = offerable.filter(level => canGrantLevel(grantable, collection, level));\n\n // The option list must be the grantable levels for this row, PLUS the row's current level\n // if it is not grantable/offerable. `vaadin-combo-box` reconciles its displayed value\n // against `.items` on every `.value`/`.items` change (verified directly, see the control's\n // test suite and this task's report), and the native `<select>` `summary-item` renders\n // behaves the same way for an unlisted `<option>` -- an out-of-reach current level not\n // present in `.options` would fail to display at all. `none` is always grantable (see\n // `canGrantLevel`), so for every collection except `stores` only `read` or `full` can end\n // up here as a mismatch -- but a legacy or API-created invitation can hold no `stores_*`\n // tokens at all, which parses to `none`, and `none` is no longer offerable for that one\n // row, so `none` itself can be the mismatch there.\n //\n // No per-option disabling is needed for a level the granter truly cannot re-grant:\n // `__hasUnreachableGrant` already forces the *entire* control readonly the instant any row\n // holds such a level, so that kind of mismatch can only ever be rendered while the whole\n // row control is already readonly. The `stores` row's own `none` mismatch is different --\n // `canGrantLevel` returns `true` unconditionally for `'none'` (see `invitation-scope.ts`),\n // so it is a *legal* grant the granter could re-issue, not an unreachable one. It does not\n // trip `__hasUnreachableGrant`, and is rendered editable while the rest of the control\n // stays unlocked (pinned by this control's own test suite: \"does not lock the control\n // merely because the stores row is at its mismatched-but-grantable none\"). Either way, the\n // out-of-reach value is simply the control's value.\n const mismatchedLevel = available.includes(currentLevel) ? null : currentLevel;\n\n // Filtered from `allLevels`, not the narrowed `offerable` list: for the `stores` row,\n // `none` was removed from `offerable` above, but an invitation with no `stores_*` tokens\n // still parses its current level as `none`. Filtering from `offerable` here would drop\n // `none` from the rendered options even when it's `mismatchedLevel`, leaving the select's\n // value absent from its own option list -- the same \"current value must stay a real\n // option\" rule as the `mismatchedLevel` fallback right above, just applied one filter\n // earlier where a narrower source list can undo it.\n const renderedLevels = allLevels.filter(\n level => available.includes(level) || level === mismatchedLevel\n );\n\n const options: Option[] = renderedLevels.map(level => ({\n label: `level_${level}`,\n value: level,\n }));\n\n return html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t(`scopes.${collection}`)}\n helper-text=\"\"\n data-collection=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${options}\n .getValue=${() => currentLevel}\n .setValue=${(newValue: unknown) => {\n // The native `<select>` `summary-item` renders always has a real selection (its\n // first, disabled placeholder `<option>` aside) once a value is set, so there is no\n // \"clear\" affordance to coerce here the way the old vaadin-combo-box row needed --\n // kept anyway as the same defensive floor: there is no \"no level\" state for a row,\n // and this must never let an empty/undefined token reach the serialized scope.\n this.__setLevel(collection, ((newValue as string) || 'none') as Level);\n }}\n >\n </foxy-internal-select-control>\n `;\n }\n\n /**\n * Renders the three resendable collections' resend grants as `foxy-internal-switch-control`s,\n * one per line, in their own `foxy-internal-summary-control` -- not folded into the level\n * grid above. Resend is a secondary, independent axis (a collection's level and its resend\n * grant are unrelated tokens -- see `parseScope`/`serializeScope`), covers only 3 of the 20\n * collections, and doesn't need the level grid's two-column treatment; keeping it as its own\n * section also means the grid's CSS (sized for 20 short rows) never has to accommodate a\n * structurally different kind of row. Renders nothing at all if the granter can't grant (and\n * the invitation doesn't already hold) any resend permission, rather than an empty section.\n */\n private __renderResendSwitches(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult | string {\n const switches = RESENDABLE.map(collection => {\n const hasResend = selection.resend.includes(collection);\n const canResend = canGrantResend(grantable, collection);\n\n // Mirrors the level mismatch in `__renderLevelControl`: the invitation can already carry\n // a resend grant this granter can no longer extend themselves. Unlike the level mismatch,\n // this needs no *separate* `disabled` condition below -- `__hasUnreachableGrant` already\n // treats any resend mismatch as grounds to lock the *entire* control (see its own return\n // statement), so `mismatchedResend` and this control's own `readonly` are never true/false\n // independently of each other; adding a redundant `?disabled=` term here would only be\n // exercising `foxy-internal-switch-control`'s `disabled` -- a `ConfigurableMixin`-inferred\n // property subject to the exact same ancestor-inference-can-overwrite-a-template-binding\n // risk documented on this control's own `updated()`, for a case that can't actually occur.\n const mismatchedResend = hasResend && !canResend;\n\n return { collection, hasResend, mismatchedResend, show: canResend || mismatchedResend };\n }).filter(entry => entry.show);\n\n if (!switches.length) return '';\n\n return html`\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${switches.map(\n ({ collection, hasResend }) => html`\n <foxy-internal-switch-control\n infer=\"\"\n label=${`${this.t('resend')} ${this.t(`scopes.${collection}`).toLowerCase()}`}\n helper-text=\"\"\n data-resend=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .getValue=${() => hasResend}\n .setValue=${(newValue: unknown) => this.__setResend(collection, !!newValue)}\n >\n </foxy-internal-switch-control>\n `\n )}\n </foxy-internal-summary-control>\n `;\n }\n\n private __setLevel(collection: string, level: Level): void {\n // Touching a row is proof the admin is actively editing in custom mode. Without this, an\n // edit that happens to make the selection match another preset (e.g. the last collection\n // reaching `read`) would make `__preset` fall back to `parseScope`'s classification and the\n // matrix would vanish out from under the admin mid-edit.\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n selection.levels[collection] = level;\n this._value = serializeScope({ ...selection, preset: 'custom' });\n }\n\n private __setResend(collection: string, checked: boolean): void {\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n\n const resend = checked\n ? [...selection.resend, collection]\n : selection.resend.filter(entry => entry !== collection);\n\n this._value = serializeScope({ ...selection, preset: 'custom', resend });\n }\n\n /**\n * The scope currently in the form. Undefined before the first edit on a new invitation.\n * An existing invitation saved without a scope grants full store access in the API, so it\n * reads as the wildcard here instead of as \"nothing chosen\".\n */\n private get __scope(): string | undefined {\n const scope = (this._value as string | undefined) ?? void 0;\n if (!scope?.trim() && this.nucleon?.data) return 'store_full_access';\n return scope;\n }\n\n private __preset(selection: Selection): Preset | null {\n if (this.__customSelected) return 'custom';\n return selection.preset;\n }\n\n private __selectPreset(preset: Preset): void {\n this.__customSelected = preset === 'custom';\n\n // Choosing Custom keeps whatever is already in the form, so the matrix opens on the\n // current grant rather than wiping it. The wildcard has no per-row levels, so it is\n // expanded into what it grants -- every collection at Full and every resend. Keeping\n // `store_full_access` behind rows that all read None would save a full-access invitation.\n if (preset === 'custom') {\n const selection = parseScope(this.__scope);\n if (selection.preset !== 'store') return;\n\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'full'));\n this._value = serializeScope({ ...selection, preset: 'custom', resend: [...RESENDABLE] });\n return;\n }\n\n if (preset === 'store') {\n this._value = 'store_full_access';\n } else {\n const selection = parseScope('');\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'read'));\n this._value = serializeScope(selection);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalUserInvitationFormScopeControl.js","sourceRoot":"","sources":["../../../../../../src/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,gFAA6E;AAC/G,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,wDAAqD;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,GACf,iDAA8C;AAI/C;;;;;;;;;GASG;AACH,MAAM,OAAO,sCAAuC,SAAQ,uBAAuB;IAAnF;;QAsEE,4EAA4E;QAC5E,iBAAY,GAAkB,IAAI,CAAC;QAEnC;;;;WAIG;QACK,qBAAgB,GAAG,KAAK,CAAC;QAEjC;;;;WAIG;QACK,eAAU,GAAG,KAAK,CAAC;IAuX7B,CAAC;IA3cC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KA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AC,MAAM,KAAK,OAAO;gBAAE,OAAO;YAEzC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC3E,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YACjE,OAAO;SACR;QAED,IAAI,MAAM,KAAK,OAAO,EAAE;YACtB,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC;SACnC;aAAM;YACL,MAAM,SAAS,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;YACjC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC3E,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;SACzC;IACH,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Option } from '../../../../internal/InternalSelectControl/types';\nimport type { Level, Selection } from '../../../../../utils/invitation-scope';\n\nimport { InternalEditableControl } from '../../../../internal/InternalEditableControl/InternalEditableControl';\nimport { COLLECTIONS, RESENDABLE } from '../../../../../utils/group-invitation-scopes';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { css } from 'lit-element';\nimport { html } from 'lit-html';\n\nimport {\n canGrantLevel,\n canGrantReadPreset,\n canGrantResend,\n getGrantable,\n parseScope,\n serializeScope,\n} from '../../../../../utils/invitation-scope';\n\ntype Preset = 'store' | 'read' | 'custom';\n\n/**\n * Lets an admin choose which scopes an invitation grants, offering only what the granting\n * user already holds.\n *\n * Bound to the invitation's `scope` string through `infer=\"scope\"`. The server is the real\n * enforcement boundary; this control exists so the UI\n * never offers a grant that would be rejected.\n *\n * @element foxy-internal-user-invitation-form-scope-control\n */\nexport class InternalUserInvitationFormScopeControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n granterScope: { attribute: 'granter-scope' },\n __customSelected: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n /*\n * \\`foxy-internal-summary-control\\` puts \\`::slotted(*) { min-width: 100% }\\` on\n * whatever it slots, and (outside \\`layout=\"section\"\\`) a background/padding on each\n * slotted element too -- both aimed at a vertical list of full-width summary-items, and\n * both outside this control's reach: they're declared against the *slotted* elements\n * from the summary control's own shadow tree, not against anything inside this one, so\n * there is no selector this control's own \\`static styles\\` could write that would stop\n * a slotted element from being full-width, and the grid that would need a second\n * \\`grid-template-columns\\` track lives inside the summary control's own shadow root --\n * not reachable at all from here (confirmed: a \\`::slotted(*)\\` rule only ever targets\n * the slotted elements themselves, never the host's own internal structure around the\n * \\`<slot>\\`). So overriding a rule of ours against the slotted elements, per CSS\n * Scoping's normal-declarations-in-the-tree-the-element-lives-in-beat-::slotted()-rule\n * precedence, can only ever affect how each *individual* slotted box is sized -- it\n * cannot make the summary control itself lay two of them out side by side, because nothing\n * this control writes can reach that summary control's own internal grid container.\n *\n * So there is exactly one slotted child here: \\`.matrix\\`, a wrapper \\`<div>\\` (see\n * \\`renderControl\\`) that lays its own 20 real children out in a grid this control fully\n * owns. \\`layout=\"section\"\\` on the summary control (see \\`renderControl\\`) opts out of its\n * background/padding-on-slotted-child rule, since that would otherwise tint the *whole*\n * wrapper as one block; this control re-creates the summary-item tile look itself, on\n * each *individual* row, below.\n */\n .matrix {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 1px;\n border-radius: var(--lumo-border-radius);\n overflow: hidden;\n }\n\n @media all and (min-width: 640px) {\n .matrix {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n }\n }\n\n /*\n * Each row is one \\`foxy-internal-select-control[layout=\"summary-item\"]\\`, a single\n * self-contained element (see \\`__renderLevelControl\\`) -- no more per-row wrapper,\n * sibling label, or separate checkbox. Its own background here (rather than\n * \\`::slotted(*)\\`'s, opted out of above) is what recreates the individual-tile look;\n * the 1px \\`.matrix\\` gap on top of \\`var(--lumo-contrast-10pct)\\` shows through between\n * every row *and* column as a hairline divider, in both directions -- a container-level\n * \\`divide-y\\` (this control's previous approach, before the summary-item rework) only\n * ever divides one axis, which draws a confusing line between the two columns' cells of\n * the same visual row; a grid gap does not have that problem.\n */\n .matrix > foxy-internal-select-control {\n background-color: var(--lumo-contrast-5pct);\n padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px);\n }\n `,\n ];\n }\n\n /** Space-separated scope of the user creating or editing the invitation. */\n granterScope: string | null = null;\n\n /**\n * Set when the admin picks `Custom` explicitly. Needed because an empty scope parses to a\n * `null` preset, so without this the radio would snap back to nothing selected the moment\n * `Custom` was chosen but before any row was set.\n */\n private __customSelected = false;\n\n /**\n * Cached outcome of `__hasUnreachableGrant` from the most recently completed `renderControl()`\n * pass. Read by `updated()` below -- see its doc comment for why the lock needs to land on\n * `this.readonly` itself rather than staying a `renderControl()`-local variable.\n */\n private __isLocked = false;\n\n renderControl(): TemplateResult {\n const selection = parseScope(this.__scope);\n const grantable = getGrantable(this.granterScope ?? void 0);\n const currentPreset = this.__preset(selection);\n const presets: Preset[] = [];\n\n if (grantable.storeFullAccess) presets.push('store');\n if (canGrantReadPreset(grantable)) presets.push('read');\n presets.push('custom');\n\n // The invitation can already hold a preset this granter couldn't offer themselves --\n // e.g. a full-access admin created it, and a narrower admin is now editing it. Omitting\n // it would make an existing grant look like no grant at all, so it's still listed as an\n // option (the same treatment `__renderLevelControl` gives an out-of-reach row level) --\n // otherwise `summary-item`'s displayed value would fall back to its placeholder instead\n // of showing the invitation's actual preset. `custom` is always offered and `null`\n // selects nothing, so only `store` and `read` can end up here.\n const mismatchedPreset =\n currentPreset && !presets.includes(currentPreset) ? currentPreset : null;\n\n const renderedPresets: Preset[] = (['store', 'read', 'custom'] as const).filter(\n preset => presets.includes(preset) || preset === mismatchedPreset\n );\n\n // The invitation can hold a grant this granter cannot themselves re-grant (see\n // `__hasUnreachableGrant`, which treats a mismatched preset as grounds to lock on its\n // own). The API validates the *entire* submitted `scope` string\n // whenever it's dirty, not just the delta, so any edit here would re-serialize and\n // resubmit that out-of-reach value and the server would reject the whole save -- a\n // failure the admin cannot fix, because there is no way to *only* change the preset\n // without touching the rest. Locking the whole control instead means no edit, and\n // therefore no failing save, can be attempted. The out-of-reach value stays visible,\n // same as always -- only editability changes. Because a mismatched preset already forces\n // `isLocked` (and therefore `readonly`) below, no separate per-option disabling is needed\n // here either -- the same reasoning `__renderLevelControl` and `__renderResendSwitches`\n // already rely on for their own mismatches.\n const isLocked = this.__hasUnreachableGrant(selection, grantable, !!mismatchedPreset);\n\n // Read by `updated()` below -- see its doc comment for why the lock also needs to land on\n // the `readonly` *property* itself, not just this render pass's local variable.\n this.__isLocked = isLocked;\n\n const readonly = this.readonly || isLocked;\n const helperText = isLocked ? this.t('helper_text_locked') : this.helperText;\n\n const presetOptions: Option[] = renderedPresets.map(preset => ({\n label: `preset_${preset}`,\n value: preset,\n }));\n\n return html`\n <div class=\"grid gap-m\">\n <foxy-internal-summary-control infer=\"\" label=${this.label} helper-text=${helperText}>\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t('preset_label')}\n helper-text=\"\"\n data-preset=\"\"\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${presetOptions}\n .getValue=${() => currentPreset ?? undefined}\n .setValue=${(newValue: unknown) => this.__selectPreset(newValue as Preset)}\n >\n </foxy-internal-select-control>\n </foxy-internal-summary-control>\n ${currentPreset === 'custom'\n ? html`\n <div class=\"matrix\">\n ${COLLECTIONS.map(collection =>\n this.__renderLevelControl(collection, selection, grantable, readonly)\n )}\n </div>\n ${this.__renderResendSwitches(selection, grantable, readonly)}\n `\n : ''}\n </div>\n `;\n }\n\n /**\n * Reflects a lock onto the real `readonly` property (in addition to whatever `updated()`\n * itself, e.g. `renderControl()`'s own `?readonly=` bindings, already did with the local\n * variable) once the initial render has committed.\n *\n * This exists because each row is now a nested `foxy-internal-select-control`.\n * `ConfigurableMixin` makes every such control infer its own `readonly` from the nearest\n * ancestor that has one (this control), by reading `this.readonly` directly during an async\n * walk (`InferrableMixin.inferFromElement`'s `key in element` check) -- not from whatever a\n * template attribute happened to bind on the row. That walk re-runs on every one of this\n * control's own updates (`InferrableMixin.updated()` calls `inferPropertiesInDescendants()`\n * unconditionally), so a row bound only via `?readonly=${this.readonly || isLocked}` in\n * `renderControl()` is overwritten back to whatever `this.readonly` was moments later --\n * confirmed empirically by a probe test, see this task's report. Setting `this.readonly`\n * itself is what the row's own inference actually reads, so this is not a workaround so much\n * as the property meaning what it says: locked really does mean the whole control, including\n * everything nested inside it, is readonly.\n *\n * Assigning inside `updated()` rather than `renderControl()`/`render()` matters too: mutating\n * a reactive property mid-render is what triggers lit's \"scheduled an update... during\n * update\" warning (and the `does not warn on a fresh empty-scope render` test would catch\n * it); `updated()` is the lifecycle hook lit itself documents for deriving follow-up state\n * from a completed render, and setting a property there does not warn.\n *\n * Never resets `this.readonly` back to `false` on its own -- the externally-imposed half\n * (e.g. the form's own `readonlycontrols` selector matching `scope`) is owned entirely by\n * `ConfigurableMixin`'s own inheritance, which keeps re-asserting its own value on every\n * update independently of this method.\n */\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (this.__isLocked && !this.readonly) this.readonly = true;\n }\n\n // A resend switch at Full is inferred as `included-resend`, so it can be readonly on its own:\n // a `?readonly=` binding on it would be overwritten by inference, as `updated()` describes.\n get readonlySelector(): BooleanSelector {\n return new BooleanSelector(`${super.readonlySelector.toString()} included-resend`.trim());\n }\n\n /**\n * `true` when the invitation already holds something this granter could not themselves\n * grant: the current preset isn't among the ones offered, a collection's current level\n * isn't grantable at that level, or a collection currently has a resend grant the granter\n * cannot extend. Reuses `canGrantLevel` / `canGrantResend` rather than reimplementing\n * grantability -- see `renderControl` for why this forces the whole control readonly.\n */\n private __hasUnreachableGrant(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n hasMismatchedPreset: boolean\n ): boolean {\n if (hasMismatchedPreset) return true;\n\n const hasUnreachableLevel = COLLECTIONS.some(collection => {\n return !canGrantLevel(grantable, collection, selection.levels[collection] ?? 'none');\n });\n\n if (hasUnreachableLevel) return true;\n\n return selection.resend.some(collection => !canGrantResend(grantable, collection));\n }\n\n /**\n * Renders one collection's level picker as a self-contained `foxy-internal-select-control`\n * in `summary-item` layout: a native `<select>` with a real `<label for=\"select\">` (the\n * collection name, passed via `label`, replacing both the old sibling `foxy-i18n` and the\n * `aria-label` workaround that stood in for a proper accessible name before this control had\n * one) plus the current value shown as compact text. `data-collection` moves onto this\n * element directly -- there's no separate row wrapper left to carry it (see the control's\n * `styles` for why one output element per collection, not a wrapper `<div>` per row, is what\n * lets this control own its own two-column grid).\n */\n private __renderLevelControl(\n collection: string,\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult {\n const allLevels: Level[] = ['none', 'read', 'full'];\n const currentLevel = selection.levels[collection] ?? 'none';\n\n // `stores_read` is what authorizes `GET /stores/{id}` and the `/stores` listing --\n // without it a user cannot load the store page or the store picker, so \"no store access\"\n // is not a real choice for this row going forward: this row's own select can only ever be\n // set to `read` or `full` from here on. This narrows what a user can newly *choose*, not\n // what a scope string already contains -- an invitation whose stores row has simply never\n // been touched (imported via the API, or edited only through a different row) still\n // parses `stores` as `none` and is written that way; see `mismatchedLevel` below for how\n // that value stays displayable without being treated as an unreachable grant.\n const offerable: Level[] = collection === 'stores' ? ['read', 'full'] : allLevels;\n const available = offerable.filter(level => canGrantLevel(grantable, collection, level));\n\n // The option list must be the grantable levels for this row, PLUS the row's current level\n // if it is not grantable/offerable. `vaadin-combo-box` reconciles its displayed value\n // against `.items` on every `.value`/`.items` change (verified directly, see the control's\n // test suite and this task's report), and the native `<select>` `summary-item` renders\n // behaves the same way for an unlisted `<option>` -- an out-of-reach current level not\n // present in `.options` would fail to display at all. `none` is always grantable (see\n // `canGrantLevel`), so for every collection except `stores` only `read` or `full` can end\n // up here as a mismatch -- but a legacy or API-created invitation can hold no `stores_*`\n // tokens at all, which parses to `none`, and `none` is no longer offerable for that one\n // row, so `none` itself can be the mismatch there.\n //\n // No per-option disabling is needed for a level the granter truly cannot re-grant:\n // `__hasUnreachableGrant` already forces the *entire* control readonly the instant any row\n // holds such a level, so that kind of mismatch can only ever be rendered while the whole\n // row control is already readonly. The `stores` row's own `none` mismatch is different --\n // `canGrantLevel` returns `true` unconditionally for `'none'` (see `invitation-scope.ts`),\n // so it is a *legal* grant the granter could re-issue, not an unreachable one. It does not\n // trip `__hasUnreachableGrant`, and is rendered editable while the rest of the control\n // stays unlocked (pinned by this control's own test suite: \"does not lock the control\n // merely because the stores row is at its mismatched-but-grantable none\"). Either way, the\n // out-of-reach value is simply the control's value.\n const mismatchedLevel = available.includes(currentLevel) ? null : currentLevel;\n\n // Filtered from `allLevels`, not the narrowed `offerable` list: for the `stores` row,\n // `none` was removed from `offerable` above, but an invitation with no `stores_*` tokens\n // still parses its current level as `none`. Filtering from `offerable` here would drop\n // `none` from the rendered options even when it's `mismatchedLevel`, leaving the select's\n // value absent from its own option list -- the same \"current value must stay a real\n // option\" rule as the `mismatchedLevel` fallback right above, just applied one filter\n // earlier where a narrower source list can undo it.\n const renderedLevels = allLevels.filter(\n level => available.includes(level) || level === mismatchedLevel\n );\n\n const options: Option[] = renderedLevels.map(level => ({\n label: `level_${level}`,\n value: level,\n }));\n\n return html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t(`scopes.${collection}`)}\n helper-text=\"\"\n data-collection=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${options}\n .getValue=${() => currentLevel}\n .setValue=${(newValue: unknown) => {\n // The native `<select>` `summary-item` renders always has a real selection (its\n // first, disabled placeholder `<option>` aside) once a value is set, so there is no\n // \"clear\" affordance to coerce here the way the old vaadin-combo-box row needed --\n // kept anyway as the same defensive floor: there is no \"no level\" state for a row,\n // and this must never let an empty/undefined token reach the serialized scope.\n this.__setLevel(collection, ((newValue as string) || 'none') as Level);\n }}\n >\n </foxy-internal-select-control>\n `;\n }\n\n /**\n * Renders the three resendable collections' resend grants as `foxy-internal-switch-control`s,\n * one per line, in their own `foxy-internal-summary-control` -- not folded into the level\n * grid above. Resend is a secondary axis (below Full, a collection's level and its resend\n * grant are unrelated tokens -- see `parseScope`/`serializeScope`; Full includes resend, so the\n * switch then shows as on and readonly), covers only 3 of the 20\n * collections, and doesn't need the level grid's two-column treatment; keeping it as its own\n * section also means the grid's CSS (sized for 20 short rows) never has to accommodate a\n * structurally different kind of row. Renders nothing at all if the granter can't grant (and\n * the invitation doesn't already hold) any resend permission, rather than an empty section.\n */\n private __renderResendSwitches(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult | string {\n const switches = RESENDABLE.map(collection => {\n const included = selection.levels[collection] === 'full';\n const hasResend = selection.resend.includes(collection);\n const canResend = canGrantResend(grantable, collection);\n\n // Mirrors the level mismatch in `__renderLevelControl`: the invitation can already carry\n // a resend grant this granter can no longer extend themselves. Unlike the level mismatch,\n // this needs no *separate* `disabled` condition below -- `__hasUnreachableGrant` already\n // treats any resend mismatch as grounds to lock the *entire* control (see its own return\n // statement), so `mismatchedResend` and this control's own `readonly` are never true/false\n // independently of each other; adding a redundant `?disabled=` term here would only be\n // exercising `foxy-internal-switch-control`'s `disabled` -- a `ConfigurableMixin`-inferred\n // property subject to the exact same ancestor-inference-can-overwrite-a-template-binding\n // risk documented on this control's own `updated()`, for a case that can't actually occur.\n const mismatchedResend = hasResend && !canResend;\n\n return {\n collection,\n included,\n hasResend: hasResend || included,\n mismatchedResend,\n show: canResend || mismatchedResend || included,\n };\n }).filter(entry => entry.show);\n\n if (!switches.length) return '';\n\n return html`\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${switches.map(\n ({ collection, included, hasResend }) => html`\n <foxy-internal-switch-control\n infer=${included ? 'included-resend' : ''}\n label=${`${this.t('resend')} ${this.t(`scopes.${collection}`).toLowerCase()}`}\n helper-text=\"\"\n data-resend=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .getValue=${() => hasResend}\n .setValue=${(newValue: unknown) => this.__setResend(collection, !!newValue)}\n >\n </foxy-internal-switch-control>\n `\n )}\n </foxy-internal-summary-control>\n `;\n }\n\n private __setLevel(collection: string, level: Level): void {\n // Touching a row is proof the admin is actively editing in custom mode. Without this, an\n // edit that happens to make the selection match another preset (e.g. the last collection\n // reaching `read`) would make `__preset` fall back to `parseScope`'s classification and the\n // matrix would vanish out from under the admin mid-edit.\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n const crossesFull = level === 'full' || selection.levels[collection] === 'full';\n selection.levels[collection] = level;\n\n // Full includes resend, so the switch shows the same at Full with or without the token.\n // Dropping it here means leaving Full always clears resend, whichever way it was stored.\n const resend = crossesFull\n ? selection.resend.filter(entry => entry !== collection)\n : selection.resend;\n\n this._value = serializeScope({ ...selection, preset: 'custom', resend });\n }\n\n private __setResend(collection: string, checked: boolean): void {\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n\n const resend = checked\n ? [...selection.resend, collection]\n : selection.resend.filter(entry => entry !== collection);\n\n this._value = serializeScope({ ...selection, preset: 'custom', resend });\n }\n\n /**\n * The scope currently in the form. Undefined before the first edit on a new invitation.\n * An existing invitation saved without a scope grants full store access in the API, so it\n * reads as the wildcard here instead of as \"nothing chosen\".\n */\n private get __scope(): string | undefined {\n const scope = (this._value as string | undefined) ?? void 0;\n if (!scope?.trim() && this.nucleon?.data) return 'store_full_access';\n return scope;\n }\n\n private __preset(selection: Selection): Preset | null {\n if (this.__customSelected) return 'custom';\n return selection.preset;\n }\n\n private __selectPreset(preset: Preset): void {\n this.__customSelected = preset === 'custom';\n\n // Choosing Custom keeps whatever is already in the form, so the matrix opens on the\n // current grant rather than wiping it. The wildcard has no per-row levels, so it is\n // expanded into what it grants -- every collection at Full, which includes resend. Keeping\n // `store_full_access` behind rows that all read None would save a full-access invitation.\n if (preset === 'custom') {\n const selection = parseScope(this.__scope);\n if (selection.preset !== 'store') return;\n\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'full'));\n this._value = serializeScope({ ...selection, preset: 'custom' });\n return;\n }\n\n if (preset === 'store') {\n this._value = 'store_full_access';\n } else {\n const selection = parseScope('');\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'read'));\n this._value = serializeScope(selection);\n }\n }\n}\n"]}
|
|
@@ -26,7 +26,7 @@ export declare type ScopeGroups = {
|
|
|
26
26
|
full: string[];
|
|
27
27
|
/** Collections the user can read but not write. */
|
|
28
28
|
read: string[];
|
|
29
|
-
/** Collections the user can resend.
|
|
29
|
+
/** Collections the user can resend without full access. Full access includes resend. */
|
|
30
30
|
resend: string[];
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -57,12 +57,14 @@ export function groupInvitationScopes(scope) {
|
|
|
57
57
|
COLLECTIONS.forEach(collection => {
|
|
58
58
|
// A write scope satisfies a read check in the API, so write wins and the collection
|
|
59
59
|
// is never listed as read-only as well.
|
|
60
|
-
|
|
60
|
+
const hasWrite = tokens.has(`${collection}_write`);
|
|
61
|
+
if (hasWrite)
|
|
61
62
|
full.push(collection);
|
|
62
63
|
else if (tokens.has(`${collection}_read`))
|
|
63
64
|
read.push(collection);
|
|
65
|
+
// Write includes resend in the API, so a full collection is not listed again as resend.
|
|
64
66
|
const isResendable = RESENDABLE.includes(collection);
|
|
65
|
-
if (isResendable && tokens.has(`${collection}_resend`))
|
|
67
|
+
if (isResendable && !hasWrite && tokens.has(`${collection}_resend`))
|
|
66
68
|
resend.push(collection);
|
|
67
69
|
});
|
|
68
70
|
return { storeFullAccess: false, full, read, resend };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-invitation-scopes.js","sourceRoot":"","sources":["../../src/utils/group-invitation-scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO;IACP,SAAS;IACT,WAAW;IACX,0BAA0B;IAC1B,eAAe;IACf,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,WAAW;IACX,uBAAuB;IACvB,mBAAmB;IACnB,QAAQ;IACR,eAAe;IACf,uBAAuB;IACvB,OAAO;IACP,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,UAAU;CACF,CAAC;AAEX,oEAAoE;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,cAAc,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAazE;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAgC;IACpE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAErF,IAAI,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE;QACnC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;KAClE;IAED,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC/B,oFAAoF;QACpF,wCAAwC;QACxC,
|
|
1
|
+
{"version":3,"file":"group-invitation-scopes.js","sourceRoot":"","sources":["../../src/utils/group-invitation-scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiB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U,OAAO,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEjE,wFAAwF;QACxF,MAAM,YAAY,GAAI,UAAgC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC5E,IAAI,YAAY,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,SAAS,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACxD,CAAC","sourcesContent":["/**\n * Collections an invitation may grant, taken from the API's list of invitation collections minus\n * the two that are not meaningful choices.\n *\n * This list is duplicated from the API. A collection added there will be silently omitted\n * here until it is added to this array AND given a `scopes.<token>` label in every consuming\n * namespace (`user-invitation-card`, `user-invitation-form`). Rendering an unlabelled raw\n * token among humanized names looks broken, so omission is the deliberate failure mode.\n *\n * Two of the API's 22 collections are excluded on purpose -- do not \"fix\" the omission:\n *\n * - `clients`: a separate top-level resource that the Foxy admin does not manage.\n * Sign-in never issues `clients_read`/`clients_write`, so granting them would have\n * no effect.\n * - `users`: the API treats `user_full_access` as `users_read users_write`,\n * and every admin sign-in requests `user_full_access`, so a user's access here never\n * depends on their invitation. A toggle would be inert rather than merely redundant.\n */\nexport const COLLECTIONS = [\n 'carts',\n 'coupons',\n 'customers',\n 'customer_portal_settings',\n 'downloadables',\n 'gift_cards',\n 'integrations',\n 'item_categories',\n 'payment_settings',\n 'reporting',\n 'shipping_integrations',\n 'shipping_settings',\n 'stores',\n 'subscriptions',\n 'subscription_settings',\n 'taxes',\n 'templates',\n 'transactions',\n 'user_invitations',\n 'webhooks',\n] as const;\n\n/** Collections that additionally support a `_resend` permission. */\nexport const RESENDABLE = ['transactions', 'webhooks', 'taxes'] as const;\n\nexport type ScopeGroups = {\n /** `store_full_access` was present. All other tokens are ignored and the arrays are empty. */\n storeFullAccess: boolean;\n /** Collections the user can read and write. A `_write` scope implies read, per the API. */\n full: string[];\n /** Collections the user can read but not write. */\n read: string[];\n /** Collections the user can resend without full access. Full access includes resend. */\n resend: string[];\n};\n\n/**\n * Groups an invitation's space-separated `scope` string by permission level.\n *\n * Returns collection tokens rather than display labels: labels are localized, and sorting\n * by them belongs in the element that has a translation function.\n */\nexport function groupInvitationScopes(scope: string | null | undefined): ScopeGroups {\n const tokens = new Set((scope ?? '').split(/\\s+/).filter(token => token.length > 0));\n\n if (tokens.has('store_full_access')) {\n return { storeFullAccess: true, full: [], read: [], resend: [] };\n }\n\n const full: string[] = [];\n const read: string[] = [];\n const resend: string[] = [];\n\n COLLECTIONS.forEach(collection => {\n // A write scope satisfies a read check in the API, so write wins and the collection\n // is never listed as read-only as well.\n const hasWrite = tokens.has(`${collection}_write`);\n if (hasWrite) full.push(collection);\n else if (tokens.has(`${collection}_read`)) read.push(collection);\n\n // Write includes resend in the API, so a full collection is not listed again as resend.\n const isResendable = (RESENDABLE as readonly string[]).includes(collection);\n if (isResendable && !hasWrite && tokens.has(`${collection}_resend`)) resend.push(collection);\n });\n\n return { storeFullAccess: false, full, read, resend };\n}\n"]}
|
|
@@ -5,7 +5,7 @@ export declare type Selection = {
|
|
|
5
5
|
preset: 'store' | 'read' | 'custom' | null;
|
|
6
6
|
/** Level per collection, keyed by the tokens in `COLLECTIONS`. Always fully populated. */
|
|
7
7
|
levels: Record<string, Level>;
|
|
8
|
-
/** Collections with
|
|
8
|
+
/** Collections with their own `_resend` token. The API includes resend in `full`. */
|
|
9
9
|
resend: string[];
|
|
10
10
|
/**
|
|
11
11
|
* Tokens this UI does not model, carried through untouched. `client_full_access` and
|
|
@@ -63,9 +63,8 @@ export function serializeScope(selection) {
|
|
|
63
63
|
COLLECTIONS.forEach(collection => {
|
|
64
64
|
var _a;
|
|
65
65
|
const level = (_a = selection.levels[collection]) !== null && _a !== void 0 ? _a : 'none';
|
|
66
|
-
// Full emits both tokens rather than write alone
|
|
67
|
-
//
|
|
68
|
-
// read-only access to that collection — the anomaly would propagate down the chain.
|
|
66
|
+
// Full emits both tokens rather than write alone, so anything that still compares tokens
|
|
67
|
+
// literally, without write covering read, sees read access too.
|
|
69
68
|
if (level === 'full')
|
|
70
69
|
tokens.push(`${collection}_read`, `${collection}_write`);
|
|
71
70
|
else if (level === 'read')
|
|
@@ -94,14 +93,16 @@ export function canGrantLevel(grantable, collection, level) {
|
|
|
94
93
|
return true;
|
|
95
94
|
if (grantable.storeFullAccess)
|
|
96
95
|
return true;
|
|
97
|
-
const
|
|
96
|
+
const hasWrite = grantable.tokens.has(`${collection}_write`);
|
|
98
97
|
if (level === 'read')
|
|
99
|
-
return
|
|
100
|
-
return
|
|
98
|
+
return hasWrite || grantable.tokens.has(`${collection}_read`);
|
|
99
|
+
return hasWrite;
|
|
101
100
|
}
|
|
102
101
|
/** Whether the granter can give `collection` a resend grant. */
|
|
103
102
|
export function canGrantResend(grantable, collection) {
|
|
104
|
-
return grantable.storeFullAccess ||
|
|
103
|
+
return (grantable.storeFullAccess ||
|
|
104
|
+
grantable.tokens.has(`${collection}_write`) ||
|
|
105
|
+
grantable.tokens.has(`${collection}_resend`));
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* Whether the "read-only access to everything" preset can be offered.
|
|
@@ -112,8 +113,6 @@ export function canGrantResend(grantable, collection) {
|
|
|
112
113
|
* the gap.
|
|
113
114
|
*/
|
|
114
115
|
export function canGrantReadPreset(grantable) {
|
|
115
|
-
|
|
116
|
-
return true;
|
|
117
|
-
return COLLECTIONS.every(collection => grantable.tokens.has(`${collection}_read`));
|
|
116
|
+
return COLLECTIONS.every(collection => canGrantLevel(grantable, collection, 'read'));
|
|
118
117
|
}
|
|
119
118
|
//# sourceMappingURL=invitation-scope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation-scope.js","sourceRoot":"","sources":["../../src/utils/invitation-scope.ts"],"names":[],"mappings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AAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;AACtE,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,SAAoB,EAAE,UAAkB,EAAE,KAAY;IAClF,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,SAAS,CAAC,eAAe;QAAE,OAAO,IAAI,CAAC;IAE3C,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,QAAQ,CAAC,CAAC;IAC7D,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,QAAQ,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC;IAEpF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,cAAc,CAAC,SAAoB,EAAE,UAAkB;IACrE,OAAO,CACL,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,QAAQ,CAAC;QAC3C,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,SAAS,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAoB;IACrD,OAAO,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AACvF,CAAC","sourcesContent":["import { COLLECTIONS, RESENDABLE } from './group-invitation-scopes';\n\n/** Access level a single collection can be granted at. */\nexport type Level = 'none' | 'read' | 'full';\n\nexport type Selection = {\n /** `null` means nothing has been chosen yet, which the form's v8n rule rejects. */\n preset: 'store' | 'read' | 'custom' | null;\n /** Level per collection, keyed by the tokens in `COLLECTIONS`. Always fully populated. */\n levels: Record<string, Level>;\n /** Collections with their own `_resend` token. The API includes resend in `full`. */\n resend: string[];\n /**\n * Tokens this UI does not model, carried through untouched. `client_full_access` and\n * `user_full_access` are valid grants the API accepts but the matrix cannot express, so\n * dropping them on a round trip would silently revoke access the invitation already had.\n */\n extra: string[];\n};\n\nconst tokenize = (scope: string | undefined): Set<string> => {\n return new Set((scope ?? '').split(/\\s+/).filter(token => token.length > 0));\n};\n\n/** Parses an invitation's space-separated `scope` string into a UI selection. */\nexport function parseScope(scope: string | undefined): Selection {\n const tokens = tokenize(scope);\n const known = new Set<string>();\n const levels: Record<string, Level> = {};\n\n COLLECTIONS.forEach(collection => {\n const read = `${collection}_read`;\n const write = `${collection}_write`;\n\n // A write token means full access whether or not the read token is present. The API\n // treats write as implying read, so a lone write is still full access.\n if (tokens.has(write)) levels[collection] = 'full';\n else if (tokens.has(read)) levels[collection] = 'read';\n else levels[collection] = 'none';\n\n if (tokens.has(read)) known.add(read);\n if (tokens.has(write)) known.add(write);\n });\n\n const resend = RESENDABLE.filter(collection => {\n const token = `${collection}_resend`;\n if (!tokens.has(token)) return false;\n known.add(token);\n return true;\n });\n\n const isStore = tokens.has('store_full_access');\n if (isStore) known.add('store_full_access');\n\n const extra = [...tokens].filter(token => !known.has(token));\n\n let preset: Selection['preset'];\n\n if (isStore) {\n preset = 'store';\n } else if (!tokens.size) {\n preset = null;\n } else if (\n !resend.length &&\n !extra.length &&\n COLLECTIONS.every(collection => levels[collection] === 'read')\n ) {\n preset = 'read';\n } else {\n preset = 'custom';\n }\n\n return { preset, levels, resend, extra: [...extra] };\n}\n\n/** Serializes a UI selection back into a space-separated `scope` string. */\nexport function serializeScope(selection: Selection): string {\n // The store wildcard does NOT supersede `client_full_access` / `user_full_access`:\n // the API treats all three as distinct, independently-granted\n // always-allowed tokens. Dropping preserved extras here would silently revoke whichever\n // of those the invitation already held.\n if (selection.preset === 'store') return ['store_full_access', ...selection.extra].join(' ');\n\n const tokens: string[] = [];\n\n COLLECTIONS.forEach(collection => {\n const level = selection.levels[collection] ?? 'none';\n\n // Full emits both tokens rather than write alone, so anything that still compares tokens\n // literally, without write covering read, sees read access too.\n if (level === 'full') tokens.push(`${collection}_read`, `${collection}_write`);\n else if (level === 'read') tokens.push(`${collection}_read`);\n });\n\n RESENDABLE.forEach(collection => {\n if (selection.resend.includes(collection)) tokens.push(`${collection}_resend`);\n });\n\n return [...tokens, ...selection.extra].join(' ');\n}\n\n/** The granter's own scope, prepared for membership checks. */\nexport type Grantable = { storeFullAccess: boolean; tokens: Set<string> };\n\n/**\n * Prepares the granting user's scope for grantability checks.\n *\n * The server is the enforcement boundary — it rejects any\n * token the granter does not hold. These helpers exist so the UI never offers a grant that\n * would be rejected, not to implement the restriction.\n */\nexport function getGrantable(granterScope: string | undefined): Grantable {\n const tokens = tokenize(granterScope);\n return { storeFullAccess: tokens.has('store_full_access'), tokens };\n}\n\n/** Whether the granter can give `collection` at `level`. */\nexport function canGrantLevel(grantable: Grantable, collection: string, level: Level): boolean {\n if (level === 'none') return true;\n if (grantable.storeFullAccess) return true;\n\n const hasWrite = grantable.tokens.has(`${collection}_write`);\n if (level === 'read') return hasWrite || grantable.tokens.has(`${collection}_read`);\n\n return hasWrite;\n}\n\n/** Whether the granter can give `collection` a resend grant. */\nexport function canGrantResend(grantable: Grantable, collection: string): boolean {\n return (\n grantable.storeFullAccess ||\n grantable.tokens.has(`${collection}_write`) ||\n grantable.tokens.has(`${collection}_resend`)\n );\n}\n\n/**\n * Whether the \"read-only access to everything\" preset can be offered.\n *\n * It is hidden unless the granter can deliver all 20 reads. Silently redefining it as\n * \"read-only on whatever I happen to be able to share\" would make one preset mean different\n * things to different admins, which is a worse trap than an absent option — `Custom` covers\n * the gap.\n */\nexport function canGrantReadPreset(grantable: Grantable): boolean {\n return COLLECTIONS.every(collection => canGrantLevel(grantable, collection, 'read'));\n}\n"]}
|
package/dist/utils/user-scope.js
CHANGED
|
@@ -14,9 +14,9 @@ export function parseUserScope(scope) {
|
|
|
14
14
|
const canWrite = (c) => tokens.has(`${c}_write`) || (c === 'users' && tokens.has('user_full_access'));
|
|
15
15
|
return {
|
|
16
16
|
canWrite,
|
|
17
|
-
// A write scope satisfies a read check in the API.
|
|
17
|
+
// A write scope satisfies a read or resend check in the API.
|
|
18
18
|
canRead: c => canWrite(c) || tokens.has(`${c}_read`),
|
|
19
|
-
canResend: c => tokens.has(`${c}_resend`),
|
|
19
|
+
canResend: c => canWrite(c) || tokens.has(`${c}_resend`),
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-scope.js","sourceRoot":"","sources":["../../src/utils/user-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,qCAAkC;AAqBxD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgC;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACrF,IAAI,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAAE,OAAO,IAAI,CAAC;IAEjD,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CACpC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CACtF,CAAC;IACF,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAEhC,MAAM,QAAQ,GAAG,CAAC,CAAkB,EAAE,EAAE,CACtC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,CAAC,GA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AAG,CAAC,GAAW,EAAE,EAAE;QACjC,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,CAAC,UAAU,IAAI,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACtD,CAAC,CAAC;IAEF,+EAA+E;IAC/E,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;QACpD,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACnD,IAAI,IAAI,CAAC,MAAM;QAAE,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;QAC/D,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { COLLECTIONS } from './group-invitation-scopes';\n\n/** `users` is not an invitation collection, but `user_full_access` grants it. */\nexport type ScopeCollection = (typeof COLLECTIONS)[number] | 'users';\n\nexport type UserScope = {\n canRead(collection: ScopeCollection): boolean;\n canWrite(collection: ScopeCollection): boolean;\n canResend(collection: ScopeCollection): boolean;\n};\n\nexport type ScopeRule = {\n /** Control path (as used by `hiddencontrols` / `readonlycontrols`) this rule applies to. */\n path: string;\n collection: ScopeCollection;\n /** Permission required to show the control. Defaults to `read`. */\n need?: 'read' | 'write' | 'resend';\n /** Show the control, but make it readonly when the user cannot write the collection. */\n readonlyIfNoWrite?: boolean;\n};\n\n/**\n * Parses a space-separated API token scope. Returns `null` when the scope does not restrict\n * store collections (no scope, `store_full_access`, or no collection tokens), meaning the UI\n * must stay unchanged.\n */\nexport function parseUserScope(scope: string | null | undefined): UserScope | null {\n const tokens = new Set((scope ?? '').split(/\\s+/).filter(token => token.length > 0));\n if (tokens.has('store_full_access')) return null;\n\n const isStoreScoped = COLLECTIONS.some(\n c => tokens.has(`${c}_read`) || tokens.has(`${c}_write`) || tokens.has(`${c}_resend`)\n );\n if (!isStoreScoped) return null;\n\n const canWrite = (c: ScopeCollection) =>\n tokens.has(`${c}_write`) || (c === 'users' && tokens.has('user_full_access'));\n\n return {\n canWrite,\n // A write scope satisfies a read or resend check in the API.\n canRead: c => canWrite(c) || tokens.has(`${c}_read`),\n canResend: c => canWrite(c) || tokens.has(`${c}_resend`),\n };\n}\n\n/**\n * Returns `true` when the scope can read the collection, or when the scope does not restrict\n * store collections at all (unset, `store_full_access`, no collection tokens).\n */\nexport function canReadCollection(\n scope: string | null | undefined,\n collection: ScopeCollection\n): boolean {\n return parseUserScope(scope)?.canRead(collection) ?? true;\n}\n\n/** Turns scope rules into control selectors to hide or make readonly. */\nexport function getScopeSelectors(\n scope: UserScope | null,\n rules: ScopeRule[],\n own: ScopeCollection | null\n): { hidden: string[]; readonly: string[]; readonlyAll: boolean } {\n const result = { hidden: [] as string[], readonly: [] as string[], readonlyAll: false };\n if (!scope) return result;\n\n const check = { read: scope.canRead, write: scope.canWrite, resend: scope.canResend };\n\n for (const { path, collection, need = 'read', readonlyIfNoWrite } of rules) {\n if (!check[need](collection)) result.hidden.push(path);\n else if (readonlyIfNoWrite && !scope.canWrite(collection)) result.readonly.push(path);\n }\n\n // Own collection with no read access is left alone: the API's \"Access denied\" covers it.\n if (own && scope.canRead(own) && !scope.canWrite(own)) {\n result.readonlyAll = true;\n result.hidden.push('delete', 'create');\n }\n\n return result;\n}\n\n/**\n * Collection that gates a zoomed rel. A rel that is not listed (items, discounts, applied\n * taxes, attributes...) belongs to its parent, which is already readable, so it is kept.\n */\nconst ZOOM_COLLECTIONS: Record<string, ScopeCollection> = {\n applied_gift_card_codes: 'gift_cards',\n billing_addresses: 'transactions',\n cart: 'carts',\n coupon: 'coupons',\n coupon_code: 'coupons',\n customer: 'customers',\n default_billing_address: 'customers',\n default_payment_method: 'customers',\n default_shipping_address: 'customers',\n downloadable: 'downloadables',\n email_template: 'templates',\n folder: 'transactions',\n gift_card: 'gift_cards',\n gift_card_code: 'gift_cards',\n gift_card_code_logs: 'gift_cards',\n item_category: 'item_categories',\n last_transaction: 'transactions',\n original_transaction: 'transactions',\n payments: 'transactions',\n shipments: 'transactions',\n store: 'stores',\n subscription: 'subscriptions',\n tax: 'taxes',\n template_set: 'templates',\n transaction: 'transactions',\n transaction_template: 'carts',\n};\n\n/**\n * Removes the zoom paths the scope can't read from a URL. The API denies the whole request\n * when one zoomed resource can't be read. Returns the URL unchanged when the scope does not\n * restrict store collections.\n */\nexport function filterZoom(url: string, scope: string | null | undefined): string {\n const userScope = parseUserScope(scope);\n if (!userScope || !url.includes('zoom=')) return url;\n\n const parsedURL = new URL(url);\n const paths = (parsedURL.searchParams.get('zoom') ?? '').split(',').filter(Boolean);\n const isReadable = (rel: string) => {\n const collection = ZOOM_COLLECTIONS[rel];\n return !collection || userScope.canRead(collection);\n };\n\n // Keep the readable start of each path: `items:item_category` becomes `items`.\n const trimmed = paths.map(path => {\n const rels = path.split(':');\n const end = rels.findIndex(rel => !isReadable(rel));\n return end === -1 ? path : rels.slice(0, end).join(':');\n });\n\n const kept = Array.from(new Set(trimmed.filter(Boolean)));\n if (kept.join(',') === paths.join(',')) return url;\n if (kept.length) parsedURL.searchParams.set('zoom', kept.join(','));\n else parsedURL.searchParams.delete('zoom');\n\n return parsedURL.toString();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as a}from"./shared-50ef1d5a.js";async function t(t){try{return await t}catch(t){if(t instanceof Response&&await a(t))return;throw t}}export{t as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./foxy-spinner.js";import{I as e}from"./shared-20841d9c.js";customElements.define("foxy-internal-card",e);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./shared-a6b2bd14.js";import"./shared-38e0a818.js";import"./shared-8ec1b077.js";import"./shared-7b6a899b.js";import{I as e}from"./shared-be20875c.js";import{a as t}from"./shared-45649d84.js";import"./shared-c066b7fd.js";import{i as s}from"./shared-53e42a77.js";import{h as o}from"./shared-ba5c42c7.js";import{c as r,_ as n,B as i}from"./shared-8f9014ff.js";import{S as a,a as l}from"./shared-5b8c7250.js";import{v as d}from"./shared-b738ee96.js";import{c}from"./shared-4e709717.js";let h,p=e=>e;customElements.define("foxy-internal-customer-form-legal-notice-control",class extends t{renderControl(){var e,t;const r=this.nucleon;return o(h||(h=p` <p class="leading-s text-xs text-secondary"> <foxy-i18n infer="" key="text"></foxy-i18n> <a class="font-medium text-body rounded hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50" target="_blank" href="${0}" rel="noopener noreferrer"> <foxy-i18n infer="" key="link"></foxy-i18n> </a> </p> `),s(null===(t=null===(e=null==r?void 0:r.settings)||void 0===e?void 0:e.tos_checkbox_settings)||void 0===t?void 0:t.url))}});var u=r((function(e){!function(){const t=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],s=(e,s=t,o="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=e||"";s[0].minDiversity=0,s[0].minLength=0;const n=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];o&&n.push({regex:`[${o}]`,message:"symbol"});let i={};i.contains=n.filter((e=>new RegExp(`${e.regex}`).test(r))).map((e=>e.message)),i.length=r.length;let a=s.filter((e=>i.contains.length>=e.minDiversity)).filter((e=>i.length>=e.minLength)).sort(((e,t)=>t.id-e.id)).map((e=>({id:e.id,value:e.value})));return Object.assign(i,a[0]),i};e.exports={passwordStrength:s,defaultOptions:t}}()}));let m,f,_=e=>e;const g=a(l(e,"customer-form")),x=u.passwordStrength;class v extends g{constructor(){super(...arguments),this.passwordless=!1,this.settings=null,this.__passwordGeneratorOptions={checkStrength:e=>x(e).id>=2},this.__isAnonymousGetValue=()=>{var e;return!1===(null===(e=this.form)||void 0===e?void 0:e.is_anonymous)?"false":"true"},this.__isAnonymousSetValue=e=>{const t="true"===e;this.edit({is_anonymous:t}),t&&this.form.password&&this.edit({password:""}),t&&this.form.password_old&&this.edit({password_old:""}),t&&this.form.forgot_password&&this.edit({forgot_password:""})},this.__isAnonymousOptions=[{value:"true",label:"option_true"},{value:"false",label:"option_false"}],this.__refreshInterval=null}static get scopedElements(){return{"foxy-internal-customer-form-legal-notice-control":customElements.get("foxy-internal-customer-form-legal-notice-control"),"foxy-internal-radio-group-control":customElements.get("foxy-internal-radio-group-control"),"foxy-internal-timestamps-control":customElements.get("foxy-internal-timestamps-control"),"foxy-internal-password-control":customElements.get("foxy-internal-password-control"),"foxy-internal-submit-control":customElements.get("foxy-internal-submit-control"),"foxy-internal-delete-control":customElements.get("foxy-internal-delete-control"),"foxy-internal-text-control":customElements.get("foxy-internal-text-control"),"foxy-internal-undo-control":customElements.get("foxy-internal-undo-control"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-spinner":customElements.get("foxy-spinner"),"vcf-tooltip":customElements.get("vcf-tooltip"),"foxy-i18n":customElements.get("foxy-i18n"),"h-captcha":customElements.get("h-captcha"),"vaadin-button":customElements.get("vaadin-button")}}static get properties(){return n(n({},super.properties),{},{passwordless:{type:Boolean},settings:{type:Object}})}static get v8n(){return[({password:e,_links:t,is_anonymous:s=!0},o)=>!!o.passwordless||(!!(t||s||e)||"password:v8n_required"),({password_old:e,password:t,_links:s},o)=>{var r;return!s||(void 0===(null===(r=o.settings)||void 0===r?void 0:r.sign_up)||(!(t&&!e)||"password-old:v8n_required"))},({first_name:e})=>!e||e.length<=50||"first-name:v8n_too_long",({last_name:e})=>!e||e.length<=50||"last-name:v8n_too_long",({password:e})=>!e||x(e).id>=2||"password:v8n_too_weak",({password:e})=>!e||e.length<=50||"password:v8n_too_long",({tax_id:e})=>!e||e.length<=50||"tax-id:v8n_too_long",({email:e})=>e&&e.length>0||"email:v8n_required",({email:e})=>!e||e.length<=100||"email:v8n_too_long",({email:e})=>!e||d(e)||"email:v8n_invalid_email"]}get scopeCollection(){return"customers"}get hiddenSelector(){const e=new Set(super.hiddenSelector.toString().split(" "));return this.settings?(e.add("forgot-password"),e.add("is-anonymous"),this.form.password||e.add("password-old"),"none"===this.settings.tos_checkbox_settings.usage&&e.add("legal-notice")):(!1!==this.form.is_anonymous&&(e.add("forgot-password"),e.add("password")),e.add("password-old"),e.add("legal-notice")),this.href&&(e.add("is-anonymous"),e.add("legal-notice")),new i(Array.from(e).join(" ").trim())}get headerTitleOptions(){var e,t;const s=this.data;return!s||(null===(e=s.first_name)||void 0===e?void 0:e.trim())||(null===(t=s.last_name)||void 0===t?void 0:t.trim())?super.headerTitleOptions:n(n({},super.headerTitleOptions),{},{context:"no_name"})}get headerSubtitleKey(){var e;return(null===(e=this.data)||void 0===e?void 0:e.is_anonymous)?"subtitle_anonymous":"subtitle_registered"}get headerSubtitleOptions(){return n(n({},super.headerSubtitleOptions),{},{id:this.headerCopyIdValue})}disconnectedCallback(){super.disconnectedCallback();const e=this.__refreshInterval;e&&clearInterval(e)}connectedCallback(){super.connectedCallback();const e=setInterval((()=>this.requestUpdate()),6e4);this.__refreshInterval=e}renderBody(){var e,t,s,r;const n=this.hiddenSelector.matches("first-name",!0),i=this.hiddenSelector.matches("last-name",!0);return o(m||(m=_` ${0} <div class="${0}"> <foxy-internal-text-control infer="first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="last-name"></foxy-internal-text-control> </div> <foxy-internal-text-control helper-text="${0}" infer="email"> </foxy-internal-text-control> <foxy-internal-radio-group-control infer="is-anonymous" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-radio-group-control> <foxy-internal-password-control placeholder="${0}" helper-text="${0}" infer="password" show-generator .generatorOptions="${0}"> </foxy-internal-password-control> <foxy-internal-password-control infer="password-old"></foxy-internal-password-control> <foxy-internal-password-control helper-text="${0}" infer="forgot-password" show-generator> </foxy-internal-password-control> <foxy-internal-text-control infer="tax-id"></foxy-internal-text-control> <foxy-internal-customer-form-legal-notice-control infer="legal-notice"> </foxy-internal-customer-form-legal-notice-control> ${0} ${0} `),this.renderHeader(),c({"grid-cols-2":!n&&!i,hidden:n&&i,"gap-m":!0,grid:!n||!i}),this.__emailHelperText,this.__isAnonymousGetValue,this.__isAnonymousSetValue,this.__isAnonymousOptions,this.__passwordPlaceholder,this.__passwordHelperText,this.__passwordGeneratorOptions,this.__forgotPasswordHelperText,!this.data&&(null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.enabled)&&"hcaptcha"===(null===(r=null===(s=this.settings)||void 0===s?void 0:s.sign_up)||void 0===r?void 0:r.verification.type)?o(f||(f=_` <h-captcha site-key="${0}" class="hidden" size="invisible" hl="${0}" @verified="${0}"> </h-captcha> `),this.settings.sign_up.verification.site_key,this.lang,(({token:e})=>{this.edit({verification:{type:"hcaptcha",token:e}}),super.submit()})):"",super.renderBody())}submit(){var e,t,s,o,r;"hcaptcha"!==(null===(s=null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.verification)||void 0===s?void 0:s.type)||this.data?super.submit():(null===(o=this.__hcaptcha)||void 0===o||o.reset(),null===(r=this.__hcaptcha)||void 0===r||r.execute())}async _sendPatch(e){const t=await super._sendPatch(e);if(e.password){const e={key:"password_change_success",options:{email:t.email}};this.status=e}return t}async _sendGet(){return this.status=null,await super._sendGet()}async _fetch(...e){try{return await super._fetch(...e)}catch(e){let t;try{t=(await e.json())._embedded["fx:errors"][0].message}catch(t){throw e}throw"Conflict"===t||t.startsWith("This email address is already in use")?["error:email_already_used"]:t.startsWith("Customer registration is disabled")?["error:registration_disabled"]:t.startsWith("Client verification failed")?["error:verification_failed"]:t.startsWith("Provided password is incorrect")?["error:old_password_incorrect"]:e}}get __forgotPasswordHelperText(){var e,t;const s=null===(e=this.data)||void 0===e?void 0:e.forgot_password_timestamp,o="forgot-password.helper_text";if((null===(t=this.data)||void 0===t?void 0:t.forgot_password)&&s){const e=new Date(new Date(s).getTime()+18e5),t=Math.floor((e.getTime()-Date.now())/1e3/60);return t<=0?this.t(`${o}_expired_on`,{expiresOn:e}):this.t(`${o}_expires_in`,{expiresInMin:`${t}minutes`})}return this.t(o)}get __passwordPlaceholder(){return this.data?this.t("password.placeholder_new"):this.t("password.placeholder")}get __passwordHelperText(){return this.data?this.t("password.helper_text_new"):this.t("password.helper_text")}get __emailHelperText(){var e;return(null===(e=this.data)||void 0===e?void 0:e.last_login_date)?this.t("email.helper_text_last_login_date",{date:this.data.last_login_date}):this.t("email.helper_text")}get __hcaptcha(){return this.renderRoot.querySelector("h-captcha")}}customElements.define("foxy-customer-form",v);export{v as C,u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as t,c as n}from"./shared-da3393a5.js";function r(t){return(null==t?void 0:t._links["fx:cart"])?"carts":(null==t?void 0:t._links["fx:transaction"])?"transactions":null}function s(r,s,a){var i;if(!t(r))return!0;const c=t=>n(r,t),o=null!==(i=null==s?void 0:s._links)&&void 0!==i?i:{};if(o["fx:transaction"]&&c("transactions"))return!0;return!(!c("carts")||!o["fx:cart"]&&(!o["fx:subscription"]||!c("subscriptions")))&&(!(a&&!a.currency_code)||!!c("templates")&&(""!==a.template_set_uri||c("stores")))}export{s as c,r as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const s=["carts","coupons","customers","customer_portal_settings","downloadables","gift_cards","integrations","item_categories","payment_settings","reporting","shipping_integrations","shipping_settings","stores","subscriptions","subscription_settings","taxes","templates","transactions","user_invitations","webhooks"],e=["transactions","webhooks","taxes"];function t(t){const n=new Set((null!=t?t:"").split(/\s+/).filter((s=>s.length>0)));if(n.has("store_full_access"))return{storeFullAccess:!0,full:[],read:[],resend:[]};const a=[],r=[],o=[];return s.forEach((s=>{n.has(`${s}_write`)?a.push(s):n.has(`${s}_read`)&&r.push(s);e.includes(s)&&n.has(`${s}_resend`)&&o.push(s)})),{storeFullAccess:!1,full:a,read:r,resend:o}}function n(e){const t=new Set((null!=e?e:"").split(/\s+/).filter((s=>s.length>0)));if(t.has("store_full_access"))return null;if(!s.some((s=>t.has(`${s}_read`)||t.has(`${s}_write`)||t.has(`${s}_resend`))))return null;const n=s=>t.has(`${s}_write`)||"users"===s&&t.has("user_full_access");return{canWrite:n,canRead:s=>n(s)||t.has(`${s}_read`),canResend:s=>t.has(`${s}_resend`)}}function a(s,e){var t,a;return null===(a=null===(t=n(s))||void 0===t?void 0:t.canRead(e))||void 0===a||a}function r(s,e,t){const n={hidden:[],readonly:[],readonlyAll:!1};if(!s)return n;const a={read:s.canRead,write:s.canWrite,resend:s.canResend};for(const{path:t,collection:r,need:o="read",readonlyIfNoWrite:i}of e)a[o](r)?i&&!s.canWrite(r)&&n.readonly.push(t):n.hidden.push(t);return t&&s.canRead(t)&&!s.canWrite(t)&&(n.readonlyAll=!0,n.hidden.push("delete","create")),n}const o={applied_gift_card_codes:"gift_cards",billing_addresses:"transactions",cart:"carts",coupon:"coupons",coupon_code:"coupons",customer:"customers",default_billing_address:"customers",default_payment_method:"customers",default_shipping_address:"customers",downloadable:"downloadables",email_template:"templates",folder:"transactions",gift_card:"gift_cards",gift_card_code:"gift_cards",gift_card_code_logs:"gift_cards",item_category:"item_categories",last_transaction:"transactions",original_transaction:"transactions",payments:"transactions",shipments:"transactions",store:"stores",subscription:"subscriptions",tax:"taxes",template_set:"templates",transaction:"transactions",transaction_template:"carts"};function i(s,e){var t;const a=n(e);if(!a||!s.includes("zoom="))return s;const r=new URL(s),i=(null!==(t=r.searchParams.get("zoom"))&&void 0!==t?t:"").split(",").filter(Boolean),c=i.map((s=>{const e=s.split(":"),t=e.findIndex((s=>!(s=>{const e=o[s];return!e||a.canRead(e)})(s)));return-1===t?s:e.slice(0,t).join(":")})),l=Array.from(new Set(c.filter(Boolean)));return l.join(",")===i.join(",")?s:(l.length?r.searchParams.set("zoom",l.join(",")):r.searchParams.delete("zoom"),r.toString())}export{s as C,e as R,t as a,a as c,i as f,r as g,n as p};
|