@kya-os/consent 0.4.0 → 0.4.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/README.md +186 -22
- package/dist/bundle/index.d.ts +9 -0
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +13 -0
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +4 -4
- package/dist/bundle/inline.js.map +1 -1
- package/dist/cjs/bundle/index.js +36 -1
- package/dist/cjs/bundle/index.js.map +1 -1
- package/dist/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.js.map +1 -1
- package/dist/cjs/components/consent-action-bar.js +97 -25
- package/dist/cjs/components/consent-action-bar.js.map +1 -1
- package/dist/cjs/components/consent-agent-header.js +7 -105
- package/dist/cjs/components/consent-agent-header.js.map +1 -1
- package/dist/cjs/components/consent-button.js +6 -1
- package/dist/cjs/components/consent-button.js.map +1 -1
- package/dist/cjs/components/consent-capabilities-screen.js +456 -117
- package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
- package/dist/cjs/components/consent-capability-card.js +159 -32
- package/dist/cjs/components/consent-capability-card.js.map +1 -1
- package/dist/cjs/components/consent-checkbox.js +7 -0
- package/dist/cjs/components/consent-checkbox.js.map +1 -1
- package/dist/cjs/components/consent-connector-header.js +262 -45
- package/dist/cjs/components/consent-connector-header.js.map +1 -1
- package/dist/cjs/components/consent-duration.js +1 -1
- package/dist/cjs/components/consent-flow-timeline.js +177 -0
- package/dist/cjs/components/consent-flow-timeline.js.map +1 -0
- package/dist/cjs/components/consent-flow.js +540 -0
- package/dist/cjs/components/consent-flow.js.map +1 -0
- package/dist/cjs/components/consent-footer.js +22 -14
- package/dist/cjs/components/consent-footer.js.map +1 -1
- package/dist/cjs/components/consent-headline.js +353 -33
- package/dist/cjs/components/consent-headline.js.map +1 -1
- package/dist/cjs/components/consent-oauth-button.js +68 -138
- package/dist/cjs/components/consent-oauth-button.js.map +1 -1
- package/dist/cjs/components/consent-otp-input.js +5 -0
- package/dist/cjs/components/consent-otp-input.js.map +1 -1
- package/dist/cjs/components/consent-phone-handoff.js +3 -3
- package/dist/cjs/components/consent-request-expiry.js +1 -1
- package/dist/cjs/components/consent-revocation-notice.js +29 -18
- package/dist/cjs/components/consent-revocation-notice.js.map +1 -1
- package/dist/cjs/components/consent-revoke.js +9 -4
- package/dist/cjs/components/consent-revoke.js.map +1 -1
- package/dist/cjs/components/consent-secured-by.js +106 -0
- package/dist/cjs/components/consent-secured-by.js.map +1 -0
- package/dist/cjs/components/consent-shell.js +1 -1
- package/dist/cjs/components/consent-terms.js +7 -0
- package/dist/cjs/components/consent-terms.js.map +1 -1
- package/dist/cjs/components/consent-wallet-check.js +26 -2
- package/dist/cjs/components/consent-wallet-check.js.map +1 -1
- package/dist/cjs/components/consent-wallet-notice.js +1 -1
- package/dist/cjs/components/consent-wallet-orb.js +1 -1
- package/dist/cjs/components/consent-wallet-signature.js +1 -1
- package/dist/cjs/components/decision-icons.js +37 -0
- package/dist/cjs/components/decision-icons.js.map +1 -0
- package/dist/cjs/components/edit-region.js +309 -0
- package/dist/cjs/components/edit-region.js.map +1 -0
- package/dist/cjs/components/flow-blocks.js +762 -0
- package/dist/cjs/components/flow-blocks.js.map +1 -0
- package/dist/cjs/components/flow-motion.js +177 -0
- package/dist/cjs/components/flow-motion.js.map +1 -0
- package/dist/cjs/components/grant-details.js +143 -0
- package/dist/cjs/components/grant-details.js.map +1 -0
- package/dist/cjs/components/grant-field-styles.js +2 -2
- package/dist/cjs/components/index.js +13 -1
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +93 -36
- package/dist/cjs/components/mcp-consent.js.map +1 -1
- package/dist/cjs/components/preview.js +67 -0
- package/dist/cjs/components/preview.js.map +1 -0
- package/dist/cjs/components/provider-icons.js +92 -0
- package/dist/cjs/components/provider-icons.js.map +1 -0
- package/dist/cjs/constants/capabilities.js +17 -2
- package/dist/cjs/constants/capabilities.js.map +1 -1
- package/dist/cjs/copy/tokens.js +67 -24
- package/dist/cjs/copy/tokens.js.map +1 -1
- package/dist/cjs/flow/copy.js +146 -0
- package/dist/cjs/flow/copy.js.map +1 -0
- package/dist/cjs/flow/index.js +31 -0
- package/dist/cjs/flow/index.js.map +1 -0
- package/dist/cjs/flow/model.js +107 -0
- package/dist/cjs/flow/model.js.map +1 -0
- package/dist/cjs/flow/presets.js +157 -0
- package/dist/cjs/flow/presets.js.map +1 -0
- package/dist/cjs/flow/schema.js +76 -0
- package/dist/cjs/flow/schema.js.map +1 -0
- package/dist/cjs/identity/agent-identity.js +3 -2
- package/dist/cjs/identity/agent-identity.js.map +1 -1
- package/dist/cjs/mcp-app/inline.js +2 -2
- package/dist/cjs/mcp-app/inline.js.map +1 -1
- package/dist/cjs/react/index.js +40 -2
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/cjs/styles/brand.js +385 -0
- package/dist/cjs/styles/brand.js.map +1 -0
- package/dist/cjs/styles/index.js +1 -0
- package/dist/cjs/styles/index.js.map +1 -1
- package/dist/cjs/styles/theme.js +102 -30
- package/dist/cjs/styles/theme.js.map +1 -1
- package/dist/cjs/types/capabilities.types.js +1 -2
- package/dist/cjs/types/capabilities.types.js.map +1 -1
- package/dist/cjs/types/decision.types.js +13 -0
- package/dist/cjs/types/decision.types.js.map +1 -0
- package/dist/cjs/types/edit.types.js +80 -0
- package/dist/cjs/types/edit.types.js.map +1 -0
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/components/consent-action-bar.d.ts +20 -1
- package/dist/components/consent-action-bar.d.ts.map +1 -1
- package/dist/components/consent-action-bar.js +97 -25
- package/dist/components/consent-action-bar.js.map +1 -1
- package/dist/components/consent-agent-header.d.ts +4 -17
- package/dist/components/consent-agent-header.d.ts.map +1 -1
- package/dist/components/consent-agent-header.js +7 -105
- package/dist/components/consent-agent-header.js.map +1 -1
- package/dist/components/consent-button.d.ts +2 -0
- package/dist/components/consent-button.d.ts.map +1 -1
- package/dist/components/consent-button.js +6 -1
- package/dist/components/consent-button.js.map +1 -1
- package/dist/components/consent-capabilities-screen.d.ts +101 -17
- package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
- package/dist/components/consent-capabilities-screen.js +457 -118
- package/dist/components/consent-capabilities-screen.js.map +1 -1
- package/dist/components/consent-capability-card.d.ts +32 -3
- package/dist/components/consent-capability-card.d.ts.map +1 -1
- package/dist/components/consent-capability-card.js +159 -32
- package/dist/components/consent-capability-card.js.map +1 -1
- package/dist/components/consent-checkbox.d.ts +2 -0
- package/dist/components/consent-checkbox.d.ts.map +1 -1
- package/dist/components/consent-checkbox.js +7 -0
- package/dist/components/consent-checkbox.js.map +1 -1
- package/dist/components/consent-connector-header.d.ts +52 -7
- package/dist/components/consent-connector-header.d.ts.map +1 -1
- package/dist/components/consent-connector-header.js +262 -45
- package/dist/components/consent-connector-header.js.map +1 -1
- package/dist/components/consent-duration.js +1 -1
- package/dist/components/consent-flow-timeline.d.ts +49 -0
- package/dist/components/consent-flow-timeline.d.ts.map +1 -0
- package/dist/components/consent-flow-timeline.js +174 -0
- package/dist/components/consent-flow-timeline.js.map +1 -0
- package/dist/components/consent-flow.d.ts +101 -0
- package/dist/components/consent-flow.d.ts.map +1 -0
- package/dist/components/consent-flow.js +504 -0
- package/dist/components/consent-flow.js.map +1 -0
- package/dist/components/consent-footer.d.ts +6 -4
- package/dist/components/consent-footer.d.ts.map +1 -1
- package/dist/components/consent-footer.js +22 -14
- package/dist/components/consent-footer.js.map +1 -1
- package/dist/components/consent-headline.d.ts +62 -16
- package/dist/components/consent-headline.d.ts.map +1 -1
- package/dist/components/consent-headline.js +352 -34
- package/dist/components/consent-headline.js.map +1 -1
- package/dist/components/consent-oauth-button.d.ts +9 -6
- package/dist/components/consent-oauth-button.d.ts.map +1 -1
- package/dist/components/consent-oauth-button.js +71 -141
- package/dist/components/consent-oauth-button.js.map +1 -1
- package/dist/components/consent-otp-input.d.ts.map +1 -1
- package/dist/components/consent-otp-input.js +5 -0
- package/dist/components/consent-otp-input.js.map +1 -1
- package/dist/components/consent-passkey.d.ts +6 -0
- package/dist/components/consent-passkey.d.ts.map +1 -1
- package/dist/components/consent-passkey.js +67 -9
- package/dist/components/consent-passkey.js.map +1 -1
- package/dist/components/consent-phone-handoff.js +3 -3
- package/dist/components/consent-request-expiry.js +1 -1
- package/dist/components/consent-revocation-notice.d.ts.map +1 -1
- package/dist/components/consent-revocation-notice.js +29 -18
- package/dist/components/consent-revocation-notice.js.map +1 -1
- package/dist/components/consent-revoke.d.ts +2 -0
- package/dist/components/consent-revoke.d.ts.map +1 -1
- package/dist/components/consent-revoke.js +9 -4
- package/dist/components/consent-revoke.js.map +1 -1
- package/dist/components/consent-secured-by.d.ts +25 -0
- package/dist/components/consent-secured-by.d.ts.map +1 -0
- package/dist/components/consent-secured-by.js +103 -0
- package/dist/components/consent-secured-by.js.map +1 -0
- package/dist/components/consent-shell.js +1 -1
- package/dist/components/consent-terms.d.ts +2 -0
- package/dist/components/consent-terms.d.ts.map +1 -1
- package/dist/components/consent-terms.js +7 -0
- package/dist/components/consent-terms.js.map +1 -1
- package/dist/components/consent-wallet-check.d.ts +8 -0
- package/dist/components/consent-wallet-check.d.ts.map +1 -1
- package/dist/components/consent-wallet-check.js +27 -3
- package/dist/components/consent-wallet-check.js.map +1 -1
- package/dist/components/consent-wallet-notice.js +1 -1
- package/dist/components/consent-wallet-orb.js +1 -1
- package/dist/components/consent-wallet-signature.js +1 -1
- package/dist/components/decision-icons.d.ts +26 -0
- package/dist/components/decision-icons.d.ts.map +1 -0
- package/dist/components/decision-icons.js +34 -0
- package/dist/components/decision-icons.js.map +1 -0
- package/dist/components/edit-region.d.ts +50 -0
- package/dist/components/edit-region.d.ts.map +1 -0
- package/dist/components/edit-region.js +305 -0
- package/dist/components/edit-region.js.map +1 -0
- package/dist/components/flow-blocks.d.ts +45 -0
- package/dist/components/flow-blocks.d.ts.map +1 -0
- package/dist/components/flow-blocks.js +755 -0
- package/dist/components/flow-blocks.js.map +1 -0
- package/dist/components/flow-motion.d.ts +41 -0
- package/dist/components/flow-motion.d.ts.map +1 -0
- package/dist/components/flow-motion.js +164 -0
- package/dist/components/flow-motion.js.map +1 -0
- package/dist/components/grant-details.d.ts +28 -0
- package/dist/components/grant-details.d.ts.map +1 -0
- package/dist/components/grant-details.js +138 -0
- package/dist/components/grant-details.js.map +1 -0
- package/dist/components/grant-field-styles.js +2 -2
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +19 -0
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +93 -36
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/components/preview.d.ts +38 -0
- package/dist/components/preview.d.ts.map +1 -0
- package/dist/components/preview.js +61 -0
- package/dist/components/preview.js.map +1 -0
- package/dist/components/provider-icons.d.ts +16 -0
- package/dist/components/provider-icons.d.ts.map +1 -0
- package/dist/components/provider-icons.js +88 -0
- package/dist/components/provider-icons.js.map +1 -0
- package/dist/consent.js +4875 -1178
- package/dist/consent.min.js +2367 -814
- package/dist/constants/capabilities.d.ts +16 -3
- package/dist/constants/capabilities.d.ts.map +1 -1
- package/dist/constants/capabilities.js +17 -2
- package/dist/constants/capabilities.js.map +1 -1
- package/dist/copy/tokens.d.ts +67 -24
- package/dist/copy/tokens.d.ts.map +1 -1
- package/dist/copy/tokens.js +67 -24
- package/dist/copy/tokens.js.map +1 -1
- package/dist/flow/copy.d.ts +31 -0
- package/dist/flow/copy.d.ts.map +1 -0
- package/dist/flow/copy.js +137 -0
- package/dist/flow/copy.js.map +1 -0
- package/dist/flow/index.d.ts +15 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +15 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/model.d.ts +209 -0
- package/dist/flow/model.d.ts.map +1 -0
- package/dist/flow/model.js +103 -0
- package/dist/flow/model.js.map +1 -0
- package/dist/flow/presets.d.ts +29 -0
- package/dist/flow/presets.d.ts.map +1 -0
- package/dist/flow/presets.js +153 -0
- package/dist/flow/presets.js.map +1 -0
- package/dist/flow/schema.d.ts +127 -0
- package/dist/flow/schema.d.ts.map +1 -0
- package/dist/flow/schema.js +72 -0
- package/dist/flow/schema.js.map +1 -0
- package/dist/identity/agent-identity.d.ts +3 -2
- package/dist/identity/agent-identity.d.ts.map +1 -1
- package/dist/identity/agent-identity.js +3 -2
- package/dist/identity/agent-identity.js.map +1 -1
- package/dist/mcp-app/inline.d.ts.map +1 -1
- package/dist/mcp-app/inline.js +2 -2
- package/dist/mcp-app/inline.js.map +1 -1
- package/dist/react/index.d.ts +27 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +39 -1
- package/dist/react/index.js.map +1 -1
- package/dist/styles/brand.d.ts +184 -0
- package/dist/styles/brand.d.ts.map +1 -0
- package/dist/styles/brand.js +372 -0
- package/dist/styles/brand.js.map +1 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/index.js +1 -0
- package/dist/styles/index.js.map +1 -1
- package/dist/styles/theme.d.ts +76 -13
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +98 -29
- package/dist/styles/theme.js.map +1 -1
- package/dist/types/capabilities.types.d.ts +12 -14
- package/dist/types/capabilities.types.d.ts.map +1 -1
- package/dist/types/capabilities.types.js +1 -2
- package/dist/types/capabilities.types.js.map +1 -1
- package/dist/types/decision.types.d.ts +57 -0
- package/dist/types/decision.types.d.ts.map +1 -0
- package/dist/types/decision.types.js +12 -0
- package/dist/types/decision.types.js.map +1 -0
- package/dist/types/edit.types.d.ts +73 -0
- package/dist/types/edit.types.d.ts.map +1 -0
- package/dist/types/edit.types.js +76 -0
- package/dist/types/edit.types.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +10 -5
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Status, from your own check of the person's wallet:
|
|
11
11
|
*
|
|
12
|
+
* - `idle`: nothing has started yet; the dial rests, unlit (as the orb's).
|
|
12
13
|
* - `checking`: looking up this browser's wallet.
|
|
13
14
|
* - `syncing`: linking this device's wallet to the account.
|
|
14
15
|
* - `ready`: the wallet can sign.
|
|
@@ -18,6 +19,11 @@
|
|
|
18
19
|
* The orb is decoration (hidden from assistive tech); the caption is
|
|
19
20
|
* announced as it changes.
|
|
20
21
|
*
|
|
22
|
+
* Placement (`placement`): `card` (the default) puts the caption under the orb
|
|
23
|
+
* in the flow. `connector` is for the connector's `mark` slot, in place of its
|
|
24
|
+
* shield (on the capabilities screen, the `connector-mark` slot): the element
|
|
25
|
+
* is the orb's size, and the caption hangs under it on one line.
|
|
26
|
+
*
|
|
21
27
|
* Parts: `frame`, `orb` (the `consent-wallet-orb`), `caption`, and the orb's
|
|
22
28
|
* own `globe`, `dial` and `check`.
|
|
23
29
|
*
|
|
@@ -34,6 +40,8 @@ export declare class ConsentWalletCheck extends LitElement {
|
|
|
34
40
|
status: string;
|
|
35
41
|
/** Your own caption, in place of the status's. */
|
|
36
42
|
caption: string;
|
|
43
|
+
/** `card`, or `connector` in the connector's place for the shield. */
|
|
44
|
+
placement: "card" | "connector";
|
|
37
45
|
static styles: import("lit").CSSResult;
|
|
38
46
|
render(): import("lit").TemplateResult<1>;
|
|
39
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent-wallet-check.d.ts","sourceRoot":"","sources":["../../src/components/consent-wallet-check.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"consent-wallet-check.d.ts","sourceRoot":"","sources":["../../src/components/consent-wallet-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,qBACa,kBAAmB,SAAQ,UAAU;IACL,MAAM,EAAE,MAAM,CAAc;IACvE,kDAAkD;IACtB,OAAO,SAAM;IAEzC,sEAAsE;IAC3B,SAAS,EAAE,MAAM,GAAG,WAAW,CACjE;IAET,OAAgB,MAAM,0BAsCpB;IAEO,MAAM;CAgBhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,sBAAsB,EAAE,kBAAkB,CAAC;KAC5C;CACF"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Status, from your own check of the person's wallet:
|
|
11
11
|
*
|
|
12
|
+
* - `idle`: nothing has started yet; the dial rests, unlit (as the orb's).
|
|
12
13
|
* - `checking`: looking up this browser's wallet.
|
|
13
14
|
* - `syncing`: linking this device's wallet to the account.
|
|
14
15
|
* - `ready`: the wallet can sign.
|
|
@@ -18,6 +19,11 @@
|
|
|
18
19
|
* The orb is decoration (hidden from assistive tech); the caption is
|
|
19
20
|
* announced as it changes.
|
|
20
21
|
*
|
|
22
|
+
* Placement (`placement`): `card` (the default) puts the caption under the orb
|
|
23
|
+
* in the flow. `connector` is for the connector's `mark` slot, in place of its
|
|
24
|
+
* shield (on the capabilities screen, the `connector-mark` slot): the element
|
|
25
|
+
* is the orb's size, and the caption hangs under it on one line.
|
|
26
|
+
*
|
|
21
27
|
* Parts: `frame`, `orb` (the `consent-wallet-orb`), `caption`, and the orb's
|
|
22
28
|
* own `globe`, `dial` and `check`.
|
|
23
29
|
*
|
|
@@ -33,7 +39,7 @@ import { LitElement, html, css } from "lit";
|
|
|
33
39
|
import { customElement, property } from "lit/decorators.js";
|
|
34
40
|
import { CONSENT_COPY_TOKENS } from "../copy/tokens.js";
|
|
35
41
|
import "./consent-wallet-orb.js";
|
|
36
|
-
import {
|
|
42
|
+
import { readWalletOrbStatus } from "./wallet-status.js";
|
|
37
43
|
export { WALLET_CHECK_STATUSES, readWalletStatus, } from "./wallet-status.js";
|
|
38
44
|
/**
|
|
39
45
|
* Takes the orb's tokens (`--cs-wallet-orb-size`, `--cs-wallet-accent`,
|
|
@@ -45,9 +51,11 @@ let ConsentWalletCheck = class ConsentWalletCheck extends LitElement {
|
|
|
45
51
|
this.status = "checking";
|
|
46
52
|
/** Your own caption, in place of the status's. */
|
|
47
53
|
this.caption = "";
|
|
54
|
+
/** `card`, or `connector` in the connector's place for the shield. */
|
|
55
|
+
this.placement = "card";
|
|
48
56
|
}
|
|
49
57
|
render() {
|
|
50
|
-
const status =
|
|
58
|
+
const status = readWalletOrbStatus(this.status);
|
|
51
59
|
return html `
|
|
52
60
|
<div part="frame" class="frame">
|
|
53
61
|
<consent-wallet-orb
|
|
@@ -84,10 +92,23 @@ ConsentWalletCheck.styles = css `
|
|
|
84
92
|
|
|
85
93
|
.caption {
|
|
86
94
|
margin: 0;
|
|
87
|
-
color: var(--cs-text-tertiary, #
|
|
95
|
+
color: var(--cs-text-tertiary, #5d6c82);
|
|
88
96
|
font-size: 12px;
|
|
89
97
|
line-height: 1.35;
|
|
90
98
|
}
|
|
99
|
+
|
|
100
|
+
:host([placement="connector"]) .frame {
|
|
101
|
+
position: relative;
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host([placement="connector"]) .caption {
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: calc(100% + 6px);
|
|
108
|
+
left: 50%;
|
|
109
|
+
translate: -50% 0;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
}
|
|
91
112
|
`;
|
|
92
113
|
__decorate([
|
|
93
114
|
property({ type: String, reflect: true })
|
|
@@ -95,6 +116,9 @@ __decorate([
|
|
|
95
116
|
__decorate([
|
|
96
117
|
property({ type: String })
|
|
97
118
|
], ConsentWalletCheck.prototype, "caption", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: String, reflect: true })
|
|
121
|
+
], ConsentWalletCheck.prototype, "placement", void 0);
|
|
98
122
|
ConsentWalletCheck = __decorate([
|
|
99
123
|
customElement("consent-wallet-check")
|
|
100
124
|
], ConsentWalletCheck);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent-wallet-check.js","sourceRoot":"","sources":["../../src/components/consent-wallet-check.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"consent-wallet-check.js","sourceRoot":"","sources":["../../src/components/consent-wallet-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QACsC,WAAM,GAAW,UAAU,CAAC;QACvE,kDAAkD;QACtB,YAAO,GAAG,EAAE,CAAC;QAEzC,sEAAsE;QAC3B,cAAS,GAClD,MAAM,CAAC;IA0DX,CAAC;IAhBU,MAAM;QACb,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,IAAI,CAAA;;;;;;oBAMK,MAAM;;;YAGd,IAAI,CAAC,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;;;KAG/D,CAAC;IACJ,CAAC;;AAvDe,yBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsC3B,AAtCqB,CAsCpB;AA9CyC;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAA6B;AAE3C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAc;AAGE;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qDACjC;AAPE,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAiE9B"}
|
|
@@ -120,7 +120,7 @@ ConsentWalletOrb.styles = css `
|
|
|
120
120
|
.frame {
|
|
121
121
|
--_ink: var(--cs-wallet-accent, var(--cs-surface-accent, #0f172a));
|
|
122
122
|
--_success: var(--cs-wallet-success, #10b981);
|
|
123
|
-
--_muted: var(--cs-wallet-muted, var(--cs-text-tertiary, #
|
|
123
|
+
--_muted: var(--cs-wallet-muted, var(--cs-text-tertiary, #5d6c82));
|
|
124
124
|
position: relative;
|
|
125
125
|
width: 100%;
|
|
126
126
|
height: 100%;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icons the capabilities screen and a consent flow draw beside the
|
|
3
|
+
* permissions: the unverified-agent warning, a passed check, each
|
|
4
|
+
* "Permission details" row, and the flow's info, declined and granted marks.
|
|
5
|
+
* Lucide's paths (ISC), stroked in `currentColor`.
|
|
6
|
+
*
|
|
7
|
+
* @module components/decision-icons
|
|
8
|
+
*/
|
|
9
|
+
import { type SVGTemplateResult } from "lit";
|
|
10
|
+
declare const PATHS: {
|
|
11
|
+
readonly warning: import("lit").TemplateResult<2>;
|
|
12
|
+
readonly check: import("lit").TemplateResult<2>;
|
|
13
|
+
readonly resource: import("lit").TemplateResult<2>;
|
|
14
|
+
readonly duration: import("lit").TemplateResult<2>;
|
|
15
|
+
readonly budget: import("lit").TemplateResult<2>;
|
|
16
|
+
readonly amountLimits: import("lit").TemplateResult<2>;
|
|
17
|
+
readonly alreadyGranted: import("lit").TemplateResult<2>;
|
|
18
|
+
readonly info: import("lit").TemplateResult<2>;
|
|
19
|
+
readonly minus: import("lit").TemplateResult<2>;
|
|
20
|
+
readonly tick: import("lit").TemplateResult<2>;
|
|
21
|
+
};
|
|
22
|
+
export type DecisionIcon = keyof typeof PATHS;
|
|
23
|
+
/** An icon, hidden from screen readers: the words beside it carry the meaning. */
|
|
24
|
+
export declare function decisionIcon(name: DecisionIcon): SVGTemplateResult;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=decision-icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-icons.d.ts","sourceRoot":"","sources":["../../src/components/decision-icons.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAO,KAAK,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAElD,QAAA,MAAM,KAAK;;;;;;;;;;;CAWD,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,KAAK,CAAC;AAE9C,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,iBAAiB,CAUlE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icons the capabilities screen and a consent flow draw beside the
|
|
3
|
+
* permissions: the unverified-agent warning, a passed check, each
|
|
4
|
+
* "Permission details" row, and the flow's info, declined and granted marks.
|
|
5
|
+
* Lucide's paths (ISC), stroked in `currentColor`.
|
|
6
|
+
*
|
|
7
|
+
* @module components/decision-icons
|
|
8
|
+
*/
|
|
9
|
+
import { svg } from "lit";
|
|
10
|
+
const PATHS = {
|
|
11
|
+
warning: svg `<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /><path d="M12 9v4" /><path d="M12 17h.01" />`,
|
|
12
|
+
check: svg `<path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" /><path d="m9 12 2 2 4-4" />`,
|
|
13
|
+
resource: svg `<rect width="20" height="8" x="2" y="2" rx="2" ry="2" /><rect width="20" height="8" x="2" y="14" rx="2" ry="2" /><line x1="6" x2="6.01" y1="6" y2="6" /><line x1="6" x2="6.01" y1="18" y2="18" />`,
|
|
14
|
+
duration: svg `<path d="M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5" /><path d="M16 2v4" /><path d="M8 2v4" /><path d="M3 10h5" /><path d="M17.5 17.5 16 16.3V14" /><circle cx="16" cy="16" r="6" />`,
|
|
15
|
+
budget: svg `<path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1" /><path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4" />`,
|
|
16
|
+
amountLimits: svg `<rect width="20" height="14" x="2" y="5" rx="2" /><line x1="2" x2="22" y1="10" y2="10" />`,
|
|
17
|
+
alreadyGranted: svg `<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />`,
|
|
18
|
+
info: svg `<circle cx="12" cy="12" r="10" /><path d="M12 16v-4" /><path d="M12 8h.01" />`,
|
|
19
|
+
minus: svg `<path d="M5 12h14" />`,
|
|
20
|
+
tick: svg `<path d="M20 6 9 17l-5-5" />`,
|
|
21
|
+
};
|
|
22
|
+
/** An icon, hidden from screen readers: the words beside it carry the meaning. */
|
|
23
|
+
export function decisionIcon(name) {
|
|
24
|
+
return svg `<svg
|
|
25
|
+
viewBox="0 0 24 24"
|
|
26
|
+
fill="none"
|
|
27
|
+
stroke="currentColor"
|
|
28
|
+
stroke-width="2"
|
|
29
|
+
stroke-linecap="round"
|
|
30
|
+
stroke-linejoin="round"
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
>${PATHS[name]}</svg>`;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=decision-icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-icons.js","sourceRoot":"","sources":["../../src/components/decision-icons.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,GAAG,EAA0B,MAAM,KAAK,CAAC;AAElD,MAAM,KAAK,GAAG;IACZ,OAAO,EAAE,GAAG,CAAA,kIAAkI;IAC9I,KAAK,EAAE,GAAG,CAAA,wMAAwM;IAClN,QAAQ,EAAE,GAAG,CAAA,mMAAmM;IAChN,QAAQ,EAAE,GAAG,CAAA,wMAAwM;IACrN,MAAM,EAAE,GAAG,CAAA,+KAA+K;IAC1L,YAAY,EAAE,GAAG,CAAA,2FAA2F;IAC5G,cAAc,EAAE,GAAG,CAAA,6GAA6G;IAChI,IAAI,EAAE,GAAG,CAAA,+EAA+E;IACxF,KAAK,EAAE,GAAG,CAAA,uBAAuB;IACjC,IAAI,EAAE,GAAG,CAAA,8BAA8B;CAC/B,CAAC;AAIX,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,IAAkB;IAC7C,OAAO,GAAG,CAAA;;;;;;;;KAQP,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit Regions
|
|
3
|
+
*
|
|
4
|
+
* In edit mode (`preview` and `editable` together) the words a person can
|
|
5
|
+
* change are regions: leaf spans a person types into, each named by a key
|
|
6
|
+
* from `CONSENT_EDIT_KEYS`. A region never sits inside a button, and no Lit
|
|
7
|
+
* part sits inside a region, so typing cannot disturb the template.
|
|
8
|
+
*
|
|
9
|
+
* A region holds the drawn text until it has focus. Focus swaps in its raw
|
|
10
|
+
* text from `editSource` (a template with its placeholders, say) and puts the
|
|
11
|
+
* caret at the end; leaving it draws the text again. While a region has focus
|
|
12
|
+
* a render never writes into it, so a host that writes each keystroke back
|
|
13
|
+
* moves no caret. Each change sends `consent-edit` with `{ key, value }`, and
|
|
14
|
+
* leaving a changed region sends `consent-edit-end`; focus and blur with no
|
|
15
|
+
* change send nothing. Enter and Escape leave the region, every key stays in
|
|
16
|
+
* it (so no row toggle or page shortcut sees typing), paste inserts plain
|
|
17
|
+
* text on one line, and a drop is ignored. An Enter an input method takes to
|
|
18
|
+
* accept a candidate stays with the input method.
|
|
19
|
+
*
|
|
20
|
+
* @module components/edit-region
|
|
21
|
+
*/
|
|
22
|
+
import { type TemplateResult } from "lit";
|
|
23
|
+
import { Directive, type ElementPart, type PartInfo } from "lit/directive.js";
|
|
24
|
+
import { type ConsentEditKey, type ConsentEditSource } from "../types/edit.types.js";
|
|
25
|
+
/**
|
|
26
|
+
* Writes a region's drawn text, except while the region has focus: then the
|
|
27
|
+
* person's typing stays as it is, caret and all, and the text is drawn when
|
|
28
|
+
* they leave.
|
|
29
|
+
*/
|
|
30
|
+
declare class EditableTextDirective extends Directive {
|
|
31
|
+
constructor(partInfo: PartInfo);
|
|
32
|
+
render(_key: ConsentEditKey, _text: string, _source: string): unknown;
|
|
33
|
+
update(part: ElementPart, [key, text, source]: [ConsentEditKey, string, string]): unknown;
|
|
34
|
+
}
|
|
35
|
+
/** See EditableTextDirective. */
|
|
36
|
+
export declare const editableText: (_key: ConsentEditKey, _text: string, _source: string) => import("lit/directive.js").DirectiveResult<typeof EditableTextDirective>;
|
|
37
|
+
/**
|
|
38
|
+
* A region for `key`: the drawn `text`, edited as `source[key]` when the
|
|
39
|
+
* source has one. `label` is what a screen reader calls it.
|
|
40
|
+
*/
|
|
41
|
+
export declare function editRegion(key: ConsentEditKey, label: string, text: string, source: ConsentEditSource | undefined): TemplateResult;
|
|
42
|
+
/**
|
|
43
|
+
* How a region shows it can be edited. Outlines take no room, so edit mode
|
|
44
|
+
* lays out exactly as the preview does. The defaults come from the text's own
|
|
45
|
+
* color; `--cs-edit-hover-ring`, `--cs-edit-focus-ring` and `--cs-edit-wash`
|
|
46
|
+
* set them.
|
|
47
|
+
*/
|
|
48
|
+
export declare const editRegionStyles: import("lit").CSSResult;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=edit-region.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-region.d.ts","sourceRoot":"","sources":["../../src/components/edit-region.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EACL,SAAS,EAGT,KAAK,WAAW,EAChB,KAAK,QAAQ,EACd,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAyMhC;;;;GAIG;AACH,cAAM,qBAAsB,SAAQ,SAAS;gBAC/B,QAAQ,EAAE,QAAQ;IAS9B,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAI5D,MAAM,CACb,IAAI,EAAE,WAAW,EACjB,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,GACpD,OAAO;CAoBX;AAED,iCAAiC;AACjC,eAAO,MAAM,YAAY,oIAAmC,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GAAG,SAAS,GACpC,cAAc,CAmBhB;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,yBA+B5B,CAAC"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit Regions
|
|
3
|
+
*
|
|
4
|
+
* In edit mode (`preview` and `editable` together) the words a person can
|
|
5
|
+
* change are regions: leaf spans a person types into, each named by a key
|
|
6
|
+
* from `CONSENT_EDIT_KEYS`. A region never sits inside a button, and no Lit
|
|
7
|
+
* part sits inside a region, so typing cannot disturb the template.
|
|
8
|
+
*
|
|
9
|
+
* A region holds the drawn text until it has focus. Focus swaps in its raw
|
|
10
|
+
* text from `editSource` (a template with its placeholders, say) and puts the
|
|
11
|
+
* caret at the end; leaving it draws the text again. While a region has focus
|
|
12
|
+
* a render never writes into it, so a host that writes each keystroke back
|
|
13
|
+
* moves no caret. Each change sends `consent-edit` with `{ key, value }`, and
|
|
14
|
+
* leaving a changed region sends `consent-edit-end`; focus and blur with no
|
|
15
|
+
* change send nothing. Enter and Escape leave the region, every key stays in
|
|
16
|
+
* it (so no row toggle or page shortcut sees typing), paste inserts plain
|
|
17
|
+
* text on one line, and a drop is ignored. An Enter an input method takes to
|
|
18
|
+
* accept a candidate stays with the input method.
|
|
19
|
+
*
|
|
20
|
+
* @module components/edit-region
|
|
21
|
+
*/
|
|
22
|
+
import { css, html } from "lit";
|
|
23
|
+
import { Directive, directive, PartType, } from "lit/directive.js";
|
|
24
|
+
import { noChange } from "lit";
|
|
25
|
+
import { CONSENT_EDIT_EVENTS, } from "../types/edit.types.js";
|
|
26
|
+
const regions = new WeakMap();
|
|
27
|
+
/**
|
|
28
|
+
* `plaintext-only` where the browser has it, so typing and pasting make no
|
|
29
|
+
* markup; `true` elsewhere, with the paste, drop and format handlers below
|
|
30
|
+
* doing the same.
|
|
31
|
+
*/
|
|
32
|
+
let editableValue;
|
|
33
|
+
function contentEditableValue() {
|
|
34
|
+
if (editableValue)
|
|
35
|
+
return editableValue;
|
|
36
|
+
if (typeof document === "undefined")
|
|
37
|
+
return "true";
|
|
38
|
+
try {
|
|
39
|
+
const probe = document.createElement("span");
|
|
40
|
+
probe.contentEditable = "plaintext-only";
|
|
41
|
+
editableValue =
|
|
42
|
+
probe.contentEditable === "plaintext-only" ? "plaintext-only" : "true";
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Browsers without plaintext-only throw on the assignment.
|
|
46
|
+
editableValue = "true";
|
|
47
|
+
}
|
|
48
|
+
return editableValue;
|
|
49
|
+
}
|
|
50
|
+
function hasFocus(el) {
|
|
51
|
+
const root = el.getRootNode();
|
|
52
|
+
return root.activeElement === el;
|
|
53
|
+
}
|
|
54
|
+
/** A region's text as one line, with the spaces a browser keeps visible as plain spaces. */
|
|
55
|
+
function lineOf(text) {
|
|
56
|
+
return text.replace(/ /g, " ").replace(/\s*[\r\n]+\s*/g, " ");
|
|
57
|
+
}
|
|
58
|
+
function emit(el, type, detail) {
|
|
59
|
+
el.dispatchEvent(new CustomEvent(type, {
|
|
60
|
+
detail,
|
|
61
|
+
bubbles: true,
|
|
62
|
+
composed: true,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Puts the caret after the region's last character. Collapsing the document's
|
|
67
|
+
* selection reaches into a shadow root in every engine, where WebKit drops a
|
|
68
|
+
* range added there.
|
|
69
|
+
*/
|
|
70
|
+
function caretToEnd(el) {
|
|
71
|
+
el.ownerDocument.getSelection()?.collapse(el, el.childNodes.length);
|
|
72
|
+
}
|
|
73
|
+
/** Inserts plain text at the caret, through the editing commands where they work so undo keeps it. */
|
|
74
|
+
function insertPlainText(el, text) {
|
|
75
|
+
if (!text)
|
|
76
|
+
return;
|
|
77
|
+
const doc = el.ownerDocument;
|
|
78
|
+
if (typeof doc.execCommand === "function") {
|
|
79
|
+
try {
|
|
80
|
+
if (doc.execCommand("insertText", false, text))
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Fall through to inserting by hand.
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const selection = doc.getSelection();
|
|
88
|
+
if (!selection || selection.rangeCount === 0)
|
|
89
|
+
return;
|
|
90
|
+
const range = selection.getRangeAt(0);
|
|
91
|
+
if (!el.contains(range.commonAncestorContainer))
|
|
92
|
+
return;
|
|
93
|
+
range.deleteContents();
|
|
94
|
+
const node = doc.createTextNode(text);
|
|
95
|
+
range.insertNode(node);
|
|
96
|
+
range.setStartAfter(node);
|
|
97
|
+
range.collapse(true);
|
|
98
|
+
selection.removeAllRanges();
|
|
99
|
+
selection.addRange(range);
|
|
100
|
+
el.dispatchEvent(new InputEvent("input", {
|
|
101
|
+
bubbles: true,
|
|
102
|
+
composed: true,
|
|
103
|
+
inputType: "insertText",
|
|
104
|
+
data: text,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
function onPointerDown(event) {
|
|
108
|
+
const state = regions.get(event.currentTarget);
|
|
109
|
+
if (state)
|
|
110
|
+
state.pointer = true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A press on a region whose raw text differs from its drawn text would place
|
|
114
|
+
* a caret in text that changes under it on focus. The region takes the press
|
|
115
|
+
* over instead: it focuses itself, which swaps the text and puts the caret at
|
|
116
|
+
* the end.
|
|
117
|
+
*/
|
|
118
|
+
function onMouseDown(event) {
|
|
119
|
+
const el = event.currentTarget;
|
|
120
|
+
const state = regions.get(el);
|
|
121
|
+
if (!state || event.button !== 0 || hasFocus(el))
|
|
122
|
+
return;
|
|
123
|
+
if (el.textContent === state.source)
|
|
124
|
+
return;
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
state.pointer = false;
|
|
127
|
+
el.focus();
|
|
128
|
+
}
|
|
129
|
+
function onFocus(event) {
|
|
130
|
+
const el = event.currentTarget;
|
|
131
|
+
const state = regions.get(el);
|
|
132
|
+
if (!state)
|
|
133
|
+
return;
|
|
134
|
+
state.changed = false;
|
|
135
|
+
const swapped = el.textContent !== state.source;
|
|
136
|
+
if (swapped)
|
|
137
|
+
el.textContent = state.source;
|
|
138
|
+
state.value = lineOf(el.textContent ?? "");
|
|
139
|
+
// A click on drawn text that is also the raw text keeps the caret where it
|
|
140
|
+
// landed; a press that swaps the text never gets here (see onMouseDown).
|
|
141
|
+
if (swapped || !state.pointer)
|
|
142
|
+
caretToEnd(el);
|
|
143
|
+
state.pointer = false;
|
|
144
|
+
}
|
|
145
|
+
function onInput(event) {
|
|
146
|
+
const el = event.currentTarget;
|
|
147
|
+
const state = regions.get(el);
|
|
148
|
+
if (!state)
|
|
149
|
+
return;
|
|
150
|
+
// A browser keeps an emptied or replaced editing host open with a <br>,
|
|
151
|
+
// which in a one-line region would break the line.
|
|
152
|
+
for (const br of el.querySelectorAll("br"))
|
|
153
|
+
br.remove();
|
|
154
|
+
state.changed = true;
|
|
155
|
+
state.value = lineOf(el.textContent ?? "");
|
|
156
|
+
emit(el, CONSENT_EDIT_EVENTS.edit, { key: state.key, value: state.value });
|
|
157
|
+
}
|
|
158
|
+
function onBlur(event) {
|
|
159
|
+
const el = event.currentTarget;
|
|
160
|
+
const state = regions.get(el);
|
|
161
|
+
if (!state)
|
|
162
|
+
return;
|
|
163
|
+
state.pointer = false;
|
|
164
|
+
if (el.textContent !== state.text)
|
|
165
|
+
el.textContent = state.text;
|
|
166
|
+
if (!state.changed)
|
|
167
|
+
return;
|
|
168
|
+
state.changed = false;
|
|
169
|
+
emit(el, CONSENT_EDIT_EVENTS.end, { key: state.key, value: state.value });
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Whether a key belongs to an input method (IME) composing text. WebKit ends
|
|
173
|
+
* the composition before the Enter that accepts a candidate, so that Enter
|
|
174
|
+
* has `isComposing` false and only its 229 key code says the IME took it.
|
|
175
|
+
*/
|
|
176
|
+
function isImeKey(event) {
|
|
177
|
+
return event.isComposing || event.keyCode === 229;
|
|
178
|
+
}
|
|
179
|
+
function onKeyDown(event) {
|
|
180
|
+
event.stopPropagation();
|
|
181
|
+
if (isImeKey(event))
|
|
182
|
+
return;
|
|
183
|
+
if (event.key === "Enter" || event.key === "Escape") {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
event.currentTarget.blur();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** Formatting and line breaks never reach a region, whichever contenteditable value it has. */
|
|
189
|
+
function onBeforeInput(event) {
|
|
190
|
+
if (event.inputType.startsWith("format") ||
|
|
191
|
+
event.inputType === "insertParagraph" ||
|
|
192
|
+
event.inputType === "insertLineBreak") {
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function onPaste(event) {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
insertPlainText(event.currentTarget, lineOf(event.clipboardData?.getData("text/plain") ?? ""));
|
|
199
|
+
}
|
|
200
|
+
function onDrop(event) {
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Writes a region's drawn text, except while the region has focus: then the
|
|
205
|
+
* person's typing stays as it is, caret and all, and the text is drawn when
|
|
206
|
+
* they leave.
|
|
207
|
+
*/
|
|
208
|
+
class EditableTextDirective extends Directive {
|
|
209
|
+
constructor(partInfo) {
|
|
210
|
+
super(partInfo);
|
|
211
|
+
if (partInfo.type !== PartType.ELEMENT) {
|
|
212
|
+
throw new Error("editableText goes on an element, as an attribute-less binding");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
render(_key, _text, _source) {
|
|
216
|
+
return noChange;
|
|
217
|
+
}
|
|
218
|
+
update(part, [key, text, source]) {
|
|
219
|
+
const el = part.element;
|
|
220
|
+
const state = regions.get(el);
|
|
221
|
+
if (state) {
|
|
222
|
+
state.key = key;
|
|
223
|
+
state.text = text;
|
|
224
|
+
state.source = source;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
regions.set(el, {
|
|
228
|
+
key,
|
|
229
|
+
text,
|
|
230
|
+
source,
|
|
231
|
+
changed: false,
|
|
232
|
+
value: text,
|
|
233
|
+
pointer: false,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (!hasFocus(el) && el.textContent !== text)
|
|
237
|
+
el.textContent = text;
|
|
238
|
+
return noChange;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/** See EditableTextDirective. */
|
|
242
|
+
export const editableText = directive(EditableTextDirective);
|
|
243
|
+
/**
|
|
244
|
+
* A region for `key`: the drawn `text`, edited as `source[key]` when the
|
|
245
|
+
* source has one. `label` is what a screen reader calls it.
|
|
246
|
+
*/
|
|
247
|
+
export function editRegion(key, label, text, source) {
|
|
248
|
+
return html `<span
|
|
249
|
+
class="edit-region"
|
|
250
|
+
data-edit-key=${key}
|
|
251
|
+
role="textbox"
|
|
252
|
+
aria-label=${label}
|
|
253
|
+
contenteditable=${contentEditableValue()}
|
|
254
|
+
spellcheck="true"
|
|
255
|
+
${editableText(key, text, source?.[key] ?? text)}
|
|
256
|
+
@pointerdown=${onPointerDown}
|
|
257
|
+
@mousedown=${onMouseDown}
|
|
258
|
+
@focus=${onFocus}
|
|
259
|
+
@blur=${onBlur}
|
|
260
|
+
@keydown=${onKeyDown}
|
|
261
|
+
@beforeinput=${onBeforeInput}
|
|
262
|
+
@input=${onInput}
|
|
263
|
+
@paste=${onPaste}
|
|
264
|
+
@drop=${onDrop}
|
|
265
|
+
></span>`;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* How a region shows it can be edited. Outlines take no room, so edit mode
|
|
269
|
+
* lays out exactly as the preview does. The defaults come from the text's own
|
|
270
|
+
* color; `--cs-edit-hover-ring`, `--cs-edit-focus-ring` and `--cs-edit-wash`
|
|
271
|
+
* set them.
|
|
272
|
+
*/
|
|
273
|
+
export const editRegionStyles = css `
|
|
274
|
+
.edit-region {
|
|
275
|
+
cursor: text;
|
|
276
|
+
border-radius: 3px;
|
|
277
|
+
outline: 1px dashed transparent;
|
|
278
|
+
outline-offset: 2px;
|
|
279
|
+
transition:
|
|
280
|
+
outline-color 0.12s ease,
|
|
281
|
+
background-color 0.12s ease;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.edit-region:hover {
|
|
285
|
+
outline-color: var(
|
|
286
|
+
--cs-edit-hover-ring,
|
|
287
|
+
color-mix(in srgb, currentColor 45%, transparent)
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.edit-region:focus {
|
|
292
|
+
outline: 2px solid var(--cs-edit-focus-ring, currentColor);
|
|
293
|
+
background-color: var(
|
|
294
|
+
--cs-edit-wash,
|
|
295
|
+
color-mix(in srgb, currentColor 8%, transparent)
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* An emptied region keeps room for the caret and something to click. */
|
|
300
|
+
.edit-region:empty {
|
|
301
|
+
display: inline-block;
|
|
302
|
+
min-width: 1ch;
|
|
303
|
+
}
|
|
304
|
+
`;
|
|
305
|
+
//# sourceMappingURL=edit-region.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-region.js","sourceRoot":"","sources":["../../src/components/edit-region.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACrD,OAAO,EACL,SAAS,EACT,SAAS,EACT,QAAQ,GAGT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,OAAO,EACL,mBAAmB,GAIpB,MAAM,wBAAwB,CAAC;AAiBhC,MAAM,OAAO,GAAG,IAAI,OAAO,EAA4B,CAAC;AAExD;;;;GAIG;AACH,IAAI,aAAoD,CAAC;AAEzD,SAAS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;CA+BlC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow blocks
|
|
3
|
+
*
|
|
4
|
+
* The building blocks of a consent flow. Each draws one piece of the card
|
|
5
|
+
* from the request's data and the flow's copy, and nothing else: no network,
|
|
6
|
+
* no motion, no state. A step is a list of block names (`flow.steps[step]
|
|
7
|
+
* .blocks`, as `name` or `name:variant`); `<consent-flow>` puts them together
|
|
8
|
+
* and moves between steps.
|
|
9
|
+
*
|
|
10
|
+
* The package's own elements draw wherever there is one: the capability
|
|
11
|
+
* cards, the countdown, the action bar, the grant details.
|
|
12
|
+
*
|
|
13
|
+
* @module components/flow-blocks
|
|
14
|
+
*/
|
|
15
|
+
import { nothing, type TemplateResult } from "lit";
|
|
16
|
+
import type { ApprovalMethod, ConsentFlowData, FlowBlock, FlowCopy, FlowStep } from "../flow/model.js";
|
|
17
|
+
export interface BlockContext {
|
|
18
|
+
data: ConsentFlowData;
|
|
19
|
+
copy: FlowCopy;
|
|
20
|
+
step: FlowStep;
|
|
21
|
+
/** The ref's variant: `approver:granted` is the approver block's `granted`. */
|
|
22
|
+
variant?: string;
|
|
23
|
+
/** The capability ids ticked. */
|
|
24
|
+
selected: ReadonlySet<string>;
|
|
25
|
+
method: ApprovalMethod;
|
|
26
|
+
preview: boolean;
|
|
27
|
+
/** The placeholders' values: Agent, Merchant, Verb, Provider, First, Domain. */
|
|
28
|
+
values: Record<string, string | undefined>;
|
|
29
|
+
}
|
|
30
|
+
export type BlockRender = (ctx: BlockContext) => TemplateResult | typeof nothing;
|
|
31
|
+
/** The block that grows out of another as it leaves: the account chip becomes the approver box; the capabilities their receipt. */
|
|
32
|
+
export declare const BLOCK_MORPH_FROM: Partial<Record<FlowBlock, FlowBlock>>;
|
|
33
|
+
/** The placeholders' values for a request. */
|
|
34
|
+
export declare function flowValues(data: ConsentFlowData): Record<string, string | undefined>;
|
|
35
|
+
/** "Thu 07:00 CST": the viewer's own time, with its zone. */
|
|
36
|
+
export declare function whenLabel(at: number | string): string;
|
|
37
|
+
/** A person's face: their initials, with the provider's picture over them when it loads. */
|
|
38
|
+
export declare function face(name: string, identifier?: string, avatarUrl?: string, size?: "sm" | "md"): TemplateResult;
|
|
39
|
+
/** The agent's tile: its mark on white in every theme, or its initial. A name alone never earns a mark. */
|
|
40
|
+
export declare function agentTile(agent: ConsentFlowData["agent"]): TemplateResult;
|
|
41
|
+
/** Every block, by name. */
|
|
42
|
+
export declare const FLOW_BLOCK_RENDERERS: Record<FlowBlock, BlockRender>;
|
|
43
|
+
/** The blocks' own look. The card and its spacing are the flow's. */
|
|
44
|
+
export declare const flowBlockStyles: import("lit").CSSResult;
|
|
45
|
+
//# sourceMappingURL=flow-blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-blocks.d.ts","sourceRoot":"","sources":["../../src/components/flow-blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAa,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAQ9D,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAc1B,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5C;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,YAAY,KACd,cAAc,GAAG,OAA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