@uh-design-system/component-library 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/component-library.cjs.js +1 -1
- package/dist/cjs/ds-accordion_3.cjs.entry.js +9 -6
- package/dist/cjs/ds-checkbox-group.cjs.entry.js +2 -3
- package/dist/cjs/ds-checkbox.cjs.entry.js +6 -4
- package/dist/cjs/ds-link-with-arrow.cjs.entry.js +2 -3
- package/dist/cjs/ds-link.cjs.entry.js +2 -3
- package/dist/cjs/ds-text-input.cjs.entry.js +11 -7
- package/dist/cjs/ds-visually-hidden.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{attributes-5f5b58be.js → utils-3412cbed.js} +41 -2
- package/dist/collection/components/00-foundations/icons/categories/actions.js +2 -0
- package/dist/collection/components/00-foundations/icons/icons.stories.js +1 -0
- package/dist/collection/components/01-base-components/ds-button/ds-button.css +6 -0
- package/dist/collection/components/01-base-components/ds-button/ds-button.js +4 -3
- package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.css +4 -0
- package/dist/collection/components/01-base-components/ds-checkbox/ds-checkbox.js +5 -2
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.css +6 -0
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.js +11 -6
- package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.stories.js +2 -2
- package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.css +1 -1
- package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.js +1 -1
- package/dist/collection/utils/attributes/attributes.js +14 -3
- package/dist/component-library/component-library.esm.js +1 -1
- package/dist/component-library/ds-accordion_3.entry.js +1 -1
- package/dist/component-library/ds-checkbox-group.entry.js +1 -1
- package/dist/component-library/ds-checkbox.entry.js +1 -1
- package/dist/component-library/ds-link-with-arrow.entry.js +1 -1
- package/dist/component-library/ds-link.entry.js +1 -1
- package/dist/component-library/ds-text-input.entry.js +1 -1
- package/dist/component-library/ds-visually-hidden.entry.js +1 -1
- package/dist/component-library/{attributes-7d09be1b.js → utils-cfc536bc.js} +1 -1
- package/dist/components/attributes.js +15 -3
- package/dist/components/ds-button2.js +5 -4
- package/dist/components/ds-checkbox2.js +6 -3
- package/dist/components/ds-icon2.js +3 -0
- package/dist/components/ds-text-input.js +12 -7
- package/dist/components/ds-visually-hidden2.js +2 -2
- package/dist/esm/component-library.js +1 -1
- package/dist/esm/ds-accordion_3.entry.js +8 -5
- package/dist/esm/ds-checkbox-group.entry.js +1 -2
- package/dist/esm/ds-checkbox.entry.js +6 -4
- package/dist/esm/ds-link-with-arrow.entry.js +1 -2
- package/dist/esm/ds-link.entry.js +1 -2
- package/dist/esm/ds-text-input.entry.js +11 -7
- package/dist/esm/ds-visually-hidden.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{attributes-7d09be1b.js → utils-cfc536bc.js} +38 -3
- package/dist/types/components/01-base-components/ds-text-input/ds-text-input.d.ts +2 -1
- package/dist/types/components.d.ts +2 -2
- package/dist/types/utils/attributes/attributes.d.ts +2 -1
- package/package.json +2 -2
- package/dist/cjs/utils-2ba5e075.js +0 -28
- package/dist/component-library/utils-5daa5bc0.js +0 -1
- package/dist/esm/utils-5daa5bc0.js +0 -24
|
@@ -3,6 +3,7 @@ import classNames from "classnames";
|
|
|
3
3
|
import { getOptionalText, getRequiredText } from "../../../utils/controls/controlUtils";
|
|
4
4
|
import { isValidation } from "../../../store";
|
|
5
5
|
import { idGenerator, getAriaLabel } from "../../../utils/utils";
|
|
6
|
+
import { inheritAttributes } from "../../../utils/attributes/attributes";
|
|
6
7
|
const INPUT_TYPE_ICONS_MAP = {
|
|
7
8
|
search: 'search',
|
|
8
9
|
};
|
|
@@ -12,6 +13,7 @@ const INPUT_TYPE_ACTION_BUTTON_ICON_MAP = {
|
|
|
12
13
|
};
|
|
13
14
|
const inputIdGenerator = idGenerator('ds-input');
|
|
14
15
|
export class DsTextInput {
|
|
16
|
+
inheritedAttributes = {};
|
|
15
17
|
suffixButtonElement;
|
|
16
18
|
inputElement;
|
|
17
19
|
assistiveTextId;
|
|
@@ -48,7 +50,7 @@ export class DsTextInput {
|
|
|
48
50
|
icon = '';
|
|
49
51
|
type = 'text';
|
|
50
52
|
ariaLabel;
|
|
51
|
-
|
|
53
|
+
ariaLabelledby;
|
|
52
54
|
ariaDescribedby;
|
|
53
55
|
hasFocus = false;
|
|
54
56
|
clearButtonVisible = false;
|
|
@@ -81,6 +83,9 @@ export class DsTextInput {
|
|
|
81
83
|
return this.label;
|
|
82
84
|
};
|
|
83
85
|
componentWillLoad() {
|
|
86
|
+
this.inheritedAttributes = {
|
|
87
|
+
...inheritAttributes(this, this.el),
|
|
88
|
+
};
|
|
84
89
|
this.setIds();
|
|
85
90
|
this.hasPrefixSlot = !!this.el.querySelector('[slot="prefix"]');
|
|
86
91
|
this.hasSuffixSlot = !!this.el.querySelector('[slot="suffix"]');
|
|
@@ -147,18 +152,18 @@ export class DsTextInput {
|
|
|
147
152
|
}
|
|
148
153
|
render() {
|
|
149
154
|
const inputType = this.type === 'password' && this.passwordInputVisible ? 'text' : this.type;
|
|
150
|
-
return (h(Fragment, { key: '
|
|
155
|
+
return (h(Fragment, { key: '6b5cc3e8f7fe00df47392eade88010d1f9faf7e1' }, h("div", { key: 'c5e72b94f444c3923a3d72fb08615a97a9a174c2', class: "ds-input--label-container" }, h("slot", { key: 'a27efdf7b2311fdf310ce5340adccac015c906b1', name: "label" }, h("label", { key: '3a0241a9c572eb4403c5d46eb6761b5121726bf9', htmlFor: this.identifier }, this.getLabelText())), h("slot", { key: '8ffec65634da10f44ea145d1efec86147c6dc296', name: "help-text" }, h("small", { key: 'a45d970a13bae23f2f488a969ee9184cc521680e', id: this.assistiveTextId }, this.assistiveText), h("ds-visually-hidden", { key: 'abea8540ddeed9f797cd28c63aabbc734b7bf083', id: this.visuallyHiddenAssistiveTextId }, this.hiddenAssistiveText))), h("div", { key: '9f162c62ee86782abb60344074544feb643c3c8b', onMouseDown: () => (this.inputActive = true), onMouseUp: () => (this.inputActive = false), onClick: e => this.handleInputContainerClick(e), class: classNames('ds-input--container', {
|
|
151
156
|
disabled: this.disabled,
|
|
152
157
|
readonly: this.readonly,
|
|
153
158
|
valid: !!this.successText,
|
|
154
|
-
invalid: !!this.
|
|
159
|
+
invalid: !!this.validationMessage,
|
|
155
160
|
focus: this.hasFocus,
|
|
156
161
|
active: !!this.inputActive,
|
|
157
|
-
}) }, this.renderPrefixContent(), h("input", { key: '
|
|
162
|
+
}) }, this.renderPrefixContent(), h("input", { key: '1c7c944a70012444caa83f7f0104f6e1992d3acb', ref: e => (this.inputElement = e), id: this.identifier, name: this.name, "aria-label": getAriaLabel(this.label, this.ariaLabel), "aria-labelledby": this.ariaLabelledby, "aria-describedby": this.ariaDescribedby ||
|
|
158
163
|
classNames(this.assistiveTextId, this.visuallyHiddenAssistiveTextId, {
|
|
159
164
|
[this.errorTextId]: Boolean(this.validationMessage),
|
|
160
165
|
[this.successTextId]: Boolean(this.successText),
|
|
161
|
-
}), "aria-invalid": Boolean(this.validationMessage) ? 'true' : 'false', disabled: this.disabled, required: this.required, readonly: this.readonly, value: this.value, type: inputType, min: this.min, max: this.max, maxlength: this.maxlength, pattern: this.pattern, placeholder: this.placeholder, autocomplete: this.autocomplete, onInput: this.handleInput, onFocus: () => (this.hasFocus = true), onBlur: this.handleBlur }), this.renderSuffixContent()), h("slot", { key: '
|
|
166
|
+
}), "aria-invalid": Boolean(this.validationMessage) ? 'true' : 'false', disabled: this.disabled, required: this.required, readonly: this.readonly, value: this.value, type: inputType, min: this.min, max: this.max, maxlength: this.maxlength, pattern: this.pattern, placeholder: this.placeholder, autocomplete: this.autocomplete, onInput: this.handleInput, onFocus: () => (this.hasFocus = true), onBlur: this.handleBlur, ...this.inheritedAttributes }), this.renderSuffixContent()), h("slot", { key: 'bdc4bbc3a0abe3668bcf18f719d50974ad12e1c4', name: "input-validity" }, h("ds-input-validity", { key: 'a392691fed93056f22673e5d20c6c4c099481181', id: this.errorTextId, text: this.validationMessage, type: "error", role: "alert" }), h("ds-input-validity", { key: '7e3b45928cdefed2c65b8c50fb4245527bae758e', id: this.successTextId, text: this.successText, type: "success", role: "status" }))));
|
|
162
167
|
}
|
|
163
168
|
static get is() { return "ds-text-input"; }
|
|
164
169
|
static get encapsulation() { return "scoped"; }
|
|
@@ -659,7 +664,7 @@ export class DsTextInput {
|
|
|
659
664
|
"attribute": "aria-label",
|
|
660
665
|
"reflect": false
|
|
661
666
|
},
|
|
662
|
-
"
|
|
667
|
+
"ariaLabelledby": {
|
|
663
668
|
"type": "string",
|
|
664
669
|
"mutable": false,
|
|
665
670
|
"complexType": {
|
package/dist/collection/components/01-base-components/ds-text-input/stories/ds-text-input.stories.js
CHANGED
|
@@ -41,7 +41,7 @@ export const Playground = {
|
|
|
41
41
|
options: textInputTypes,
|
|
42
42
|
},
|
|
43
43
|
ariaLabel: { name: 'aria-label', control: 'text' },
|
|
44
|
-
|
|
44
|
+
ariaLabelledby: { name: 'aria-labelledby', control: 'text' },
|
|
45
45
|
ariaDescribedby: { name: 'aria-describedby', control: 'text' },
|
|
46
46
|
autocomplete: { control: 'text' },
|
|
47
47
|
},
|
|
@@ -66,7 +66,7 @@ export const Playground = {
|
|
|
66
66
|
type: 'text',
|
|
67
67
|
autocomplete: '',
|
|
68
68
|
ariaLabel: '',
|
|
69
|
-
|
|
69
|
+
ariaLabelledby: '',
|
|
70
70
|
ariaDescribedby: '',
|
|
71
71
|
}
|
|
72
72
|
};
|
package/dist/collection/components/01-base-components/ds-visually-hidden/ds-visually-hidden.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
export class DsVisuallyHidden {
|
|
3
3
|
render() {
|
|
4
|
-
return (h("slot", { key: '
|
|
4
|
+
return (h("div", { key: 'f488f0f134c76c308763d47c57360e54ae299a06', class: "ds-visually-hidden" }, h("slot", { key: '20d5cdef8c333e5421c670e2558b511b1f235e7f' })));
|
|
5
5
|
}
|
|
6
6
|
static get is() { return "ds-visually-hidden"; }
|
|
7
7
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
const kebabToCamelCase = (str) => str.replace(/-./g, x => x[1].toUpperCase());
|
|
2
|
+
export const inheritSpecifiedAttributes = (el, attributes = []) => {
|
|
2
3
|
const attributeObject = {};
|
|
3
4
|
attributes.forEach(attr => {
|
|
4
5
|
if (el.hasAttribute(attr)) {
|
|
@@ -64,12 +65,22 @@ export const ariaAttributes = [
|
|
|
64
65
|
'aria-valuenow',
|
|
65
66
|
'aria-valuetext',
|
|
66
67
|
];
|
|
67
|
-
const kebabToCamelCase = (attr) => attr.replace(/-./g, x => x[1].toUpperCase());
|
|
68
68
|
export const getAriaAttributeArgTypes = (attrs) => attrs.reduce((acc, curr) => ((acc[kebabToCamelCase(curr)] = { control: 'text', name: curr }), acc), {});
|
|
69
69
|
export const inheritAriaAttributes = (el, ignoreList) => {
|
|
70
70
|
let attributesToInherit = [...ariaAttributes];
|
|
71
71
|
if (ignoreList && ignoreList.length > 0) {
|
|
72
72
|
attributesToInherit = attributesToInherit.filter(attr => !ignoreList.includes(attr));
|
|
73
73
|
}
|
|
74
|
-
return
|
|
74
|
+
return inheritSpecifiedAttributes(el, attributesToInherit);
|
|
75
|
+
};
|
|
76
|
+
export const inheritAttributes = (component, elem) => {
|
|
77
|
+
const attributesToIgnore = new Set(['class', 'style', ...ariaAttributes]);
|
|
78
|
+
const propsToIgnore = new Set(Object.keys(component));
|
|
79
|
+
const attributes = {};
|
|
80
|
+
for (const attr of elem.attributes) {
|
|
81
|
+
if (!propsToIgnore.has(kebabToCamelCase(attr.name)) && !attributesToIgnore.has(attr.name)) {
|
|
82
|
+
attributes[attr.name] = attr.value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return attributes;
|
|
75
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as i}from"./index-434995e1.js";export{s as setNonce}from"./index-434995e1.js";import{g as t}from"./app-globals-0f993ce5.js";(()=>{const i=import.meta.url,t={};return""!==i&&(t.resourcesUrl=new URL(".",i).href),e(t)})().then((async e=>(await t(),i([["ds-accordion_3",[[1,"ds-accordion",{variant:[1],borderAligned:[4,"border-aligned"],openByDefault:[4,"open-by-default"],accordionId:[1,"accordion-id"],headingLevel:[2,"heading-level"],useCloseButton:[4,"use-close-button"],closeButtonLabel:[1,"close-button-label"],hideTopBorder:[4,"hide-top-border"],isExpanded:[32]},null,{isExpanded:["watchHandler"]}],[6,"ds-button",{value:[1],variant:[1],colour:[1],size:[1],fontWeight:[1,"font-weight"],icon:[1],iconPosition:[1,"icon-position"],type:[1],disabled:[4],fullWidth:[4,"full-width"],ariaDisabled:[1,"aria-disabled"]}],[1,"ds-icon",{name:[1],colour:[1],size:[1],dsTitle:[1,"title"],role:[1],hidden:[4],message:[32]}]]],["ds-input-validity",[[0,"ds-input-validity",{text:[1],type:[1],validityRole:[1,"role"],identifier:[32]}]]],["ds-text-input",[[70,"ds-text-input",{label:[1],placeholder:[1],identifier:[1,"id"],name:[1],disabled:[4],optional:[4],required:[4],readonly:[4],value:[1],min:[2],max:[2],maxlength:[2],pattern:[1],autocomplete:[1],optionalText:[1,"optional-text"],errorText:[1,"error-text"],successText:[1,"success-text"],assistiveText:[1,"assistive-text"],actionButtonAriaLabel:[1,"action-button-aria-label"],hiddenAssistiveText:[1,"hidden-assistive-text"],prefixText:[1,"prefix-text"],suffixText:[1,"suffix-text"],icon:[1],type:[1],ariaLabel:[1,"aria-label"],
|
|
1
|
+
import{p as e,b as i}from"./index-434995e1.js";export{s as setNonce}from"./index-434995e1.js";import{g as t}from"./app-globals-0f993ce5.js";(()=>{const i=import.meta.url,t={};return""!==i&&(t.resourcesUrl=new URL(".",i).href),e(t)})().then((async e=>(await t(),i([["ds-accordion_3",[[1,"ds-accordion",{variant:[1],borderAligned:[4,"border-aligned"],openByDefault:[4,"open-by-default"],accordionId:[1,"accordion-id"],headingLevel:[2,"heading-level"],useCloseButton:[4,"use-close-button"],closeButtonLabel:[1,"close-button-label"],hideTopBorder:[4,"hide-top-border"],isExpanded:[32]},null,{isExpanded:["watchHandler"]}],[6,"ds-button",{value:[1],variant:[1],colour:[1],size:[1],fontWeight:[1,"font-weight"],icon:[1],iconPosition:[1,"icon-position"],type:[1],disabled:[4],fullWidth:[4,"full-width"],ariaDisabled:[1,"aria-disabled"]}],[1,"ds-icon",{name:[1],colour:[1],size:[1],dsTitle:[1,"title"],role:[1],hidden:[4],message:[32]}]]],["ds-input-validity",[[0,"ds-input-validity",{text:[1],type:[1],validityRole:[1,"role"],identifier:[32]}]]],["ds-text-input",[[70,"ds-text-input",{label:[1],placeholder:[1],identifier:[1,"id"],name:[1],disabled:[4],optional:[4],required:[4],readonly:[4],value:[1],min:[2],max:[2],maxlength:[2],pattern:[1],autocomplete:[1],optionalText:[1,"optional-text"],errorText:[1,"error-text"],successText:[1,"success-text"],assistiveText:[1,"assistive-text"],actionButtonAriaLabel:[1,"action-button-aria-label"],hiddenAssistiveText:[1,"hidden-assistive-text"],prefixText:[1,"prefix-text"],suffixText:[1,"suffix-text"],icon:[1],type:[1],ariaLabel:[1,"aria-label"],ariaLabelledby:[1,"aria-labelledby"],ariaDescribedby:[1,"aria-describedby"],hasFocus:[32],clearButtonVisible:[32],passwordInputVisible:[32],inputActive:[32],validationMessage:[32],togglePasswordVisibility:[64],clearInput:[64]}]]],["ds-checkbox",[[65,"ds-checkbox",{identifier:[1,"id"],checked:[1028],legend:[1],assistiveText:[1,"assistive-text"],text:[1],indeterminate:[4],disabled:[4],errorText:[1,"error-text"],errorsDisabled:[4,"data-errors-disabled"],required:[4],optional:[4],optionalText:[1,"optional-text"],ariaLabel:[1,"aria-label"],value:[32],validationMessage:[32]}]]],["ds-checkbox-group",[[1,"ds-checkbox-group",{legend:[1],assistiveText:[1,"assistive-text"],direction:[1],errorText:[1,"error-text"],text:[1],checked:[4],disabled:[4],childElementsCount:[32],checkedChildElementCount:[32],isIndeterminate:[32],indeterminateChildCheckboxCount:[32],setChecked:[64]},[[0,"dsCheckboxGroupIndeterminateChildChange","listenIndeterminateChildChange"],[0,"dsCheckboxInput","listenCheckboxChange"],[0,"dsCheckboxGroupChange","listenCheckboxGroupChange"]],{disabled:["watchCheckboxDisabledChange"],checked:["watchCheckedChange"],isIndeterminate:["watchIndeterminateChange"],checkedChildElementCount:["watchCheckedChildElementCountChange"]}]]],["ds-visually-hidden",[[1,"ds-visually-hidden"]]],["ds-link",[[1,"ds-link",{text:[1],size:[1],variant:[1],weight:[1],icon:[1025],iconPosition:[1025,"icon-position"],iconTitle:[1,"icon-title"],iconHidden:[4,"icon-hidden"],href:[1],target:[1],download:[4],language:[1,"lang"],ariaLabel:[1,"aria-label"]}]]],["ds-link-with-arrow",[[1,"ds-link-with-arrow",{text:[1],iconPosition:[1,"icon-position"],href:[1],target:[1],language:[1,"lang"],ariaLabel:[1,"aria-label"]}]]]],e))));
|