@quartzds/core 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +136 -0
  2. package/components/floating-ui.dom.esm.js +1402 -0
  3. package/components/floating-ui.dom.esm.js.map +1 -0
  4. package/components/helpers.js +174 -0
  5. package/components/helpers.js.map +1 -0
  6. package/components/icon.js +175 -0
  7. package/components/icon.js.map +1 -0
  8. package/components/index.d.ts +52 -0
  9. package/components/index.js +117 -0
  10. package/components/index.js.map +1 -0
  11. package/components/label.js +55 -0
  12. package/components/label.js.map +1 -0
  13. package/components/qds-button.d.ts +11 -0
  14. package/components/qds-button.js +148 -0
  15. package/components/qds-button.js.map +1 -0
  16. package/components/qds-checkbox.d.ts +11 -0
  17. package/components/qds-checkbox.js +156 -0
  18. package/components/qds-checkbox.js.map +1 -0
  19. package/components/qds-dropdown.d.ts +11 -0
  20. package/components/qds-dropdown.js +259 -0
  21. package/components/qds-dropdown.js.map +1 -0
  22. package/components/qds-icon.d.ts +11 -0
  23. package/components/qds-icon.js +13 -0
  24. package/components/qds-icon.js.map +1 -0
  25. package/components/qds-inline-link.d.ts +11 -0
  26. package/components/qds-inline-link.js +89 -0
  27. package/components/qds-inline-link.js.map +1 -0
  28. package/components/qds-input.d.ts +11 -0
  29. package/components/qds-input.js +244 -0
  30. package/components/qds-input.js.map +1 -0
  31. package/components/qds-label.d.ts +11 -0
  32. package/components/qds-label.js +13 -0
  33. package/components/qds-label.js.map +1 -0
  34. package/components/qds-radio.d.ts +11 -0
  35. package/components/qds-radio.js +109 -0
  36. package/components/qds-radio.js.map +1 -0
  37. package/components/qds-switch.d.ts +11 -0
  38. package/components/qds-switch.js +119 -0
  39. package/components/qds-switch.js.map +1 -0
  40. package/components/qds-title.d.ts +11 -0
  41. package/components/qds-title.js +94 -0
  42. package/components/qds-title.js.map +1 -0
  43. package/components/qds-tooltip.d.ts +11 -0
  44. package/components/qds-tooltip.js +325 -0
  45. package/components/qds-tooltip.js.map +1 -0
  46. package/dist/cjs/floating-ui.dom.esm-71fa96af.js +1410 -0
  47. package/dist/cjs/floating-ui.dom.esm-71fa96af.js.map +1 -0
  48. package/dist/cjs/helpers-0b23af3f.js +184 -0
  49. package/dist/cjs/helpers-0b23af3f.js.map +1 -0
  50. package/dist/cjs/index-f19b2823.js +2030 -0
  51. package/dist/cjs/index-f19b2823.js.map +1 -0
  52. package/dist/cjs/index.cjs.js +115 -0
  53. package/dist/cjs/index.cjs.js.map +1 -0
  54. package/dist/cjs/library-4803c801.js +62 -0
  55. package/dist/cjs/library-4803c801.js.map +1 -0
  56. package/dist/cjs/loader.cjs.js +29 -0
  57. package/dist/cjs/loader.cjs.js.map +1 -0
  58. package/dist/cjs/qds-button.cjs.entry.js +110 -0
  59. package/dist/cjs/qds-button.cjs.entry.js.map +1 -0
  60. package/dist/cjs/qds-checkbox.cjs.entry.js +116 -0
  61. package/dist/cjs/qds-checkbox.cjs.entry.js.map +1 -0
  62. package/dist/cjs/qds-dropdown.cjs.entry.js +227 -0
  63. package/dist/cjs/qds-dropdown.cjs.entry.js.map +1 -0
  64. package/dist/cjs/qds-icon.cjs.entry.js +113 -0
  65. package/dist/cjs/qds-icon.cjs.entry.js.map +1 -0
  66. package/dist/cjs/qds-inline-link.cjs.entry.js +61 -0
  67. package/dist/cjs/qds-inline-link.cjs.entry.js.map +1 -0
  68. package/dist/cjs/qds-input.cjs.entry.js +200 -0
  69. package/dist/cjs/qds-input.cjs.entry.js.map +1 -0
  70. package/dist/cjs/qds-label.cjs.entry.js +39 -0
  71. package/dist/cjs/qds-label.cjs.entry.js.map +1 -0
  72. package/dist/cjs/qds-radio.cjs.entry.js +74 -0
  73. package/dist/cjs/qds-radio.cjs.entry.js.map +1 -0
  74. package/dist/cjs/qds-switch.cjs.entry.js +79 -0
  75. package/dist/cjs/qds-switch.cjs.entry.js.map +1 -0
  76. package/dist/cjs/qds-title.cjs.entry.js +66 -0
  77. package/dist/cjs/qds-title.cjs.entry.js.map +1 -0
  78. package/dist/cjs/qds-tooltip.cjs.entry.js +284 -0
  79. package/dist/cjs/qds-tooltip.cjs.entry.js.map +1 -0
  80. package/dist/cjs/qds.cjs.js +33 -0
  81. package/dist/cjs/qds.cjs.js.map +1 -0
  82. package/dist/custom-elements.json +3976 -0
  83. package/dist/docs.d.ts +148 -0
  84. package/dist/docs.json +3918 -0
  85. package/dist/esm/floating-ui.dom.esm-f96ac766.js +1402 -0
  86. package/dist/esm/floating-ui.dom.esm-f96ac766.js.map +1 -0
  87. package/dist/esm/helpers-5c189a19.js +174 -0
  88. package/dist/esm/helpers-5c189a19.js.map +1 -0
  89. package/dist/esm/index-1bc8e218.js +2000 -0
  90. package/dist/esm/index-1bc8e218.js.map +1 -0
  91. package/dist/esm/index.js +106 -0
  92. package/dist/esm/index.js.map +1 -0
  93. package/dist/esm/library-aa6893c0.js +58 -0
  94. package/dist/esm/library-aa6893c0.js.map +1 -0
  95. package/dist/esm/loader.js +25 -0
  96. package/dist/esm/loader.js.map +1 -0
  97. package/dist/esm/polyfills/core-js.js +11 -0
  98. package/dist/esm/polyfills/css-shim.js +1 -0
  99. package/dist/esm/polyfills/dom.js +79 -0
  100. package/dist/esm/polyfills/es5-html-element.js +1 -0
  101. package/dist/esm/polyfills/index.js +34 -0
  102. package/dist/esm/polyfills/system.js +6 -0
  103. package/dist/esm/qds-button.entry.js +106 -0
  104. package/dist/esm/qds-button.entry.js.map +1 -0
  105. package/dist/esm/qds-checkbox.entry.js +112 -0
  106. package/dist/esm/qds-checkbox.entry.js.map +1 -0
  107. package/dist/esm/qds-dropdown.entry.js +223 -0
  108. package/dist/esm/qds-dropdown.entry.js.map +1 -0
  109. package/dist/esm/qds-icon.entry.js +109 -0
  110. package/dist/esm/qds-icon.entry.js.map +1 -0
  111. package/dist/esm/qds-inline-link.entry.js +57 -0
  112. package/dist/esm/qds-inline-link.entry.js.map +1 -0
  113. package/dist/esm/qds-input.entry.js +196 -0
  114. package/dist/esm/qds-input.entry.js.map +1 -0
  115. package/dist/esm/qds-label.entry.js +35 -0
  116. package/dist/esm/qds-label.entry.js.map +1 -0
  117. package/dist/esm/qds-radio.entry.js +70 -0
  118. package/dist/esm/qds-radio.entry.js.map +1 -0
  119. package/dist/esm/qds-switch.entry.js +75 -0
  120. package/dist/esm/qds-switch.entry.js.map +1 -0
  121. package/dist/esm/qds-title.entry.js +62 -0
  122. package/dist/esm/qds-title.entry.js.map +1 -0
  123. package/dist/esm/qds-tooltip.entry.js +280 -0
  124. package/dist/esm/qds-tooltip.entry.js.map +1 -0
  125. package/dist/esm/qds.js +28 -0
  126. package/dist/esm/qds.js.map +1 -0
  127. package/dist/types/components/button/button.d.ts +209 -0
  128. package/dist/types/components/checkbox/checkbox.d.ts +136 -0
  129. package/dist/types/components/create-story.d.ts +5 -0
  130. package/dist/types/components/dropdown/dropdown.d.ts +135 -0
  131. package/dist/types/components/icon/default-library.d.ts +4 -0
  132. package/dist/types/components/icon/icon.d.ts +31 -0
  133. package/dist/types/components/icon/library.d.ts +19 -0
  134. package/dist/types/components/icon/request.d.ts +12 -0
  135. package/dist/types/components/icon/system-library.d.ts +4 -0
  136. package/dist/types/components/inline-link/inline-link.d.ts +208 -0
  137. package/dist/types/components/input/input.d.ts +386 -0
  138. package/dist/types/components/label/label.d.ts +33 -0
  139. package/dist/types/components/radio/radio.d.ts +110 -0
  140. package/dist/types/components/switch/switch.d.ts +115 -0
  141. package/dist/types/components/title/title.d.ts +42 -0
  142. package/dist/types/components/tooltip/tooltip.d.ts +147 -0
  143. package/dist/types/components.d.ts +1692 -0
  144. package/dist/types/helpers.d.ts +49 -0
  145. package/dist/types/index.d.ts +4 -0
  146. package/dist/types/qds-test.d.ts +18 -0
  147. package/dist/types/stencil-public-runtime.d.ts +1638 -0
  148. package/dist/types/utils.d.ts +65 -0
  149. package/dist/vscode.html-custom-data.json +947 -0
  150. package/hydrate/index.d.ts +218 -0
  151. package/hydrate/index.js +9690 -0
  152. package/hydrate/package.json +6 -0
  153. package/loader/cdn.js +7 -0
  154. package/loader/index.cjs.js +7 -0
  155. package/loader/index.d.ts +21 -0
  156. package/loader/index.es2017.js +7 -0
  157. package/loader/index.js +8 -0
  158. package/loader/package.json +11 -0
  159. package/package.json +231 -0
  160. package/styles/core.css +379 -0
