@internetarchive/elements 1.10.0 → 1.11.0

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.
Files changed (44) hide show
  1. package/dist/src/elements/ia-button/ia-button.d.ts +31 -0
  2. package/dist/src/elements/ia-button/ia-button.d.ts.map +1 -1
  3. package/dist/src/elements/ia-button/ia-button.js +96 -7
  4. package/dist/src/elements/ia-button/ia-button.js.map +1 -1
  5. package/dist/src/elements/ia-userlist-settings/ia-userlist-settings.d.ts +70 -0
  6. package/dist/src/elements/ia-userlist-settings/ia-userlist-settings.d.ts.map +1 -0
  7. package/dist/src/elements/ia-userlist-settings/ia-userlist-settings.js +314 -0
  8. package/dist/src/elements/ia-userlist-settings/ia-userlist-settings.js.map +1 -0
  9. package/dist/src/elements/ia-userlist-settings/mocks/mock-userlist-service.d.ts +37 -0
  10. package/dist/src/elements/ia-userlist-settings/mocks/mock-userlist-service.d.ts.map +1 -0
  11. package/dist/src/elements/ia-userlist-settings/mocks/mock-userlist-service.js +71 -0
  12. package/dist/src/elements/ia-userlist-settings/mocks/mock-userlist-service.js.map +1 -0
  13. package/dist/src/elements/ia-userlist-settings/models.d.ts +10 -0
  14. package/dist/src/elements/ia-userlist-settings/models.d.ts.map +1 -0
  15. package/dist/src/elements/ia-userlist-settings/models.js +2 -0
  16. package/dist/src/elements/ia-userlist-settings/models.js.map +1 -0
  17. package/dist/src/elements/modal-manager/ia-modal-manager-template.d.ts.map +1 -1
  18. package/dist/src/elements/modal-manager/ia-modal-manager-template.js +6 -4
  19. package/dist/src/elements/modal-manager/ia-modal-manager-template.js.map +1 -1
  20. package/dist/src/services/userlist-service/index.d.ts +5 -0
  21. package/dist/src/services/userlist-service/index.d.ts.map +1 -0
  22. package/dist/src/services/userlist-service/index.js +3 -0
  23. package/dist/src/services/userlist-service/index.js.map +1 -0
  24. package/dist/src/services/userlist-service/mocks/sample-lists-backend.d.ts +29 -0
  25. package/dist/src/services/userlist-service/mocks/sample-lists-backend.d.ts.map +1 -0
  26. package/dist/src/services/userlist-service/mocks/sample-lists-backend.js +173 -0
  27. package/dist/src/services/userlist-service/mocks/sample-lists-backend.js.map +1 -0
  28. package/dist/src/services/userlist-service/models.d.ts +51 -0
  29. package/dist/src/services/userlist-service/models.d.ts.map +1 -0
  30. package/dist/src/services/userlist-service/models.js +2 -0
  31. package/dist/src/services/userlist-service/models.js.map +1 -0
  32. package/dist/src/services/userlist-service/userlist-error.d.ts +18 -0
  33. package/dist/src/services/userlist-service/userlist-error.d.ts.map +1 -0
  34. package/dist/src/services/userlist-service/userlist-error.js +18 -0
  35. package/dist/src/services/userlist-service/userlist-error.js.map +1 -0
  36. package/dist/src/services/userlist-service/userlist-service-interface.d.ts +94 -0
  37. package/dist/src/services/userlist-service/userlist-service-interface.d.ts.map +1 -0
  38. package/dist/src/services/userlist-service/userlist-service-interface.js +2 -0
  39. package/dist/src/services/userlist-service/userlist-service-interface.js.map +1 -0
  40. package/dist/src/services/userlist-service/userlist-service.d.ts +60 -0
  41. package/dist/src/services/userlist-service/userlist-service.d.ts.map +1 -0
  42. package/dist/src/services/userlist-service/userlist-service.js +122 -0
  43. package/dist/src/services/userlist-service/userlist-service.js.map +1 -0
  44. package/package.json +1 -1
@@ -9,8 +9,31 @@ import '../ia-status-indicator/ia-status-indicator.js';
9
9
  * i.e. for an <ia-button type="submit" @click=${doSideEffects}></ia-button>,
10
10
  * whether the form is submitted via enter or by clicking the button directly, the button will always
11
11
  * run doSideEffects() and then submit the form.
12
+ *
13
+ * The inner `<button>` takes focus, so that's where its role and ARIA state
14
+ * belong. Set them with the `role`, `ariaChecked`, `ariaDisabled`,
15
+ * `ariaHasPopup`, `ariaExpanded` and `ariaBusy` properties, e.g.
16
+ * `<ia-button .role=${'menuitemcheckbox'} .ariaChecked=${'false'}>`. These
17
+ * shadow the native ARIA reflection properties, so nothing lands on the host
18
+ * and a screen reader hears the role or state once. `null`, `undefined` and
19
+ * `''` leave an attribute off; anything else, `false` included, is set as a
20
+ * string. Note:
21
+ * - A `role` or `aria-*` *attribute* written on `<ia-button>` stays on the
22
+ * host, as before, and these properties don't read it back: with
23
+ * `<ia-button aria-disabled="true">`, `ariaDisabled` is `null`.
24
+ * - Set them once `ia-button` is defined. Before that, the native setter
25
+ * writes the attribute onto the host instead.
26
+ *
27
+ * `description` becomes the inner button's accessible description, e.g.
28
+ * "List full". It isn't part of the button's name.
29
+ *
30
+ * Focus is delegated, so `focus()` on `<ia-button>` focuses the inner button.
31
+ * With `href`, the wrapping link is the first thing that can take focus, so
32
+ * it takes it instead; the ARIA properties and description stay on the
33
+ * button.
12
34
  */