@@ -0,0 +1,156 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: © 2023 Schneider Electric
3
+ *
4
+ * SPDX-License-Identifier: LGPL-2.1-only
5
+ */
6
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
7
+ import { p as pickFocusEventAttributes, a as invariant, i as inheritAriaAttributes, b as inheritAttributes } from './helpers.js';
8
+ import { d as defineCustomElement$3 } from './icon.js';
9
+ import { d as defineCustomElement$2 } from './label.js';
10
+
11
+ const checkboxCss = ".sc-qds-checkbox-h{box-sizing:border-box}[hidden].sc-qds-checkbox-h{display:none !important}.sc-qds-checkbox-h *.sc-qds-checkbox,.sc-qds-checkbox-h *.sc-qds-checkbox::before,.sc-qds-checkbox-h *.sc-qds-checkbox::after{box-sizing:inherit}.sc-qds-checkbox-h{display:inline-block;line-height:0}.icon.sc-qds-checkbox{display:none;color:var(--qds-theme-signature-color-contrast);inset-inline-start:0;pointer-events:none;position:absolute}.label.sc-qds-checkbox{cursor:pointer;display:inline-flex;position:relative}.checkbox.sc-qds-checkbox{align-items:center;-webkit-appearance:none;appearance:none;background-color:var(--qds-theme-control-input-background);border-radius:var(--qds-control-border-radius);border:var(--qds-control-border-width) solid var(--qds-theme-control-border);cursor:pointer;display:flex;flex-shrink:0;justify-content:center;margin:0;-webkit-print-color-adjust:exact;print-color-adjust:exact}.checkbox.sc-qds-checkbox:focus-visible{outline:var(--qds-theme-focus-border) solid var(--qds-focus-border-width);outline-offset:var(--qds-focus-border-offset)}.checkbox.sc-qds-checkbox::before{content:'';height:10px;position:absolute;width:10px}.checkbox.sc-qds-checkbox:hover::before{box-shadow:inset 1em 1em var(--qds-theme-signature-color-hover)}.checkbox.sc-qds-checkbox:active::before{box-shadow:inset 1em 1em var(--qds-theme-signature-color-pressed)}.checkbox.sc-qds-checkbox:checked~.checked.sc-qds-checkbox,.checkbox.sc-qds-checkbox:indeterminate~.indeterminate.sc-qds-checkbox{display:inline-block}.checkbox.sc-qds-checkbox:checked,.checkbox.sc-qds-checkbox:indeterminate{background-color:var(--qds-theme-signature-color-default);border-color:transparent}.checkbox.sc-qds-checkbox:checked:hover,.checkbox.sc-qds-checkbox:indeterminate:hover{background-color:var(--qds-theme-signature-color-hover)}.checkbox.sc-qds-checkbox:checked:active,.checkbox.sc-qds-checkbox:indeterminate:active{background-color:var(--qds-theme-signature-color-pressed)}[aria-disabled='true'].sc-qds-checkbox{opacity:var(--qds-theme-disabled);pointer-events:none}.icon[data-size='small'].sc-qds-checkbox,.checkbox[data-size='small'].sc-qds-checkbox{width:var(--qds-control-small-icon-size);height:var(--qds-control-small-icon-size)}.inline[data-size='small'].sc-qds-checkbox{margin-block:var(--qds-control-small-padding-auto-height)}.label[data-size='small'].sc-qds-checkbox{gap:var(--qds-control-small-gap-siblings-related)}.icon[data-size='standard'].sc-qds-checkbox,.checkbox[data-size='standard'].sc-qds-checkbox{width:var(--qds-control-standard-icon-size);height:var(--qds-control-standard-icon-size)}.inline[data-size='standard'].sc-qds-checkbox{margin-block:var(--qds-control-standard-padding-auto-height)}.label[data-size='standard'].sc-qds-checkbox{gap:var(--qds-control-standard-gap-siblings-related)}.icon[data-size='large'].sc-qds-checkbox,.checkbox[data-size='large'].sc-qds-checkbox{width:var(--qds-control-large-icon-size);height:var(--qds-control-large-icon-size)}.inline[data-size='large'].sc-qds-checkbox{margin-block:var(--qds-control-large-padding-auto-height)}.label[data-size='large'].sc-qds-checkbox{gap:var(--qds-control-large-gap-siblings-related)}";
12
+
13
+ let autoIncrementingId = 1;
14
+ const Checkbox = /*@__PURE__*/ proxyCustomElement(class Checkbox extends HTMLElement {
15
+ constructor() {
16
+ super();
17
+ this.__registerHost();
18
+ this.blurEmitter = createEvent(this, "qdsBlur", 2);
19
+ this.changeEmitter = createEvent(this, "qdsChange", 6);
20
+ this.focusEmitter = createEvent(this, "qdsFocus", 2);
21
+ this.inheritedAttributes = {};
22
+ this.ref = (checkbox) => {
23
+ this.input = checkbox;
24
+ };
25
+ this.onBlur = (event) => {
26
+ this.blurEmitter.emit(pickFocusEventAttributes(event));
27
+ };
28
+ this.onFocus = (event) => {
29
+ this.focusEmitter.emit(pickFocusEventAttributes(event));
30
+ };
31
+ this.inline = false;
32
+ this.size = 'standard';
33
+ this.text = undefined;
34
+ this.autoFocus = undefined;
35
+ this.checked = undefined;
36
+ this.disabled = undefined;
37
+ this.form = undefined;
38
+ this.indeterminate = undefined;
39
+ this.name = `qds-checkbox-${autoIncrementingId}`;
40
+ this.required = undefined;
41
+ this.value = undefined;
42
+ }
43
+ get computedDisabled() {
44
+ return this.disabled ?? false;
45
+ }
46
+ get computedIndeterminate() {
47
+ return this.indeterminate ?? false;
48
+ }
49
+ get hasText() {
50
+ return ((this.text !== undefined && this.text !== '') || this.required === true);
51
+ }
52
+ /**
53
+ * Returns whether a form will validate this checkbox when it is submitted
54
+ * without having to submit it.
55
+ */
56
+ async checkValidity() {
57
+ invariant(this.input);
58
+ return this.input.checkValidity();
59
+ }
60
+ /**
61
+ * Returns true if the checkbox's value passes validity checks; otherwise,
62
+ * returns false, and (if the event isn't canceled) reports the problem to
63
+ * the user.
64
+ */
65
+ async reportValidity() {
66
+ invariant(this.input);
67
+ return this.input.reportValidity();
68
+ }
69
+ /**
70
+ * Sets a custom validity message for the checkbox. If this message is not the
71
+ * empty string, then the checkbox is considered invalid.
72
+ */
73
+ async setCustomValidity(message) {
74
+ invariant(this.input);
75
+ this.input.setCustomValidity(message);
76
+ }
77
+ onClick(event) {
78
+ if (this.computedDisabled)
79
+ return;
80
+ event.preventDefault();
81
+ this.checked = this.computedIndeterminate ? true : !(this.checked ?? false);
82
+ this.changeEmitter.emit();
83
+ this.indeterminate = false;
84
+ }
85
+ componentWillLoad() {
86
+ autoIncrementingId += 1;
87
+ this.inheritedAttributes = {
88
+ ...inheritAriaAttributes(this.element),
89
+ ...inheritAttributes(this.element, ['tabindex']),
90
+ };
91
+ }
92
+ render() {
93
+ return (
94
+ // eslint-disable-next-line jsx-a11y/label-has-associated-control
95
+ h("label", { "aria-disabled": this.computedDisabled ? 'true' : 'false', class: {
96
+ inline: this.inline,
97
+ label: true,
98
+ }, "data-size": this.size }, h("input", {
99
+ // eslint-disable-next-line jsx-a11y/no-autofocus
100
+ autoFocus: this.autoFocus, checked: this.computedIndeterminate ? false : this.checked, class: "checkbox", "data-size": this.size, disabled: this.disabled, form: this.form, indeterminate: this.indeterminate, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, ref: this.ref, required: this.required, type: "checkbox", value: this.value ?? undefined, ...this.inheritedAttributes
101
+ }), h("qds-icon", { "aria-hidden": "true", class: {
102
+ icon: true,
103
+ checked: true,
104
+ }, "data-size": this.size, library: "system", name: "check" }), h("qds-icon", { "aria-hidden": "true", class: {
105
+ icon: true,
106
+ indeterminate: true,
107
+ }, "data-size": this.size, library: "system", name: "minus" }), this.hasText && (h("qds-label", { required: this.required, size: this.size, text: this.text }))));
108
+ }
109
+ get element() { return this; }
110
+ static get style() { return checkboxCss; }
111
+ }, [2, "qds-checkbox", {
112
+ "inline": [4],
113
+ "size": [513],
114
+ "text": [1537],
115
+ "autoFocus": [4, "autofocus"],
116
+ "checked": [1540],
117
+ "disabled": [1540],
118
+ "form": [1],
119
+ "indeterminate": [1540],
120
+ "name": [1],
121
+ "required": [4],
122
+ "value": [1032],
123
+ "checkValidity": [64],
124
+ "reportValidity": [64],
125
+ "setCustomValidity": [64]
126
+ }, [[0, "click", "onClick"]]]);
127
+ function defineCustomElement$1() {
128
+ if (typeof customElements === "undefined") {
129
+ return;
130
+ }
131
+ const components = ["qds-checkbox", "qds-icon", "qds-label"];
132
+ components.forEach(tagName => { switch (tagName) {
133
+ case "qds-checkbox":
134
+ if (!customElements.get(tagName)) {
135
+ customElements.define(tagName, Checkbox);
136
+ }
137
+ break;
138
+ case "qds-icon":
139
+ if (!customElements.get(tagName)) {
140
+ defineCustomElement$3();
141
+ }
142
+ break;
143
+ case "qds-label":
144
+ if (!customElements.get(tagName)) {
145
+ defineCustomElement$2();
146
+ }
147
+ break;
148
+ } });
149
+ }
150
+
151
+ const QdsCheckbox = Checkbox;
152
+ const defineCustomElement = defineCustomElement$1;
153
+
154
+ export { QdsCheckbox, defineCustomElement };
155
+
156
+ //# sourceMappingURL=qds-checkbox.js.map
@@ -0,0 +1 @@
1
+ {"file":"qds-checkbox.js","mappings":";;;;;;;;;;AAAA,MAAM,WAAW,GAAG,+lGAA+lG;;AC0BnnG,IAAI,kBAAkB,GAAG,CAAC,CAAA;MAcb,QAAQ;;;;;;;IAmHX,wBAAmB,GAAe,EAAE,CAAA;IAoI3B,QAAG,GAAG,CAAC,QAA2B;MACjD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAA;KACtB,CAAA;IAEgB,WAAM,GAAG,CAAC,KAAiB;MAC1C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;KACvD,CAAA;IAEgB,YAAO,GAAG,CAAC,KAAiB;MAC3C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;KACxD,CAAA;kBA1PyC,KAAK;gBAKe,UAAU;;;;;;;gBA4DzC,gBAAgB,kBAAkB,EAAE;;;;EA+CnE,IAAY,gBAAgB;IAC1B,OAAO,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAA;GAC9B;EAED,IAAY,qBAAqB;IAC/B,OAAO,IAAI,CAAC,aAAa,IAAI,KAAK,CAAA;GACnC;EAED,IAAY,OAAO;IACjB,QACE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,KAAK,IAAI,CAAC,QA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AE,IAAI,CAAC,qBAAqB,GAAG,KAAK,GAAG,IAAI,CAAC,OAAO,EAC1D,KAAK,EAAC,UAAU,eACL,IAAI,CAAC,IAAI,EACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,aAAa,EAAE,IAAI,CAAC,aAAa,EACjC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAC,UAAU,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS,KAE1B,IAAI,CAAC,mBAAmB;MAC5B,EACF,+BACc,MAAM,EAClB,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;OACd,eACU,IAAI,CAAC,IAAI,EACpB,OAAO,EAAC,QAAQ,EAChB,IAAI,EAAC,OAAO,GACZ,EACF,+BACc,MAAM,EAClB,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,aAAa,EAAE,IAAI;OACpB,eACU,IAAI,CAAC,IAAI,EACpB,OAAO,EAAC,QAAQ,EAChB,IAAI,EAAC,OAAO,GACZ,EACD,IAAI,CAAC,OAAO,KACX,iBACE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,GACf,CACH,CACK,EACT;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/checkbox/checkbox.css?tag=qds-checkbox&encapsulation=scoped","./src/components/checkbox/checkbox.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n display: inline-block;\n line-height: 0;\n}\n\n.icon {\n display: none;\n color: var(--qds-theme-signature-color-contrast);\n inset-inline-start: 0;\n pointer-events: none;\n position: absolute;\n}\n\n.label {\n cursor: pointer;\n display: inline-flex;\n position: relative;\n}\n\n.checkbox {\n align-items: center;\n appearance: none;\n background-color: var(--qds-theme-control-input-background);\n border-radius: var(--qds-control-border-radius);\n border: var(--qds-control-border-width) solid var(--qds-theme-control-border);\n cursor: pointer;\n display: flex;\n flex-shrink: 0;\n justify-content: center;\n margin: 0;\n print-color-adjust: exact;\n\n &:focus-visible {\n outline: var(--qds-theme-focus-border) solid var(--qds-focus-border-width);\n outline-offset: var(--qds-focus-border-offset);\n }\n\n &::before {\n content: '';\n height: 10px;\n position: absolute;\n width: 10px;\n }\n\n &:hover::before {\n box-shadow: inset 1em 1em var(--qds-theme-signature-color-hover);\n }\n\n &:active::before {\n box-shadow: inset 1em 1em var(--qds-theme-signature-color-pressed);\n }\n\n &:checked ~ .checked,\n &:indeterminate ~ .indeterminate {\n display: inline-block;\n }\n\n &:checked,\n &:indeterminate {\n background-color: var(--qds-theme-signature-color-default);\n border-color: transparent;\n\n &:hover {\n background-color: var(--qds-theme-signature-color-hover);\n }\n\n &:active {\n background-color: var(--qds-theme-signature-color-pressed);\n }\n }\n}\n\n[aria-disabled='true'] {\n opacity: var(--qds-theme-disabled);\n pointer-events: none;\n}\n\n[data-size='small'] {\n &:is(.icon, .checkbox) {\n width: var(--qds-control-small-icon-size);\n height: var(--qds-control-small-icon-size);\n }\n\n &.inline {\n margin-block: var(--qds-control-small-padding-auto-height);\n }\n\n &.label {\n gap: var(--qds-control-small-gap-siblings-related);\n }\n}\n\n[data-size='standard'] {\n &:is(.icon, .checkbox) {\n width: var(--qds-control-standard-icon-size);\n height: var(--qds-control-standard-icon-size);\n }\n\n &.inline {\n margin-block: var(--qds-control-standard-padding-auto-height);\n }\n\n &.label {\n gap: var(--qds-control-standard-gap-siblings-related);\n }\n}\n\n[data-size='large'] {\n &:is(.icon, .checkbox) {\n width: var(--qds-control-large-icon-size);\n height: var(--qds-control-large-icon-size);\n }\n\n &.inline {\n margin-block: var(--qds-control-large-padding-auto-height);\n }\n\n &.label {\n gap: var(--qds-control-large-gap-siblings-related);\n }\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Listen,\n Method,\n Prop,\n} from '@stencil/core'\n\nimport type { Attributes, QdsFocusEventDetail } from '../../helpers'\nimport {\n inheritAriaAttributes,\n inheritAttributes,\n invariant,\n pickFocusEventAttributes,\n} from '../../helpers'\n\nexport type CheckboxValue = number | string | null\nexport type CheckboxSize = 'large' | 'small' | 'standard'\n\nlet autoIncrementingId = 1\n\n/**\n * `<qds-checkbox>` elements are rendered as boxes that are checked (ticked)\n * when activated, like you might see in an official government paper form. A\n * checkbox allows you to select single values for submission in a form (or not).\n *\n * @see https://quartz.se.com/build/components/checkbox\n */\n@Component({\n tag: 'qds-checkbox',\n scoped: true,\n styleUrl: 'checkbox.css',\n})\nexport class Checkbox implements ComponentInterface {\n /**\n * Adds vertical margin to the checkbox for alignment.\n *\n * This is useful when creating inline layouts so that the first lines have\n * the correct vertical centering.\n */\n @Prop() public readonly inline: boolean = false\n\n /**\n * The checkbox's size.\n */\n @Prop({ reflect: true }) public readonly size: CheckboxSize = 'standard'\n\n /**\n * The checkbox's text.\n */\n @Prop({ mutable: true, reflect: true }) public readonly text?: string\n\n /**\n * Specify whether the checkbox should have focus when the page loads.\n *\n * @webnative\n */\n @Prop({ attribute: 'autofocus' }) public readonly autoFocus?: boolean\n\n /**\n * Sets the checkbox's state.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public checked?: boolean\n\n /**\n * Prevents the checkbox from being interacted with: it cannot be pressed or\n * focused.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public disabled?: boolean\n\n /**\n * The [`<form>`](https://developer.mozilla.org/docs/Web/HTML/Element/form)\n * element to associate the checkbox with (its form owner).\n *\n * The value of this property must be the id of a `<form>` in the same\n * document. If this property is not set, the `<qds-checkbox>` is associated\n * with its ancestor `<form>` element, if any.\n *\n * This property lets you associate `<qds-checkbox>` elements to `<form>`s\n * anywhere in the document, not just inside a `<form>`. It can also override\n * an ancestor `<form>` element.\n *\n * @webnative\n */\n @Prop() public readonly form?: string\n\n /**\n * Sets the checkbox to an indeterminate state. This is usually applied to\n * checkboxes that represents a \"select all/none\" behavior when associated\n * checkboxes have a mix of checked and unchecked states.\n *\n * @webnative\n */\n @Prop({ mutable: true, reflect: true }) public indeterminate?: boolean\n\n /**\n * The name of the checkbox, which is submitted with the form data. An\n * incrementing ID is used by default.\n *\n * @webnative\n */\n @Prop() public readonly name = `qds-checkbox-${autoIncrementingId}`\n\n /**\n * A value must be specified for the checkbox before the owning form can be\n * submitted.\n *\n * See\n * [Client-side validation](https://developer.mozilla.org/docs/Web/HTML/Element/input#client-side_validation)\n * and the\n * [HTML attribute: `required`](https://developer.mozilla.org/docs/Web/HTML/Attributes/required)\n * for more information.\n *\n * @webnative\n */\n @Prop() public readonly required?: boolean\n\n /**\n * The value of the checkbox, submitted as a name/value pair with form data.\n *\n * @webnative\n */\n @Prop({ mutable: true }) public value?: CheckboxValue\n\n /**\n * Emitted when the checkbox loses focus.\n */\n @Event({ eventName: 'qdsBlur', bubbles: false, cancelable: false })\n private readonly blurEmitter!: EventEmitter<QdsFocusEventDetail>\n\n /**\n * Emitted when a change to the checkbox's state is committed by the user.\n */\n @Event({ eventName: 'qdsChange', cancelable: false })\n private readonly changeEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the checkbox gains focus.\n */\n @Event({ eventName: 'qdsFocus', bubbles: false, cancelable: false })\n private readonly focusEmitter!: EventEmitter<QdsFocusEventDetail>\n\n @Element() private readonly element!: HTMLQdsCheckboxElement\n\n private inheritedAttributes: Attributes = {}\n\n private input?: HTMLInputElement\n\n private get computedDisabled(): boolean {\n return this.disabled ?? false\n }\n\n private get computedIndeterminate(): boolean {\n return this.indeterminate ?? false\n }\n\n private get hasText(): boolean {\n return (\n (this.text !== undefined && this.text !== '') || this.required === true\n )\n }\n\n /**\n * Returns whether a form will validate this checkbox when it is submitted\n * without having to submit it.\n */\n @Method()\n public async checkValidity(): Promise<boolean> {\n invariant(this.input)\n\n return this.input.checkValidity()\n }\n\n /**\n * Returns true if the checkbox's value passes validity checks; otherwise,\n * returns false, and (if the event isn't canceled) reports the problem to\n * the user.\n */\n @Method()\n public async reportValidity(): Promise<boolean> {\n invariant(this.input)\n\n return this.input.reportValidity()\n }\n\n /**\n * Sets a custom validity message for the checkbox. If this message is not the\n * empty string, then the checkbox is considered invalid.\n */\n @Method()\n public async setCustomValidity(message: string): Promise<void> {\n invariant(this.input)\n\n this.input.setCustomValidity(message)\n }\n\n @Listen('click')\n protected onClick(event: MouseEvent): void {\n if (this.computedDisabled) return\n\n event.preventDefault()\n\n this.checked = this.computedIndeterminate ? true : !(this.checked ?? false)\n this.changeEmitter.emit()\n this.indeterminate = false\n }\n\n public componentWillLoad(): void {\n autoIncrementingId += 1\n this.inheritedAttributes = {\n ...inheritAriaAttributes(this.element),\n ...inheritAttributes(this.element, ['tabindex']),\n }\n }\n\n public render() {\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n aria-disabled={this.computedDisabled ? 'true' : 'false'}\n class={{\n inline: this.inline,\n label: true,\n }}\n data-size={this.size}\n >\n <input\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={this.autoFocus}\n checked={this.computedIndeterminate ? false : this.checked}\n class=\"checkbox\"\n data-size={this.size}\n disabled={this.disabled}\n form={this.form}\n indeterminate={this.indeterminate}\n name={this.name}\n onBlur={this.onBlur}\n onFocus={this.onFocus}\n ref={this.ref}\n required={this.required}\n type=\"checkbox\"\n value={this.value ?? undefined}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...this.inheritedAttributes}\n />\n <qds-icon\n aria-hidden=\"true\"\n class={{\n icon: true,\n checked: true,\n }}\n data-size={this.size}\n library=\"system\"\n name=\"check\"\n />\n <qds-icon\n aria-hidden=\"true\"\n class={{\n icon: true,\n indeterminate: true,\n }}\n data-size={this.size}\n library=\"system\"\n name=\"minus\"\n />\n {this.hasText && (\n <qds-label\n required={this.required}\n size={this.size}\n text={this.text}\n />\n )}\n </label>\n )\n }\n\n private readonly ref = (checkbox?: HTMLInputElement): void => {\n this.input = checkbox\n }\n\n private readonly onBlur = (event: FocusEvent): void => {\n this.blurEmitter.emit(pickFocusEventAttributes(event))\n }\n\n private readonly onFocus = (event: FocusEvent): void => {\n this.focusEmitter.emit(pickFocusEventAttributes(event))\n }\n}\n"],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../dist/types/components";
2
+
3
+ interface QdsDropdown extends Components.QdsDropdown, HTMLElement {}
4
+ export const QdsDropdown: {
5
+ prototype: QdsDropdown;
6
+ new (): QdsDropdown;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,259 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: © 2023 Schneider Electric
3
+ *
4
+ * SPDX-License-Identifier: LGPL-2.1-only
5
+ */
6
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
7
+ import { o as offset, f as flip, s as shift, c as computePosition, a as autoUpdate, l as limitShift } from './floating-ui.dom.esm.js';
8
+ import { c as ignorePromise, d as propertyToPx, a as invariant, r as roundByDPR } from './helpers.js';
9
+
10
+ const dropdownCss = ":host{box-sizing:border-box}:host([hidden]){display:none !important}:host([hidden]){}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{background:var(--qds-theme-accessory-background);border-radius:var(--qds-accessory-border-radius);box-shadow:var(--qds-theme-accessory-elevation);display:inline-block;left:0;top:0}";
11
+
12
+ let autoIncrementingId = 1;
13
+ const Dropdown = /*@__PURE__*/ proxyCustomElement(class Dropdown extends HTMLElement {
14
+ constructor() {
15
+ super();
16
+ this.__registerHost();
17
+ this.__attachShadow();
18
+ this.cancelEmitter = createEvent(this, "qdsCancel", 3);
19
+ this.closeEmitter = createEvent(this, "qdsClose", 2);
20
+ this.open = false;
21
+ this.boundFocusout = (event) => {
22
+ ignorePromise(this.handleFocusOut(event));
23
+ };
24
+ this.boundEscape = (event) => {
25
+ ignorePromise(this.handleEscape(event));
26
+ };
27
+ this.boundReferenceClick = () => {
28
+ ignorePromise(this.handleReferenceClick());
29
+ };
30
+ this.autoUpdateOptions = undefined;
31
+ this.disabled = false;
32
+ this.flipOptions = undefined;
33
+ this.noFlip = false;
34
+ this.noShift = false;
35
+ this.offsetOptions = undefined;
36
+ this.placement = 'bottom-start';
37
+ this.shiftOptions = undefined;
38
+ this.strategy = undefined;
39
+ this.target = undefined;
40
+ this.hostAriaLabelledBy = undefined;
41
+ this.hostDisplay = undefined;
42
+ this.hostPosition = undefined;
43
+ this.hostTransform = undefined;
44
+ }
45
+ /**
46
+ * Show the dropdown.
47
+ */
48
+ async show() {
49
+ if (this.open)
50
+ return;
51
+ if (this.referenceElement instanceof globalThis.Element) {
52
+ this.referenceElement.setAttribute('aria-expanded', 'true');
53
+ this.referenceElement.setAttribute('aria-controls', this.element.id);
54
+ }
55
+ this.open = true;
56
+ this.hostDisplay = undefined;
57
+ this.startAutoUpdate();
58
+ }
59
+ /**
60
+ * Close the dropdown.
61
+ */
62
+ async close() {
63
+ if (!this.open)
64
+ return;
65
+ if (this.referenceElement instanceof globalThis.Element) {
66
+ this.referenceElement.setAttribute('aria-expanded', 'false');
67
+ this.referenceElement.removeAttribute('aria-controls');
68
+ }
69
+ this.open = false;
70
+ this.hostDisplay = 'none';
71
+ if (this.cleanup)
72
+ this.cleanup();
73
+ this.closeEmitter.emit();
74
+ }
75
+ /**
76
+ * Update the dropdown's middleware and position.
77
+ */
78
+ async update() {
79
+ await this.updateMiddleware();
80
+ }
81
+ async handleMouseDown(event) {
82
+ if (!this.open)
83
+ return;
84
+ const composedPath = event.composedPath();
85
+ const withinBounds = composedPath.includes(this.element) ||
86
+ (this.referenceElement instanceof globalThis.Element &&
87
+ composedPath.includes(this.referenceElement));
88
+ if (!withinBounds)
89
+ await this.close();
90
+ }
91
+ async updateReferenceElement() {
92
+ var _a;
93
+ this.disconnectReferenceElement();
94
+ const resolvedTarget = typeof this.target === 'function' ? this.target() : this.target;
95
+ if (typeof resolvedTarget === 'string') {
96
+ const element = document.querySelector(resolvedTarget);
97
+ if (element === null)
98
+ throw new Error('String `target` must resolve to an Element.');
99
+ this.referenceElement = element;
100
+ }
101
+ else
102
+ this.referenceElement = resolvedTarget;
103
+ if (!(this.referenceElement instanceof globalThis.Element))
104
+ return;
105
+ this.referenceElement.setAttribute('aria-expanded', 'false');
106
+ this.referenceElement.addEventListener('click', this.boundReferenceClick);
107
+ this.referenceElement.addEventListener('focusout', this.boundFocusout);
108
+ this.referenceElement.addEventListener('keydown', this.boundEscape);
109
+ if (this.element.role === 'menu') {
110
+ (_a = this.referenceElement).id || (_a.id = `qds-dropdown-trigger-${autoIncrementingId}`);
111
+ this.hostAriaLabelledBy = this.referenceElement.id;
112
+ }
113
+ }
114
+ async updateMiddleware() {
115
+ this.middleware = [
116
+ offset({
117
+ ...this.offsetOptions,
118
+ mainAxis: propertyToPx(this.element, '--qds-accessory-gap-floating') ?? 0,
119
+ }),
120
+ !this.noFlip &&
121
+ flip({
122
+ crossAxis: this.noShift,
123
+ ...this.flipOptions,
124
+ }),
125
+ !this.noShift &&
126
+ shift({
127
+ limiter: limitShift(),
128
+ ...this.shiftOptions,
129
+ }),
130
+ ].filter((middleware) => middleware !== false);
131
+ await this.updatePosition();
132
+ }
133
+ async updatePosition() {
134
+ invariant(this.referenceElement);
135
+ const { x, y, strategy } = await computePosition(this.referenceElement, this.element, {
136
+ middleware: this.middleware,
137
+ placement: this.placement,
138
+ strategy: this.strategy,
139
+ });
140
+ this.hostPosition = strategy;
141
+ this.hostTransform = `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`;
142
+ }
143
+ startAutoUpdate() {
144
+ invariant(this.referenceElement);
145
+ if (this.cleanup)
146
+ this.cleanup();
147
+ this.cleanup = autoUpdate(this.referenceElement, this.element, () => {
148
+ ignorePromise(this.updatePosition());
149
+ }, this.autoUpdateOptions);
150
+ }
151
+ async componentWillLoad() {
152
+ var _a, _b;
153
+ this.hostDisplay = 'none';
154
+ (_a = this.element).role ?? (_a.role = 'menu');
155
+ (_b = this.element).id || (_b.id = `qds-dropdown-${autoIncrementingId}`);
156
+ await this.updateReferenceElement();
157
+ autoIncrementingId += 1;
158
+ await this.updateMiddleware();
159
+ }
160
+ disconnectedCallback() {
161
+ this.disconnectReferenceElement();
162
+ }
163
+ render() {
164
+ return (h(Host, { "aria-labelledby": this.hostAriaLabelledBy, onKeyDown: this.boundEscape, onFocusout: this.boundFocusout, style: {
165
+ display: this.hostDisplay,
166
+ position: this.hostPosition,
167
+ transform: this.hostTransform,
168
+ } }, h("slot", null)));
169
+ }
170
+ async handleFocusOut(event) {
171
+ if (!(event instanceof FocusEvent))
172
+ return;
173
+ const { relatedTarget } = event;
174
+ if (relatedTarget instanceof globalThis.Element &&
175
+ !this.element.contains(relatedTarget) &&
176
+ this.referenceElement !== relatedTarget)
177
+ await this.close();
178
+ }
179
+ async handleEscape(event) {
180
+ if (!(event instanceof KeyboardEvent) ||
181
+ event.key !== 'Escape' ||
182
+ (event.target !== this.referenceElement &&
183
+ event.target instanceof globalThis.Element &&
184
+ event.target.closest('qds-dropdown') !== this.element))
185
+ return;
186
+ const cancelEvent = this.cancelEmitter.emit();
187
+ if (cancelEvent.defaultPrevented)
188
+ return;
189
+ await this.close();
190
+ if (this.referenceElement instanceof globalThis.HTMLElement ||
191
+ this.referenceElement instanceof globalThis.SVGElement)
192
+ this.referenceElement.focus();
193
+ }
194
+ async handleReferenceClick() {
195
+ if (!this.disabled)
196
+ await (this.open ? this.close() : this.show());
197
+ }
198
+ disconnectReferenceElement() {
199
+ this.hostAriaLabelledBy = undefined;
200
+ if (!(this.referenceElement instanceof globalThis.Element))
201
+ return;
202
+ this.referenceElement.removeEventListener('click', this.boundReferenceClick);
203
+ this.referenceElement.removeEventListener('focusout', this.boundFocusout);
204
+ this.referenceElement.removeEventListener('keydown', this.boundEscape);
205
+ this.referenceElement.removeAttribute('aria-expanded');
206
+ this.referenceElement.removeAttribute('aria-controls');
207
+ }
208
+ get element() { return this; }
209
+ static get watchers() { return {
210
+ "target": ["updateReferenceElement"],
211
+ "flipOptions": ["updateMiddleware"],
212
+ "noFlip": ["updateMiddleware"],
213
+ "noShift": ["updateMiddleware"],
214
+ "offsetOptions": ["updateMiddleware"],
215
+ "shiftOptions": ["updateMiddleware"],
216
+ "placement": ["updatePosition"],
217
+ "strategy": ["updatePosition"],
218
+ "autoUpdateOptions": ["startAutoUpdate"]
219
+ }; }
220
+ static get style() { return dropdownCss; }
221
+ }, [1, "qds-dropdown", {
222
+ "autoUpdateOptions": [16],
223
+ "disabled": [1028],
224
+ "flipOptions": [16],
225
+ "noFlip": [4, "no-flip"],
226
+ "noShift": [4, "no-shift"],
227
+ "offsetOptions": [16],
228
+ "placement": [1],
229
+ "shiftOptions": [16],
230
+ "strategy": [1],
231
+ "target": [1],
232
+ "hostAriaLabelledBy": [32],
233
+ "hostDisplay": [32],
234
+ "hostPosition": [32],
235
+ "hostTransform": [32],
236
+ "show": [64],
237
+ "close": [64],
238
+ "update": [64]
239
+ }, [[4, "click", "handleMouseDown"]]]);
240
+ function defineCustomElement$1() {
241
+ if (typeof customElements === "undefined") {
242
+ return;
243
+ }
244
+ const components = ["qds-dropdown"];
245
+ components.forEach(tagName => { switch (tagName) {
246
+ case "qds-dropdown":
247
+ if (!customElements.get(tagName)) {
248
+ customElements.define(tagName, Dropdown);
249
+ }
250
+ break;
251
+ } });
252
+ }
253
+
254
+ const QdsDropdown = Dropdown;
255
+ const defineCustomElement = defineCustom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AAC,KAAK,EAAE,CAAA;GAChC;EAMO,MAAM,oBAAoB;IAChC,IAAI,CAAC,IAAI,CAAC,QAAQ;MAAE,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;GACnE;EAMO,0BAA0B;IAChC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;IAEnC,IAAI,EAAE,IAAI,CAAC,gBAAgB,YAAY,UAAU,CAAC,OAAO,CAAC;MAAE,OAAM;IAElE,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC5E,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IACzE,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACtE,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAA;IACtD,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,eAAe,CAAC,CAAA;GACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/dropdown/dropdown.css?tag=qds-dropdown&encapsulation=shadow","./src/components/dropdown/dropdown.tsx"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: © 2023 Schneider Electric\n *\n * SPDX-License-Identifier: LGPL-2.1-only\n */\n\n@import url('../shared.css');\n\n:host {\n background: var(--qds-theme-accessory-background);\n border-radius: var(--qds-accessory-border-radius);\n box-shadow: var(--qds-theme-accessory-elevation);\n display: inline-block;\n left: 0;\n top: 0;\n}\n","// SPDX-FileCopyrightText: © 2023 Schneider Electric\n//\n// SPDX-License-Identifier: LGPL-2.1-only\n\nimport type {\n AutoUpdateOptions,\n DetectOverflowOptions,\n FlipOptions,\n Middleware,\n Placement,\n ReferenceElement,\n ShiftOptions,\n Strategy,\n} from '@floating-ui/dom'\nimport {\n autoUpdate,\n computePosition,\n flip,\n limitShift,\n offset,\n shift,\n} from '@floating-ui/dom'\nimport type { ComponentInterface, EventEmitter } from '@stencil/core'\nimport {\n Component,\n Element,\n Event,\n h,\n Host,\n Listen,\n Method,\n Prop,\n State,\n Watch,\n} from '@stencil/core'\n\nimport type { OffsetOptions } from '../../helpers'\nimport {\n ignorePromise,\n invariant,\n propertyToPx,\n roundByDPR,\n} from '../../helpers'\n\nlet autoIncrementingId = 1\n\n/**\n * @experimental\n * @slot Content to display in the dropdown.\n * @see https://quartz.se.com/build/components/dropdown\n */\n@Component({\n tag: 'qds-dropdown',\n shadow: true,\n styleUrl: 'dropdown.css',\n})\nexport class Dropdown implements ComponentInterface {\n /**\n * Options to pass to Floating UI's\n * [`autoUpdate()` function](https://floating-ui.com/docs/autoUpdate).\n *\n * @see https://floating-ui.com/docs/autoupdate#options\n */\n @Prop() public readonly autoUpdateOptions?: AutoUpdateOptions\n\n /**\n * Prevents the dropdown from being shown by user interaction. The dropdown\n * can still be displayed by calling the `show()` method.\n */\n @Prop({ mutable: true }) public disabled = false\n\n /**\n * Options to pass to Floating UI's\n * [`flip` middleware](https://floating-ui.com/docs/flip).\n *\n * The [`crossAxis` option](https://floating-ui.com/docs/flip#crossaxis) is\n * set to the value of the `noShift` property by default for interoperability\n * with the [`shift` middleware](https://floating-ui.com/docs/shift).\n *\n * @see https://floating-ui.com/docs/flip#options\n */\n @Prop() public readonly flipOptions?: Partial<\n DetectOverflowOptions & FlipOptions\n >\n\n /**\n * Disable Floating UI's\n * [`flip` middleware](https://floating-ui.com/docs/flip).\n */\n @Prop() public readonly noFlip: boolean = false\n\n /**\n * Disable Floating UI's\n * [`shift` middleware](https://floating-ui.com/docs/shift).\n */\n @Prop() public readonly noShift: boolean = false\n\n /**\n * Options to pass to Floating UI's\n * [`offset` middleware](https://floating-ui.com/docs/offset).\n *\n * The [`mainAxis` option](https://floating-ui.com/docs/offset#mainaxis) is\n * not supported.\n *\n * @see https://floating-ui.com/docs/offset#options\n */\n @Prop() public readonly offsetOptions?: OffsetOptions\n\n /**\n * Where to place the dropdown relative to the `target`.\n *\n * @see https://floating-ui.com/docs/tutorial#placements\n */\n @Prop() public readonly placement: Placement = 'bottom-start'\n\n /**\n * Options to pass to Floating UI's\n * [`shift` middleware](https://floating-ui.com/docs/shift).\n *\n * @see https://floating-ui.com/docs/shift#options\n */\n @Prop() public readonly shiftOptions?: Partial<\n DetectOverflowOptions & ShiftOptions\n >\n\n /**\n * The CSS position strategy to use.\n *\n * @see https://floating-ui.com/docs/computeposition#strategy\n */\n @Prop() public readonly strategy?: Strategy\n\n /**\n * The trigger element that will trigger the dropdown. The target specified\n * can be any of the follow:\n *\n * - A CSS selector string\n * - A reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element) or\n * [Virtual Element](https://floating-ui.com/docs/virtual-elements)\n * - A function returning a reference to an\n * [`Element`](https://developer.mozilla.org/docs/Web/API/Element),\n * [Virtual Element](https://floating-ui.com/docs/virtual-elements),\n * or a CSS selector string\n */\n @Prop() public readonly target!:\n | ReferenceElement\n | string\n | (() => ReferenceElement | string)\n\n /**\n * Emitted when the user instructs the browser that they wish to dismiss the\n * current open dropdown by pressing the `Esc` key.\n *\n * When a dropdown is dismissed with the `Esc` key, both the `qdsCancel` and\n * `qdsClose` events are emitted.\n */\n @Event({ eventName: 'qdsCancel', bubbles: false })\n private readonly cancelEmitter!: EventEmitter<void>\n\n /**\n * Emitted when the dropdown is closed.\n */\n @Event({ eventName: 'qdsClose', bubbles: false, cancelable: false })\n private readonly closeEmitter!: EventEmitter<void>\n\n @Element() private readonly element!: HTMLQdsDropdownElement\n\n @State() private hostAriaLabelledBy?: string\n\n @State() private hostDisplay?: string\n\n @State() private hostPosition?: string\n\n @State() private hostTransform?: string\n\n private cleanup?: () => void\n\n private middleware?: Middleware[]\n\n private referenceElement?: ReferenceElement\n\n private open = false\n\n /**\n * Show the dropdown.\n */\n @Method()\n public async show(): Promise<void> {\n if (this.open) return\n\n if (this.referenceElement instanceof globalThis.Element) {\n this.referenceElement.setAttribute('aria-expanded', 'true')\n this.referenceElement.setAttribute('aria-controls', this.element.id)\n }\n\n this.open = true\n this.hostDisplay = undefined\n this.startAutoUpdate()\n }\n\n /**\n * Close the dropdown.\n */\n @Method()\n public async close(): Promise<void> {\n if (!this.open) return\n\n if (this.referenceElement instanceof globalThis.Element) {\n this.referenceElement.setAttribute('aria-expanded', 'false')\n this.referenceElement.removeAttribute('aria-controls')\n }\n\n this.open = false\n this.hostDisplay = 'none'\n if (this.cleanup) this.cleanup()\n\n this.closeEmitter.emit()\n }\n\n /**\n * Update the dropdown's middleware and position.\n */\n @Method()\n public async update(): Promise<void> {\n await this.updateMiddleware()\n }\n\n @Listen('click', { target: 'document' })\n protected async handleMouseDown(event: MouseEvent): Promise<void> {\n if (!this.open) return\n\n const composedPath = event.composedPath()\n const withinBounds =\n composedPath.includes(this.element) ||\n (this.referenceElement instanceof globalThis.Element &&\n composedPath.includes(this.referenceElement))\n if (!withinBounds) await this.close()\n }\n\n @Watch('target')\n private async updateReferenceElement(): Promise<void> {\n this.disconnectReferenceElement()\n\n const resolvedTarget =\n typeof this.target === 'function' ? this.target() : this.target\n if (typeof resolvedTarget === 'string') {\n const element = document.querySelector(resolvedTarget)\n if (element === null)\n throw new Error('String `target` must resolve to an Element.')\n this.referenceElement = element\n } else this.referenceElement = resolvedTarget\n\n if (!(this.referenceElement instanceof globalThis.Element)) return\n\n this.referenceElement.setAttribute('aria-expanded', 'false')\n this.referenceElement.addEventListener('click', this.boundReferenceClick)\n this.referenceElement.addEventListener('focusout', this.boundFocusout)\n this.referenceElement.addEventListener('keydown', this.boundEscape)\n if (this.element.role === 'menu') {\n this.referenceElement.id ||= `qds-dropdown-trigger-${autoIncrementingId}`\n this.hostAriaLabelledBy = this.referenceElement.id\n }\n }\n\n @Watch('flipOptions')\n @Watch('noFlip')\n @Watch('noShift')\n @Watch('offsetOptions')\n @Watch('shiftOptions')\n private async updateMiddleware(): Promise<void> {\n this.middleware = [\n offset({\n ...this.offsetOptions,\n mainAxis:\n propertyToPx(this.element, '--qds-accessory-gap-floating') ?? 0,\n }),\n !this.noFlip &&\n flip({\n crossAxis: this.noShift,\n ...this.flipOptions,\n }),\n !this.noShift &&\n shift({\n limiter: limitShift(),\n ...this.shiftOptions,\n }),\n ].filter((middleware): middleware is Middleware => middleware !== false)\n await this.updatePosition()\n }\n\n @Watch('placement')\n @Watch('strategy')\n private async updatePosition(): Promise<void> {\n invariant(this.referenceElement)\n\n const { x, y, strategy } = await computePosition(\n this.referenceElement,\n this.element,\n {\n middleware: this.middleware,\n placement: this.placement,\n strategy: this.strategy,\n },\n )\n this.hostPosition = strategy\n this.hostTransform = `translate(${roundByDPR(x)}px,${roundByDPR(y)}px)`\n }\n\n @Watch('autoUpdateOptions')\n private startAutoUpdate(): void {\n invariant(this.referenceElement)\n\n if (this.cleanup) this.cleanup()\n this.cleanup = autoUpdate(\n this.referenceElement,\n this.element,\n () => {\n ignorePromise(this.updatePosition())\n },\n this.autoUpdateOptions,\n )\n }\n\n public async componentWillLoad(): Promise<void> {\n this.hostDisplay = 'none'\n this.element.role ??= 'menu'\n this.element.id ||= `qds-dropdown-${autoIncrementingId}`\n await this.updateReferenceElement()\n autoIncrementingId += 1\n await this.updateMiddleware()\n }\n\n public disconnectedCallback(): void {\n this.disconnectReferenceElement()\n }\n\n public render() {\n return (\n <Host\n aria-labelledby={this.hostAriaLabelledBy}\n onKeyDown={this.boundEscape}\n onFocusout={this.boundFocusout}\n style={{\n display: this.hostDisplay,\n position: this.hostPosition,\n transform: this.hostTransform,\n }}\n >\n <slot />\n </Host>\n )\n }\n\n private async handleFocusOut(event: Event): Promise<void> {\n if (!(event instanceof FocusEvent)) return\n const { relatedTarget } = event\n\n if (\n relatedTarget instanceof globalThis.Element &&\n !this.element.contains(relatedTarget) &&\n this.referenceElement !== relatedTarget\n )\n await this.close()\n }\n\n private readonly boundFocusout = (event: Event): void => {\n ignorePromise(this.handleFocusOut(event))\n }\n\n private async handleEscape(event: Event): Promise<void> {\n if (\n !(event instanceof KeyboardEvent) ||\n event.key !== 'Escape' ||\n (event.target !== this.referenceElement &&\n event.target instanceof globalThis.Element &&\n event.target.closest('qds-dropdown') !== this.element)\n )\n return\n\n const cancelEvent = this.cancelEmitter.emit()\n if (cancelEvent.defaultPrevented) return\n\n await this.close()\n if (\n this.referenceElement instanceof globalThis.HTMLElement ||\n this.referenceElement instanceof globalThis.SVGElement\n )\n this.referenceElement.focus()\n }\n\n private readonly boundEscape = (event: Event): void => {\n ignorePromise(this.handleEscape(event))\n }\n\n private async handleReferenceClick(): Promise<void> {\n if (!this.disabled) await (this.open ? this.close() : this.show())\n }\n\n private readonly boundReferenceClick = (): void => {\n ignorePromise(this.handleReferenceClick())\n }\n\n private disconnectReferenceElement(): void {\n this.hostAriaLabelledBy = undefined\n\n if (!(this.referenceElement instanceof globalThis.Element)) return\n\n this.referenceElement.removeEventListener('click', this.boundReferenceClick)\n this.referenceElement.removeEventListener('focusout', this.boundFocusout)\n this.referenceElement.removeEventListener('keydown', this.boundEscape)\n this.referenceElement.removeAttribute('aria-expanded')\n this.referenceElement.removeAttribute('aria-controls')\n }\n}\n"],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../dist/types/components";
2
+
3
+ interface QdsIcon extends Components.QdsIcon, HTMLElement {}
4
+ export const QdsIcon: {
5
+ prototype: QdsIcon;
6
+ new (): QdsIcon;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: © 2023 Schneider Electric
3
+ *
4
+ * SPDX-License-Identifier: LGPL-2.1-only
5
+ */
6
+ import { I as Icon, d as defineCustomElement$1 } from './icon.js';
7
+
8
+ const QdsIcon = Icon;
9
+ const defineCustomElement = defineCustomElement$1;
10
+
11
+ export { QdsIcon, defineCustomElement };
12
+
13
+ //# sourceMappingURL=qds-icon.js.map
@@ -0,0 +1 @@
1
+ {"file":"qds-icon.js","mappings":";;;;;;;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../dist/types/components";
2
+
3
+ interface QdsInlineLink extends Components.QdsInlineLink, HTMLElement {}
4
+ export const QdsInlineLink: {
5
+ prototype: QdsInlineLink;
6
+ new (): QdsInlineLink;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,89 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: © 2023 Schneider Electric
3
+ *
4
+ * SPDX-License-Identifier: LGPL-2.1-only
5
+ */
6
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
7
+ import { p as pickFocusEventAttributes, i as inheritAriaAttributes, b as inheritAttributes } from './helpers.js';
8
+ import { d as defineCustomElement$2 } from './icon.js';
9
+
10
+ const inlineLinkCss = ":host{box-sizing:border-box}:host([hidden]){display:none !important}:host([hidden]){}:host *,:host *::before,:host *::after{box-sizing:inherit}:host{display:inline-block}.external{display:none;height:1.25em;-webkit-margin-start:var(--qds-text-icon-gap);margin-inline-start:var(--qds-text-icon-gap);vertical-align:text-top;width:1.25em}.inline-link{border-radius:var(--qds-focus-border-radius);color:var(--qds-theme-link-default)}.inline-link[rel~='external']>.external{display:inline-block}.inline-link:focus-visible{outline:var(--qds-theme-focus-border) solid var(--qds-focus-border-width)}.inline-link:visited{color:var(--qds-theme-link-visited)}[aria-disabled='true']{opacity:var(--qds-theme-disabled);pointer-events:none}";
11
+
12
+ const InlineLink = /*@__PURE__*/ proxyCustomElement(class InlineLink extends HTMLElement {
13
+ constructor() {
14
+ super();
15
+ this.__registerHost();
16
+ this.__attachShadow();
17
+ this.blurEmitter = createEvent(this, "qdsBlur", 2);
18
+ this.focusEmitter = createEvent(this, "qdsFocus", 2);
19
+ this.inheritedAttributes = {};
20
+ this.onBlur = (event) => {
21
+ this.blurEmitter.emit(pickFocusEventAttributes(event));
22
+ };
23
+ this.onFocus = (event) => {
24
+ this.focusEmitter.emit(pickFocusEventAttributes(event));
25
+ };
26
+ this.disabled = false;
27
+ this.download = undefined;
28
+ this.href = undefined;
29
+ this.hreflang = undefined;
30
+ this.referrerPolicy = undefined;
31
+ this.rel = undefined;
32
+ this.target = '_self';
33
+ }
34
+ get computedTabIndex() {
35
+ const parsedValue = Number.parseInt(this.inheritedAttributes.tabindex, 10);
36
+ return Number.isNaN(parsedValue) ? 0 : parsedValue;
37
+ }
38
+ onClick(event) {
39
+ if (this.disabled) {
40
+ event.preventDefault();
41
+ event.stopPropagation();
42
+ }
43
+ }
44
+ componentWillLoad() {
45
+ this.inheritedAttributes = {
46
+ ...inheritAriaAttributes(this.element),
47
+ ...inheritAttributes(this.element, ['tabindex']),
48
+ };
49
+ }
50
+ render() {
51
+ return (h("a", { "aria-disabled": this.disabled ? 'true' : 'false', class: "inline-link", download: this.download, href: this.href, hrefLang: this.hreflang, onBlur: this.onBlur, onFocus: this.onFocus, referrerPolicy: this.referrerPolicy, rel: this.rel, target: this.target, ...this.inheritedAttributes, tabIndex: this.disabled ? -1 : this.computedTabIndex }, h("slot", null), h("qds-icon", { class: "external", library: "system", name: "arrow-top-right-on-square" })));
52
+ }
53
+ static get delegatesFocus() { return true; }
54
+ get element() { return this; }
55
+ static get style() { return inlineLinkCss; }
56
+ }, [17, "qds-inline-link", {
57
+ "disabled": [1540],
58
+ "download": [8],
59
+ "href": [1],
60
+ "hreflang": [1],
61
+ "referrerPolicy": [1, "referrerpolicy"],
62
+ "rel": [1],
63
+ "target": [1]
64
+ }, [[0, "click", "onClick"]]]);
65
+ function defineCustomElement$1() {
66
+ if (typeof customElements === "undefined") {
67
+ return;
68
+ }
69
+ const components = ["qds-inline-link", "qds-icon"];
70
+ components.forEach(tagName => { switch (tagName) {
71
+ case "qds-inline-link":
72
+ if (!customElements.get(tagName)) {
73
+ customElements.define(tagName, InlineLink);
74
+ }
75
+ break;
76
+ case "qds-icon":
77
+ if (!customElements.get(tagName)) {
78
+ defineCustomElement$2();
79
+ }
80
+ break;
81
+ } });
82
+ }
83
+
84
+ const QdsInlineLink = InlineLink;
85
+ const defineCustomElement = defineCustomElement$1;
86
+
87
+ export { QdsInlineLink, defineCustomElement };
88
+
89
+ //# sourceMappingURL=qds-inline-link.js.map