13
35
  export declare class IAButton extends LitElement {
36
+ static shadowRootOptions: ShadowRootInit;
14
37
  mode: 'primary' | 'secondary' | 'danger' | 'warning' | 'disabled' | 'transparent' | 'custom' | 'link' | 'danger-link';
15
38
  loading: boolean;
16
39
  disabled: boolean;
@@ -18,9 +41,17 @@ export declare class IAButton extends LitElement {
18
41
  type: 'button' | 'submit' | 'reset';
19
42
  href?: string;
20
43
  openLinksNewTab: boolean;
44
+ role: string | null;
45
+ ariaChecked: string | null;
46
+ ariaDisabled: string | null;
47
+ ariaHasPopup: string | null;
48
+ ariaExpanded: string | null;
49
+ ariaBusy: string | null;
50
+ description: string;
21
51
  render(): TemplateResult;
22
52
  protected willUpdate(changed: PropertyValues): void;
23
53
  private get buttonTemplate();
54
+ private get descriptionTemplate();
24
55
  private get buttonTextTemplate();
25
56
  private get loadingStateTemplate();
26
57
  /** Sets up or removes button type emulation as needed */
@@ -1 +1 @@
1
- {"version":3,"file":"ia-button.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-button/ia-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,cAAc,EACd,cAAc,EAEd,cAAc,EAEf,MAAM,KAAK,CAAC;AAKb,OAAO,4CAA4C,CAAC;AAEpD;;;;;;;;;GASG;AACH,qBACa,QAAS,SAAQ,UAAU;IAEV,IAAI,EAC5B,SAAS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W,EAAE,MAAM,CAAM;IAGV,IAAI,EAC3C,QAAQ,GACR,QAAQ,GACR,OAAO,CAAY;IAGK,IAAI,CAAC,EAAE,MAAM,CAAC;IAGb,eAAe,EAAE,OAAO,CAAS;IAM9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAElC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEnC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEnC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEnC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAGnC,WAAW,EAAE,MAAM,CAAM;IAErD,MAAM,IAAI,cAAc;IAexB,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAOnD,OAAO,KAAK,cAAc,GAezB;IAOD,OAAO,KAAK,mBAAmB,GAG9B;IAGD,OAAO,KAAK,kBAAkB,GAE7B;IAGD,OAAO,KAAK,oBAAoB,GAO/B;IAED,yDAAyD;IACzD,OAAO,CAAC,sBAAsB;IAc9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAevB,sFAAsF;IACtF,OAAO,CAAC,iBAAiB;IAwBzB,MAAM,KAAK,MAAM,IAAI,cAAc,CAkNlC;CACF"}
@@ -1,9 +1,19 @@
1
1
  import { __decorate } from "tslib";
2
- import { html, LitElement, css, render, } from 'lit';
2
+ import { html, LitElement, css, nothing, render, } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
4
  import { customElement } from '../../utils/custom-element.js';
5
5
  import themeStyles from '../../themes/theme-styles.js';
6
6
  import '../ia-status-indicator/ia-status-indicator.js';
7
+ /**
8
+ * An ARIA property's value as an attribute value. `null`, `undefined` and `''`
9
+ * leave the attribute off. Anything else, a boolean `false` from an untyped
10
+ * binding included, is stringified, so `aria-expanded` can still say "false".
11
+ */
12
+ function ariaValue(value) {
13
+ return value === null || value === undefined || value === ''
14
+ ? nothing
15
+ : String(value);
16
+ }
7
17
  /**
8
18
  * Renders a standardized button built off the ia-button styling and the activity indicator, with the option to show
9
19
  * a loading indicator instead of the text or to customize the text, and the ability to pass in any
@@ -13,6 +23,28 @@ import '../ia-status-indicator/ia-status-indicator.js';
13
23
  * i.e. for an <ia-button type="submit" @click=${doSideEffects}></ia-button>,
14
24
  * whether the form is submitted via enter or by clicking the button directly, the button will always
15
25
  * run doSideEffects() and then submit the form.
26
+ *
27
+ * The inner `<button>` takes focus, so that's where its role and ARIA state
28
+ * belong. Set them with the `role`, `ariaChecked`, `ariaDisabled`,
29
+ * `ariaHasPopup`, `ariaExpanded` and `ariaBusy` properties, e.g.
30
+ * `<ia-button .role=${'menuitemcheckbox'} .ariaChecked=${'false'}>`. These
31
+ * shadow the native ARIA reflection properties, so nothing lands on the host
32
+ * and a screen reader hears the role or state once. `null`, `undefined` and
33
+ * `''` leave an attribute off; anything else, `false` included, is set as a
34
+ * string. Note:
35
+ * - A `role` or `aria-*` *attribute* written on `<ia-button>` stays on the
36
+ * host, as before, and these properties don't read it back: with
37
+ * `<ia-button aria-disabled="true">`, `ariaDisabled` is `null`.
38
+ * - Set them once `ia-button` is defined. Before that, the native setter
39
+ * writes the attribute onto the host instead.
40
+ *
41
+ * `description` becomes the inner button's accessible description, e.g.
42
+ * "List full". It isn't part of the button's name.
43
+ *
44
+ * Focus is delegated, so `focus()` on `<ia-button>` focuses the inner button.
45
+ * With `href`, the wrapping link is the first thing that can take focus, so
46
+ * it takes it instead; the ARIA properties and description stay on the
47
+ * button.
16
48
  */
17
49
  let IAButton = class IAButton extends LitElement {
18
50
  constructor() {
@@ -29,17 +61,32 @@ let IAButton = class IAButton extends LitElement {
29
61
  this.type = 'button';
30
62
  /* Whether to add a target="_blank" to any wrapping link */
31
63
  this.openLinksNewTab = false;
64
+ /*
65
+ * Role and ARIA state for the inner button. Property-only (no attribute), so
66
+ * the host doesn't expose them too. See the class comment.
67
+ */
68
+ this.role = null;
69
+ this.ariaChecked = null;
70
+ this.ariaDisabled = null;
71
+ this.ariaHasPopup = null;
72
+ this.ariaExpanded = null;
73
+ this.ariaBusy = null;
74
+ /* The inner button's accessible description, e.g. "List full" */
75
+ this.description = '';
32
76
  }
33
77
  render() {
34
78
  // No whitespace between the top-level nodes: a text node in the shadow
35
79
  // root renders as a space when the host is display:inline.
36
- return html `${this.href
80
+ const control = this.href
37
81
  ? html `<a
38
- href=${this.href}
39
- target=${this.openLinksNewTab ? '_blank' : '_self'}
40
- >${this.buttonTemplate}</a
41
- >`
42
- : this.buttonTemplate}<slot name="hidden-button"></slot>`;
82
+ href=${this.href}
83
+ target=${this.openLinksNewTab ? '_blank' : '_self'}
84
+ >${this.buttonTemplate}</a
85
+ >`
86
+ : this.buttonTemplate;
87
+ return html `${control}${this.descriptionTemplate}<slot
88
+ name="hidden-button"
89
+ ></slot>`;
43
90
  }
44
91
  willUpdate(changed) {
45
92
  if (changed.has('type')) {
@@ -52,10 +99,27 @@ let IAButton = class IAButton extends LitElement {
52
99
  part="button"
53
100
  class=${this.mode}
54
101
  ?disabled=${this.disabled || this.loading}
102
+ role=${ariaValue(this.role)}
103
+ aria-checked=${ariaValue(this.ariaChecked)}
104
+ aria-disabled=${ariaValue(this.ariaDisabled)}
105
+ aria-haspopup=${ariaValue(this.ariaHasPopup)}
106
+ aria-expanded=${ariaValue(this.ariaExpanded)}
107
+ aria-busy=${ariaValue(this.ariaBusy)}
108
+ aria-describedby=${this.description ? 'description' : nothing}
55
109
  >
56
110
  ${this.buttonTextTemplate}
57
111
  </button>`;
58
112
  }
113
+ /*
114
+ * The description, in the shadow root because aria-describedby can't point
115
+ * across it. Outside the button, so it isn't part of the button's name, and
116
+ * hidden, since aria-describedby still reads a hidden element.
117
+ */
118
+ get descriptionTemplate() {
119
+ if (!this.description)
120
+ return nothing;
121
+ return html `<span id="description" hidden>${this.description}</span>`;
122
+ }
59
123
  /* The text to render within the button */
60
124
  get buttonTextTemplate() {
61
125
  return this.loading ? this.loadingStateTemplate : html `<slot></slot>`;
@@ -347,6 +411,10 @@ let IAButton = class IAButton extends LitElement {
347
411
  ];
348
412
  }
349
413
  };
414
+ IAButton.shadowRootOptions = {
415
+ ...LitElement.shadowRootOptions,
416
+ delegatesFocus: true,
417
+ };
350
418
  __decorate([
351
419
  property({ type: String })
352
420
  ], IAButton.prototype, "mode", void 0);
@@ -368,6 +436,27 @@ __decorate([
368
436
  __decorate([
369
437
  property({ type: Boolean })
370
438
  ], IAButton.prototype, "openLinksNewTab", void 0);
439
+ __decorate([
440
+ property({ attribute: false })
441
+ ], IAButton.prototype, "role", void 0);
442
+ __decorate([
443
+ property({ attribute: false })
444
+ ], IAButton.prototype, "ariaChecked", void 0);
445
+ __decorate([
446
+ property({ attribute: false })
447
+ ], IAButton.prototype, "ariaDisabled", void 0);
448
+ __decorate([
449
+ property({ attribute: false })
450
+ ], IAButton.prototype, "ariaHasPopup", void 0);
451
+ __decorate([
452
+ property({ attribute: false })
453
+ ], IAButton.prototype, "ariaExpanded", void 0);
454
+ __decorate([
455
+ property({ attribute: false })
456
+ ], IAButton.prototype, "ariaBusy", void 0);
457
+ __decorate([
458
+ property({ type: String })
459
+ ], IAButton.prototype, "description", void 0);
371
460
  IAButton = __decorate([
372
461
  customElement('ia-button')
373
462
  ], IAButton);
@@ -1 +1 @@
1
- {"version":3,"file":"ia-button.js","sourceRoot":"","sources":["../../../../src/elements/ia-button/ia-button.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EAGV,GAAG,EAEH,MAAM,GACP,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,4CAA4C,CAAC;AAEpD;;;;;;;;;GASG;AAEI,I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E,OAAO;QAEtC,kDAAkD;QAClD,wDAAwD;QACxD,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,EAAE,CAAC,CACtE,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6MF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAlX6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCASG;AAGD;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAA0B;AAGzB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAA2B;AAG3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAA0B;AAGV;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAGnB;AAGK;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCAAe;AAGb;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAkC;AAhCnD,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAoXpB","sourcesContent":["import {\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n css,\n PropertyValues,\n render,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport themeStyles from '@src/themes/theme-styles';\n\nimport '../ia-status-indicator/ia-status-indicator';\n\n/**\n * Renders a standardized button built off the ia-button styling and the activity indicator, with the option to show\n * a loading indicator instead of the text or to customize the text, and the ability to pass in any\n * function to run on click.\n *\n * Designed to behave exactly like a native type=\"submit\" or type=\"reset\" button if either type is supplied,\n * i.e. for an <ia-button type=\"submit\" @click=${doSideEffects}></ia-button>,\n * whether the form is submitted via enter or by clicking the button directly, the button will always\n * run doSideEffects() and then submit the form.\n */\n@customElement('ia-button')\nexport class IAButton extends LitElement {\n /* Which version of the button to display */\n @property({ type: String }) mode:\n | 'primary'\n | 'secondary'\n | 'danger'\n | 'warning'\n | 'disabled'\n | 'transparent'\n | 'custom'\n | 'link'\n | 'danger-link' = 'primary';\n\n /* Whether to show a loading indicator instead of the button */\n @property({ type: Boolean }) loading: boolean = false;\n\n /* Whether the button should be disabled, regardless of submission status */\n @property({ type: Boolean }) disabled: boolean = false;\n\n /* Optional text to include next to the loading indicator */\n @property({ type: String }) loadingText: string = '';\n\n /* Type of the button - defaults to 'button' to prevent form submission */\n @property({ type: String, reflect: true }) type:\n | 'button'\n | 'submit'\n | 'reset' = 'button';\n\n /* An optional href to wrap around the button */\n @property({ type: String }) href?: string;\n\n /* Whether to add a target=\"_blank\" to any wrapping link */\n @property({ type: Boolean }) openLinksNewTab: boolean = false;\n\n render(): TemplateResult {\n // No whitespace between the top-level nodes: a text node in the shadow\n // root renders as a space when the host is display:inline.\n return html`${this.href\n ? html`<a\n href=${this.href}\n target=${this.openLinksNewTab ? '_blank' : '_self'}\n >${this.buttonTemplate}</a\n >`\n : this.buttonTemplate}<slot name=\"hidden-button\"></slot>`;\n }\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('type')) {\n this.setButtonTypeEmulation();\n }\n }\n\n /* The native button to render */\n private get buttonTemplate(): TemplateResult {\n return html`<button\n part=\"button\"\n class=${this.mode}\n ?disabled=${this.disabled || this.loading}\n >\n ${this.buttonTextTemplate}\n </button>`;\n }\n\n /* The text to render within the button */\n private get buttonTextTemplate(): TemplateResult {\n return this.loading ? this.loadingStateTemplate : html`<slot></slot>`;\n }\n\n /* Content to render while button is loading */\n private get loadingStateTemplate(): TemplateResult {\n return html`\n <span class=\"loading-indicator\" alt=\"Loading indicator\">\n <ia-status-indicator mode=\"loading\"></ia-status-indicator> ${this\n .loadingText}\n </span>\n `;\n }\n\n /** Sets up or removes button type emulation as needed */\n private setButtonTypeEmulation(): void {\n const hiddenButton: HTMLInputElement | null = this.querySelector(\n 'input.hidden-button',\n );\n\n if (hiddenButton) {\n hiddenButton.type = this.type;\n return;\n }\n\n this.addHiddenButton();\n this.addEventListener('click', this.handleComponentClick);\n }\n\n /**\n * Triggers form actions (submit/reset) on click, if desired\n * and if actions not already in progress\n */\n private handleComponentClick(e: Event): void {\n if (this.type === 'button') return;\n\n // No need to submit/reset the form if it's already submitting/resetting\n const formActionsInProgress =\n e instanceof CustomEvent && e.detail.formActionsInProgress;\n if (formActionsInProgress) return;\n\n // Request form submission/reset by clicking the hidden native submit/reset button we added earlier\n const hiddenButton = this.querySelector(\n 'input.hidden-button',\n ) as HTMLInputElement;\n hiddenButton.dispatchEvent(new PointerEvent('click'));\n }\n\n /**\n * Adds a hidden button to the light DOM to\n * emulate native reset/submit button behavior.\n *\n * Used for:\n * - Submitting/resetting the form (on behalf of handleComponentClick)\n * - Activating any component click events if form is submitted with the enter key\n * (via handleFormActions)\n */\n private addHiddenButton(): void {\n if (this.type === 'button') return;\n\n render(\n html`<input\n type=${this.type}\n class=\"hidden-button\"\n style=\"display:none\"\n slot=\"hidden-button\"\n @click=${(e: Event) => this.handleFormActions(e)}\n />`,\n this,\n );\n }\n\n /** Triggers the component's click event manually to prevent extra submission/reset */\n private handleFormActions(e: Event): void {\n /**\n * Prevents the event from bubbling up to the ia-button component itself.\n * This way, if the click on this button is triggered by a click on the component,\n * we don't accidentally bubble up a second click and end up in an infinite loop.\n *\n * And if the click was triggered by form submission (via the enter key), we can hijack the click\n * event to pass that info to the component, so it knows not to\n * re-attempt submission.\n */\n e.stopPropagation();\n\n // Detect if click comes from the parent component,\n // in which case there's no need to trigger a second click on it\n const triggeredByComponentClick = !e.isTrusted;\n if (triggeredByComponentClick) return;\n\n // Trigger parent component click events manually,\n // so it knows not to try to re-submit/re-reset the form\n this.dispatchEvent(\n new CustomEvent('click', { detail: { formActionsInProgress: true } }),\n );\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --primary-cta-text-color--: var(--primary-cta-text-color);\n --primary-cta-fill--: var(--primary-cta-fill);\n --primary-cta-border--: var(--primary-cta-border);\n\n --secondary-cta-text-color--: var(--secondary-cta-text-color);\n --secondary-cta-fill--: var(--secondary-cta-fill);\n --secondary-cta-border--: var(--secondary-cta-border);\n\n --danger-cta-text-color--: var(--danger-cta-text-color);\n --danger-cta-fill--: var(--danger-cta-fill);\n --danger-cta-border--: var(--danger-cta-border);\n\n --warning-cta-text-color--: var(--warning-cta-text-color);\n --warning-cta-fill--: var(--warning-cta-fill);\n --warning-cta-border--: var(--warning-cta-border);\n\n --disabled-cta-text-color--: var(--disabled-cta-text-color);\n --disabled-cta-fill--: var(--disabled-cta-fill);\n --disabled-cta-border--: var(--disabled-cta-border);\n\n --link-color--: var(--link-color);\n --color-danger--: var(--color-danger);\n\n --button-padding--: var(--button-padding);\n --button-width--: var(--button-width);\n --button-height--: var(--button-height);\n --button-border-width--: var(--button-border-width);\n --button-border-radius--: var(--button-border-radius);\n --base-font-family--: var(--base-font-family);\n --font-size-standard--: var(--font-size-standard);\n\n --ia-button-transition--: var(\n --ia-button-transition,\n all 0.1s ease 0s\n );\n\n --ia-button-custom-text-color--: var(\n --ia-button-custom-text-color,\n var(--primary-cta-text-color--)\n );\n --ia-button-custom-fill--: var(\n --ia-button-custom-fill,\n var(--primary-cta-fill--)\n );\n --ia-button-custom-border--: var(\n --ia-button-custom-border,\n var(--primary-cta-border--)\n );\n --ia-button-custom-active-text-color--: var(\n --ia-button-custom-active-text-color,\n var(--ia-button-custom-text-color--)\n );\n --ia-button-custom-active-fill--: var(\n --ia-button-custom-active-fill,\n var(--ia-button-custom-fill--)\n );\n --ia-button-custom-active-border--: var(\n --ia-button-custom-active-border,\n var(--ia-button-custom-border--)\n );\n\n display: inline-block; /* keeps host sized to button */\n }\n\n button {\n font-family: var(--base-font-family--);\n font-size: var(--font-size-standard--);\n height: var(--button-height--);\n min-height: var(--button-height--);\n width: var(--button-width--);\n padding: var(--button-padding--);\n border-width: var(--button-border-width--);\n border-radius: var(--button-border-radius--);\n transition: var(--ia-button-transition--);\n\n outline-color: currentColor;\n cursor: pointer;\n line-height: normal;\n border-style: solid;\n white-space: nowrap;\n appearance: auto;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n vertical-align: middle;\n outline-offset: -4px;\n user-select: none;\n text-decoration: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n -o-user-select: none;\n }\n\n a {\n text-decoration: none;\n }\n\n button:disabled,\n button.disabled {\n cursor: not-allowed;\n color: var(--disabled-cta-text-color--);\n background-color: var(--disabled-cta-fill--);\n border: 1px solid var(--disabled-cta-border--);\n opacity: 0.5;\n }\n\n button:enabled:hover {\n opacity: 0.9;\n }\n\n button:focus-visible {\n opacity: 0.8;\n outline-style: double;\n }\n\n button:active {\n opacity: 0.7;\n }\n\n button.primary {\n color: var(--primary-cta-text-color--);\n background-color: var(--primary-cta-fill--);\n border-color: var(--primary-cta-border--);\n }\n\n button.secondary {\n color: var(--secondary-cta-text-color--);\n background-color: var(--secondary-cta-fill--);\n border-color: var(--secondary-cta-border--);\n }\n\n button.danger {\n color: var(--danger-cta-text-color--);\n background-color: var(--danger-cta-fill--);\n border-color: var(--danger-cta-border--);\n }\n\n button.warning {\n color: var(--warning-cta-text-color--);\n background-color: var(--warning-cta-fill--);\n border-color: var(--warning-cta-border--);\n }\n\n button.transparent {\n color: inherit;\n border-width: 0;\n background-color: transparent;\n border-color: transparent;\n }\n\n button.custom {\n color: var(--ia-button-custom-text-color--);\n background-color: var(--ia-button-custom-fill--);\n border-color: var(--ia-button-custom-border--);\n }\n\n button.custom:enabled:is(:hover, :focus, :active, .active) {\n color: var(--ia-button-custom-active-text-color--);\n background-color: var(--ia-button-custom-active-fill--);\n border-color: var(--ia-button-custom-active-border--);\n }\n\n :host(.fit-content) button {\n padding: 0;\n height: fit-content;\n }\n\n button.link:enabled:hover,\n button.danger-link:enabled:hover {\n text-decoration: underline;\n }\n\n button.link,\n button.danger-link {\n margin: 0;\n border: 0;\n appearance: none;\n background: none;\n text-decoration: none;\n cursor: pointer;\n padding: 0;\n }\n\n button.link {\n color: var(--link-color--);\n }\n\n button.danger-link {\n color: var(--color-danger--);\n }\n\n .loading-indicator {\n display: flex;\n flex-direction: row;\n gap: 0.5rem;\n align-items: center;\n }\n\n ia-status-indicator {\n --ia-theme-primary-text-color: currentColor;\n }\n `,\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"ia-button.js","sourceRoot":"","sources":["../../../../src/elements/ia-button/ia-button.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EAGV,GAAG,EACH,OAAO,EAEP,MAAM,GACP,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,4CAA4C,CAAC;AAEpD;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;QAC1D,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEI,IAAM,QAA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CAA0B;AAxD1C,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAgapB","sourcesContent":["import {\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n css,\n nothing,\n PropertyValues,\n render,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport themeStyles from '@src/themes/theme-styles';\n\nimport '../ia-status-indicator/ia-status-indicator';\n\n/**\n * An ARIA property's value as an attribute value. `null`, `undefined` and `''`\n * leave the attribute off. Anything else, a boolean `false` from an untyped\n * binding included, is stringified, so `aria-expanded` can still say \"false\".\n */\nfunction ariaValue(value: unknown): string | typeof nothing {\n return value === null || value === undefined || value === ''\n ? nothing\n : String(value);\n}\n\n/**\n * Renders a standardized button built off the ia-button styling and the activity indicator, with the option to show\n * a loading indicator instead of the text or to customize the text, and the ability to pass in any\n * function to run on click.\n *\n * Designed to behave exactly like a native type=\"submit\" or type=\"reset\" button if either type is supplied,\n * i.e. for an <ia-button type=\"submit\" @click=${doSideEffects}></ia-button>,\n * whether the form is submitted via enter or by clicking the button directly, the button will always\n * run doSideEffects() and then submit the form.\n *\n * The inner `<button>` takes focus, so that's where its role and ARIA state\n * belong. Set them with the `role`, `ariaChecked`, `ariaDisabled`,\n * `ariaHasPopup`, `ariaExpanded` and `ariaBusy` properties, e.g.\n * `<ia-button .role=${'menuitemcheckbox'} .ariaChecked=${'false'}>`. These\n * shadow the native ARIA reflection properties, so nothing lands on the host\n * and a screen reader hears the role or state once. `null`, `undefined` and\n * `''` leave an attribute off; anything else, `false` included, is set as a\n * string. Note:\n * - A `role` or `aria-*` *attribute* written on `<ia-button>` stays on the\n * host, as before, and these properties don't read it back: with\n * `<ia-button aria-disabled=\"true\">`, `ariaDisabled` is `null`.\n * - Set them once `ia-button` is defined. Before that, the native setter\n * writes the attribute onto the host instead.\n *\n * `description` becomes the inner button's accessible description, e.g.\n * \"List full\". It isn't part of the button's name.\n *\n * Focus is delegated, so `focus()` on `<ia-button>` focuses the inner button.\n * With `href`, the wrapping link is the first thing that can take focus, so\n * it takes it instead; the ARIA properties and description stay on the\n * button.\n */\n@customElement('ia-button')\nexport class IAButton extends LitElement {\n static shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /* Which version of the button to display */\n @property({ type: String }) mode:\n | 'primary'\n | 'secondary'\n | 'danger'\n | 'warning'\n | 'disabled'\n | 'transparent'\n | 'custom'\n | 'link'\n | 'danger-link' = 'primary';\n\n /* Whether to show a loading indicator instead of the button */\n @property({ type: Boolean }) loading: boolean = false;\n\n /* Whether the button should be disabled, regardless of submission status */\n @property({ type: Boolean }) disabled: boolean = false;\n\n /* Optional text to include next to the loading indicator */\n @property({ type: String }) loadingText: string = '';\n\n /* Type of the button - defaults to 'button' to prevent form submission */\n @property({ type: String, reflect: true }) type:\n | 'button'\n | 'submit'\n | 'reset' = 'button';\n\n /* An optional href to wrap around the button */\n @property({ type: String }) href?: string;\n\n /* Whether to add a target=\"_blank\" to any wrapping link */\n @property({ type: Boolean }) openLinksNewTab: boolean = false;\n\n /*\n * Role and ARIA state for the inner button. Property-only (no attribute), so\n * the host doesn't expose them too. See the class comment.\n */\n @property({ attribute: false }) role: string | null = null;\n\n @property({ attribute: false }) ariaChecked: string | null = null;\n\n @property({ attribute: false }) ariaDisabled: string | null = null;\n\n @property({ attribute: false }) ariaHasPopup: string | null = null;\n\n @property({ attribute: false }) ariaExpanded: string | null = null;\n\n @property({ attribute: false }) ariaBusy: string | null = null;\n\n /* The inner button's accessible description, e.g. \"List full\" */\n @property({ type: String }) description: string = '';\n\n render(): TemplateResult {\n // No whitespace between the top-level nodes: a text node in the shadow\n // root renders as a space when the host is display:inline.\n const control = this.href\n ? html`<a\n href=${this.href}\n target=${this.openLinksNewTab ? '_blank' : '_self'}\n >${this.buttonTemplate}</a\n >`\n : this.buttonTemplate;\n return html`${control}${this.descriptionTemplate}<slot\n name=\"hidden-button\"\n ></slot>`;\n }\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('type')) {\n this.setButtonTypeEmulation();\n }\n }\n\n /* The native button to render */\n private get buttonTemplate(): TemplateResult {\n return html`<button\n part=\"button\"\n class=${this.mode}\n ?disabled=${this.disabled || this.loading}\n role=${ariaValue(this.role)}\n aria-checked=${ariaValue(this.ariaChecked)}\n aria-disabled=${ariaValue(this.ariaDisabled)}\n aria-haspopup=${ariaValue(this.ariaHasPopup)}\n aria-expanded=${ariaValue(this.ariaExpanded)}\n aria-busy=${ariaValue(this.ariaBusy)}\n aria-describedby=${this.description ? 'description' : nothing}\n >\n ${this.buttonTextTemplate}\n </button>`;\n }\n\n /*\n * The description, in the shadow root because aria-describedby can't point\n * across it. Outside the button, so it isn't part of the button's name, and\n * hidden, since aria-describedby still reads a hidden element.\n */\n private get descriptionTemplate(): TemplateResult | typeof nothing {\n if (!this.description) return nothing;\n return html`<span id=\"description\" hidden>${this.description}</span>`;\n }\n\n /* The text to render within the button */\n private get buttonTextTemplate(): TemplateResult {\n return this.loading ? this.loadingStateTemplate : html`<slot></slot>`;\n }\n\n /* Content to render while button is loading */\n private get loadingStateTemplate(): TemplateResult {\n return html`\n <span class=\"loading-indicator\" alt=\"Loading indicator\">\n <ia-status-indicator mode=\"loading\"></ia-status-indicator> ${this\n .loadingText}\n </span>\n `;\n }\n\n /** Sets up or removes button type emulation as needed */\n private setButtonTypeEmulation(): void {\n const hiddenButton: HTMLInputElement | null = this.querySelector(\n 'input.hidden-button',\n );\n\n if (hiddenButton) {\n hiddenButton.type = this.type;\n return;\n }\n\n this.addHiddenButton();\n this.addEventListener('click', this.handleComponentClick);\n }\n\n /**\n * Triggers form actions (submit/reset) on click, if desired\n * and if actions not already in progress\n */\n private handleComponentClick(e: Event): void {\n if (this.type === 'button') return;\n\n // No need to submit/reset the form if it's already submitting/resetting\n const formActionsInProgress =\n e instanceof CustomEvent && e.detail.formActionsInProgress;\n if (formActionsInProgress) return;\n\n // Request form submission/reset by clicking the hidden native submit/reset button we added earlier\n const hiddenButton = this.querySelector(\n 'input.hidden-button',\n ) as HTMLInputElement;\n hiddenButton.dispatchEvent(new PointerEvent('click'));\n }\n\n /**\n * Adds a hidden button to the light DOM to\n * emulate native reset/submit button behavior.\n *\n * Used for:\n * - Submitting/resetting the form (on behalf of handleComponentClick)\n * - Activating any component click events if form is submitted with the enter key\n * (via handleFormActions)\n */\n private addHiddenButton(): void {\n if (this.type === 'button') return;\n\n render(\n html`<input\n type=${this.type}\n class=\"hidden-button\"\n style=\"display:none\"\n slot=\"hidden-button\"\n @click=${(e: Event) => this.handleFormActions(e)}\n />`,\n this,\n );\n }\n\n /** Triggers the component's click event manually to prevent extra submission/reset */\n private handleFormActions(e: Event): void {\n /**\n * Prevents the event from bubbling up to the ia-button component itself.\n * This way, if the click on this button is triggered by a click on the component,\n * we don't accidentally bubble up a second click and end up in an infinite loop.\n *\n * And if the click was triggered by form submission (via the enter key), we can hijack the click\n * event to pass that info to the component, so it knows not to\n * re-attempt submission.\n */\n e.stopPropagation();\n\n // Detect if click comes from the parent component,\n // in which case there's no need to trigger a second click on it\n const triggeredByComponentClick = !e.isTrusted;\n if (triggeredByComponentClick) return;\n\n // Trigger parent component click events manually,\n // so it knows not to try to re-submit/re-reset the form\n this.dispatchEvent(\n new CustomEvent('click', { detail: { formActionsInProgress: true } }),\n );\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --primary-cta-text-color--: var(--primary-cta-text-color);\n --primary-cta-fill--: var(--primary-cta-fill);\n --primary-cta-border--: var(--primary-cta-border);\n\n --secondary-cta-text-color--: var(--secondary-cta-text-color);\n --secondary-cta-fill--: var(--secondary-cta-fill);\n --secondary-cta-border--: var(--secondary-cta-border);\n\n --danger-cta-text-color--: var(--danger-cta-text-color);\n --danger-cta-fill--: var(--danger-cta-fill);\n --danger-cta-border--: var(--danger-cta-border);\n\n --warning-cta-text-color--: var(--warning-cta-text-color);\n --warning-cta-fill--: var(--warning-cta-fill);\n --warning-cta-border--: var(--warning-cta-border);\n\n --disabled-cta-text-color--: var(--disabled-cta-text-color);\n --disabled-cta-fill--: var(--disabled-cta-fill);\n --disabled-cta-border--: var(--disabled-cta-border);\n\n --link-color--: var(--link-color);\n --color-danger--: var(--color-danger);\n\n --button-padding--: var(--button-padding);\n --button-width--: var(--button-width);\n --button-height--: var(--button-height);\n --button-border-width--: var(--button-border-width);\n --button-border-radius--: var(--button-border-radius);\n --base-font-family--: var(--base-font-family);\n --font-size-standard--: var(--font-size-standard);\n\n --ia-button-transition--: var(\n --ia-button-transition,\n all 0.1s ease 0s\n );\n\n --ia-button-custom-text-color--: var(\n --ia-button-custom-text-color,\n var(--primary-cta-text-color--)\n );\n --ia-button-custom-fill--: var(\n --ia-button-custom-fill,\n var(--primary-cta-fill--)\n );\n --ia-button-custom-border--: var(\n --ia-button-custom-border,\n var(--primary-cta-border--)\n );\n --ia-button-custom-active-text-color--: var(\n --ia-button-custom-active-text-color,\n var(--ia-button-custom-text-color--)\n );\n --ia-button-custom-active-fill--: var(\n --ia-button-custom-active-fill,\n var(--ia-button-custom-fill--)\n );\n --ia-button-custom-active-border--: var(\n --ia-button-custom-active-border,\n var(--ia-button-custom-border--)\n );\n\n display: inline-block; /* keeps host sized to button */\n }\n\n button {\n font-family: var(--base-font-family--);\n font-size: var(--font-size-standard--);\n height: var(--button-height--);\n min-height: var(--button-height--);\n width: var(--button-width--);\n padding: var(--button-padding--);\n border-width: var(--button-border-width--);\n border-radius: var(--button-border-radius--);\n transition: var(--ia-button-transition--);\n\n outline-color: currentColor;\n cursor: pointer;\n line-height: normal;\n border-style: solid;\n white-space: nowrap;\n appearance: auto;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n vertical-align: middle;\n outline-offset: -4px;\n user-select: none;\n text-decoration: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n -o-user-select: none;\n }\n\n a {\n text-decoration: none;\n }\n\n button:disabled,\n button.disabled {\n cursor: not-allowed;\n color: var(--disabled-cta-text-color--);\n background-color: var(--disabled-cta-fill--);\n border: 1px solid var(--disabled-cta-border--);\n opacity: 0.5;\n }\n\n button:enabled:hover {\n opacity: 0.9;\n }\n\n button:focus-visible {\n opacity: 0.8;\n outline-style: double;\n }\n\n button:active {\n opacity: 0.7;\n }\n\n button.primary {\n color: var(--primary-cta-text-color--);\n background-color: var(--primary-cta-fill--);\n border-color: var(--primary-cta-border--);\n }\n\n button.secondary {\n color: var(--secondary-cta-text-color--);\n background-color: var(--secondary-cta-fill--);\n border-color: var(--secondary-cta-border--);\n }\n\n button.danger {\n color: var(--danger-cta-text-color--);\n background-color: var(--danger-cta-fill--);\n border-color: var(--danger-cta-border--);\n }\n\n button.warning {\n color: var(--warning-cta-text-color--);\n background-color: var(--warning-cta-fill--);\n border-color: var(--warning-cta-border--);\n }\n\n button.transparent {\n color: inherit;\n border-width: 0;\n background-color: transparent;\n border-color: transparent;\n }\n\n button.custom {\n color: var(--ia-button-custom-text-color--);\n background-color: var(--ia-button-custom-fill--);\n border-color: var(--ia-button-custom-border--);\n }\n\n button.custom:enabled:is(:hover, :focus, :active, .active) {\n color: var(--ia-button-custom-active-text-color--);\n background-color: var(--ia-button-custom-active-fill--);\n border-color: var(--ia-button-custom-active-border--);\n }\n\n :host(.fit-content) button {\n padding: 0;\n height: fit-content;\n }\n\n button.link:enabled:hover,\n button.danger-link:enabled:hover {\n text-decoration: underline;\n }\n\n button.link,\n button.danger-link {\n margin: 0;\n border: 0;\n appearance: none;\n background: none;\n text-decoration: none;\n cursor: pointer;\n padding: 0;\n }\n\n button.link {\n color: var(--link-color--);\n }\n\n button.danger-link {\n color: var(--color-danger--);\n }\n\n .loading-indicator {\n display: flex;\n flex-direction: row;\n gap: 0.5rem;\n align-items: center;\n }\n\n ia-status-indicator {\n --ia-theme-primary-text-color: currentColor;\n }\n `,\n ];\n }\n}\n"]}
@@ -0,0 +1,70 @@
1
+ import { LitElement, CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
+ import type { UserListServiceInterface } from '../../services/userlist-service/userlist-service-interface.js';
3
+ import type { UserListModel } from './models.js';
4
+ import '../../elements/ia-button/ia-button.js';
5
+ export type { UserListModel } from './models.js';
6
+ /**
7
+ * The form for creating or editing a user list: its name, description and
8
+ * privacy. Saving goes through the given `userListsService`.
9
+ *
10
+ * @fires listModalClosed - Cancel was clicked
11
+ * @fires userListSaving - A save has started
12
+ * @fires userListSaved - The list was saved; `detail` is the saved `UserList`
13
+ * @fires userListError - The save failed; `detail.error` holds the error
14
+ *
15
+ * A failed save shows an error message in the form.
16
+ */
17
+ export declare class IAUserListSettings extends LitElement {
18
+ /**
19
+ * The list to edit. Leave unset, or without an `id`, to create a new list.
20
+ */
21
+ userList?: UserListModel;
22
+ /**
23
+ * User lists service to use for creating/updating lists
24
+ */
25
+ userListsService?: UserListServiceInterface;
26
+ /**
27
+ * Whether to focus the List name field when the form first renders.
28
+ * Set `.autoFocusListName=${false}` to leave focus where it is.
29
+ */
30
+ autoFocusListName: boolean;
31
+ /** Whether a save is in progress, which disables the Save button */
32
+ private saving;
33
+ /** Whether the last save failed, which shows an error message */
34
+ private saveFailed;
35
+ private form;
36
+ private listId;
37
+ private listName;
38
+ private listDescription;
39
+ private listPrivate;
40
+ protected willUpdate(changed: PropertyValues<this>): void;
41
+ protected firstUpdated(): void;
42
+ protected updated(changed: PropertyValues<this>): void;
43
+ /** Saves the form through the service, on submit */
44
+ private saveListDetails;
45
+ private emitCloseModalEvent;
46
+ /** Updates the list being edited, or creates a new one when there's no id */
47
+ private saveList;
48
+ private handleSaveSuccess;
49
+ private handleSaveError;
50
+ /** The list details as typed into the form */
51
+ private readFormValues;
52
+ /**
53
+ * Fills the fields from `userList`, or empties them for a new list. Only runs
54
+ * when `userList` changes, so other renders leave what's been typed alone.
55
+ */
56
+ private fillForm;
57
+ render(): TemplateResult;
58
+ private get nameFieldTemplate();
59
+ private get descriptionFieldTemplate();
60
+ private get privateFieldTemplate();
61
+ private get errorTemplate();
62
+ private get footerTemplate();
63
+ static get styles(): CSSResultGroup;
64
+ }
65
+ declare global {
66
+ interface HTMLElementTagNameMap {
67
+ 'ia-userlist-settings': IAUserListSettings;
68
+ }
69
+ }
70
+ //# sourceMappingURL=ia-userlist-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ia-userlist-settings.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-userlist-settings/ia-userlist-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,cAAc,EAEd,cAAc,EACd,cAAc,EACf,MAAM,KAAK,CAAC;AAOb,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AAM1G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,mCAAmC,CAAC;AAE3C,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,qBAEa,kBAAmB,SAAQ,UAAU;IAChD;;OAEG;IACyB,QAAQ,CAAC,EAAE,aAAa,CAAC;IAErD;;OAEG;IACyB,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAExE;;;OAGG;IAC0B,iBAAiB,UAAQ;IAEtD,oEAAoE;IAC3D,OAAO,CAAC,MAAM,CAAS;IAEhC,iEAAiE;IACxD,OAAO,CAAC,UAAU,CAAS;IAEV,OAAO,CAAC,IAAI,CAAmB;IAE3C,OAAO,CAAC,MAAM,CAAoB;IAEhC,OAAO,CAAC,QAAQ,CAAoB;IAE7B,OAAO,CAAC,eAAe,CAAuB;IAElD,OAAO,CAAC,WAAW,CAAoB;IAE1D,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAKzD,SAAS,CAAC,YAAY,IAAI,IAAI;IAO9B,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAItD,oDAAo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