@uh-design-system/component-library 0.2.2-alpha.0 → 0.2.2-alpha.7
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 +2 -2
- package/dist/cjs/ds-accordion_2.cjs.entry.js +35 -32
- package/dist/cjs/ds-button_2.cjs.entry.js +55 -50
- package/dist/cjs/ds-text-input.cjs.entry.js +50 -27
- package/dist/cjs/{index-d03b8350.js → index-fd4f6cd2.js} +28 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/01-base-components/ds-accordion/ds-accordion.js +27 -27
- package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.stories.js +6 -1
- package/dist/collection/components/01-base-components/ds-button/ds-button.js +54 -50
- package/dist/collection/components/01-base-components/ds-button/stories/ds-button.stories.js +29 -9
- package/dist/collection/components/01-base-components/ds-icon/ds-icon.js +7 -7
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.examples.stories.js +1 -1
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.js +52 -31
- package/dist/collection/components/01-base-components/ds-text-input/ds-text-input.stories.js +2 -2
- package/dist/collection/utils/typography/typographyUtils.js +1 -1
- package/dist/component-library/component-library.css +1 -0
- package/dist/component-library/component-library.esm.js +1 -1
- package/dist/component-library/ds-accordion_2.entry.js +1 -1
- package/dist/component-library/ds-button_2.entry.js +1 -1
- package/dist/component-library/ds-text-input.entry.js +1 -1
- package/dist/component-library/index-4200d514.js +2 -0
- package/dist/components/ds-accordion.js +27 -26
- package/dist/components/ds-button2.js +54 -49
- package/dist/components/ds-icon2.js +7 -5
- package/dist/components/ds-text-input.js +50 -27
- package/dist/components/index2.js +28 -1
- package/dist/esm/component-library.js +3 -3
- package/dist/esm/ds-accordion_2.entry.js +35 -32
- package/dist/esm/ds-button_2.entry.js +55 -50
- package/dist/esm/ds-text-input.entry.js +50 -27
- package/dist/esm/{index-dfeefc7e.js → index-4200d514.js} +28 -1
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/01-base-components/ds-text-input/ds-text-input.d.ts +2 -2
- package/dist/types/components.d.ts +3 -3
- package/package.json +16 -3
- package/dist/component-library/index-dfeefc7e.js +0 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-fd4f6cd2.js');
|
|
6
6
|
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
7
|
|
|
8
8
|
/*
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["ds-accordion_2.cjs",[[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"],"isExpanded":[32]},null,{"isExpanded":["watchHandler"]}],[1,"ds-icon",{"name":[1],"colour":[1],"size":[1],"title":[1],"role":[1],"hidden":[4],"message":[32]}]]],["ds-button_2.cjs",[[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],"ariaDisabled":[1,"aria-disabled"]}],[1,"ds-visually-hidden"]]],["ds-text-input.cjs",[[6,"ds-text-input",{"label":[1],"placeholder":[1],"
|
|
22
|
+
return index.bootstrapLazy([["ds-accordion_2.cjs",[[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"],"isExpanded":[32]},null,{"isExpanded":["watchHandler"]}],[1,"ds-icon",{"name":[1],"colour":[1],"size":[1],"title":[1],"role":[1],"hidden":[4],"message":[32]}]]],["ds-button_2.cjs",[[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],"ariaDisabled":[1,"aria-disabled"]}],[1,"ds-visually-hidden"]]],["ds-text-input.cjs",[[6,"ds-text-input",{"label":[1],"placeholder":[1],"dsId":[1,"ds-id"],"name":[1],"disabled":[4],"required":[4],"readonly":[4],"value":[1],"min":[2],"max":[2],"maxlength":[2],"pattern":[1],"autocomplete":[1],"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],"togglePasswordVisibility":[64],"clearInput":[64]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-fd4f6cd2.js');
|
|
6
6
|
const index$1 = require('./index-5b0b9d4c.js');
|
|
7
7
|
|
|
8
8
|
const dsAccordionCss = ".ds-accordion__open-button{color:var(--ds-textColor-default, #1A1A1A);all:unset;box-sizing:border-box;display:flex;flex-direction:row;gap:8px;width:100%}.ds-accordion__open-button:hover{cursor:pointer;background:var(--ds-bgColor-transparent-onLight-hover, rgba(0, 0, 0, 0.1019607843))}.ds-accordion__open-button:hover.ds-accordion--border-aligned{padding-inline:16px;margin-inline:0}.ds-accordion__open-button:active{background:var(--ds-bgColor-transparent-onLight-active, rgba(0, 0, 0, 0.1490196078))}.ds-accordion__open-button:active.ds-accordion--border-aligned{padding-inline:16px;margin-inline:0}.ds-accordion__open-button:focus{background:var(--ds-bgColor-transparent-onLight-hover, rgba(0, 0, 0, 0.1019607843));box-shadow:0px 0px 0px 1px var(--ds-palette-black)}.ds-accordion__open-button:focus.ds-accordion--border-aligned{padding-inline:16px;margin-inline:0}.ds-accordion__open-button.ds-accordion--default{padding:16px;font-family:var(--ds-fontFamily-body);font-size:var(--ds-fontSize-18);font-weight:600;line-height:27px;letter-spacing:var(--letterSpacing-wide)}.ds-accordion__open-button.ds-accordion--compact{font-size:var(--ds-fontSize-16);padding:12px 16px 12px 16px;line-height:24px;font-weight:600}.ds-accordion__open-button.ds-accordion--border-aligned{padding-inline:0;padding-inline:0;margin-inline:16px}.ds-accordion__open-button[aria-expanded=false]{border-bottom:1px solid var(--ds-borderColor-light, #CCCCCC)}.ds-accordion__panel--expanded{border-bottom:1px solid var(--ds-borderColor-light, #CCCCCC)}.ds-accordion__content{color:var(--ds-textColor-default, #1A1A1A);font-family:var(--ds-fontFamily-body);padding:16px}.ds-accordion__content .ds-accordion--default{font-size:var(--ds-fontSize-18);font-weight:400;line-height:27px;letter-spacing:var(--ds-letterSpacing-wide)}.ds-accordion__content .ds-accordion--compact{font-size:var(--fontSize-16);font-weight:400;line-height:24px;letter-spacing:var(--letterSpacing-wide)}.ds-accordion__close-button{color:var(--ds-textColor-default, #1A1A1A);all:unset;border-bottom:1px solid var(--ds-borderColor-light, #CCCCCC);display:flex;flex-direction:row;gap:8px;font-family:var(--ds-fontFamily-body);letter-spacing:var(--ds-letterSpacing-wide);width:100%}.ds-accordion__close-button:hover{cursor:pointer;background:var(--ds-bgColor-transparent-onLight-hover, rgba(0, 0, 0, 0.1019607843))}.ds-accordion__close-button:hover.ds-accordion--border-aligned{padding-inline:16px;margin-inline:0}.ds-accordion__close-button:active{background:var(--ds-bgColor-transparent-onLight-active, rgba(0, 0, 0, 0.1490196078))}.ds-accordion__close-button:active.ds-accordion--border-aligned{padding-inline:16px;margin-inline:0}.ds-accordion__close-button:focus{background:var(--ds-bgColor-transparent-onLight-hover, rgba(0, 0, 0, 0.1019607843));box-shadow:0px 0px 0px 1px var(--ds-palette-black)}.ds-accordion__close-button:focus.ds-accordion--border-aligned{padding-inline:16px;margin-inline:0}.ds-accordion__close-button.ds-accordion--default{padding:16px;font-family:var(--ds-fontFamily-body);font-size:var(--ds-fontSize-18);font-weight:600;line-height:27px;letter-spacing:var(--letterSpacing-wide)}.ds-accordion__close-button.ds-accordion--compact{font-size:var(--ds-fontSize-16);padding:12px 16px 12px 16px;line-height:24px;font-weight:600}.ds-accordion__close-button.ds-accordion--border-aligned{padding-inline:0;padding-inline:0;margin-inline:16px}";
|
|
@@ -11,38 +11,40 @@ const DsAccordionStyle0 = dsAccordionCss;
|
|
|
11
11
|
const DsAccordion = class {
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
index.registerInstance(this, hostRef);
|
|
14
|
-
this.variant = 'default';
|
|
15
|
-
this.borderAligned = false;
|
|
16
|
-
this.openByDefault = false;
|
|
17
|
-
this.accordionId = 'dsaccordion';
|
|
18
|
-
this.headingLevel = 2;
|
|
19
|
-
this.useCloseButton = false;
|
|
20
|
-
this.closeButtonLabel = 'Close';
|
|
21
|
-
this.isExpanded = this.openByDefault;
|
|
22
|
-
this.shouldMoveFocus = false;
|
|
23
|
-
this.handleClick = (event) => {
|
|
24
|
-
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
25
|
-
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
26
|
-
this.isExpanded = !this.isExpanded;
|
|
27
|
-
};
|
|
28
|
-
this.handleKeyDown = (event) => {
|
|
29
|
-
switch (event.key) {
|
|
30
|
-
case 'Enter':
|
|
31
|
-
case ' ':
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
34
|
-
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
35
|
-
this.isExpanded = !this.isExpanded;
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
14
|
}
|
|
15
|
+
variant = 'default';
|
|
16
|
+
borderAligned = false;
|
|
17
|
+
openByDefault = false;
|
|
18
|
+
accordionId = 'dsaccordion';
|
|
19
|
+
headingLevel = 2;
|
|
20
|
+
useCloseButton = false;
|
|
21
|
+
closeButtonLabel = 'Close';
|
|
22
|
+
isExpanded = this.openByDefault;
|
|
23
|
+
get host() { return index.getElement(this); }
|
|
24
|
+
headerButtonRef;
|
|
25
|
+
shouldMoveFocus = false;
|
|
40
26
|
watchHandler(isExpanded) {
|
|
41
27
|
if (!isExpanded && this.shouldMoveFocus && this.headerButtonRef) {
|
|
42
28
|
this.headerButtonRef.focus();
|
|
43
29
|
this.shouldMoveFocus = false;
|
|
44
30
|
}
|
|
45
31
|
}
|
|
32
|
+
handleClick = (event) => {
|
|
33
|
+
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
34
|
+
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
35
|
+
this.isExpanded = !this.isExpanded;
|
|
36
|
+
};
|
|
37
|
+
handleKeyDown = (event) => {
|
|
38
|
+
switch (event.key) {
|
|
39
|
+
case 'Enter':
|
|
40
|
+
case ' ':
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
43
|
+
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
44
|
+
this.isExpanded = !this.isExpanded;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
46
48
|
render() {
|
|
47
49
|
return (index.h("div", { key: '2cc1b7c39897a2437b1c1b2a2dda3c73366f2406', class: index$1.classNames('ds-accordion', `ds-accordion--${this.variant}`, {
|
|
48
50
|
'ds-accordion--border-aligned': this.borderAligned
|
|
@@ -55,7 +57,6 @@ const DsAccordion = class {
|
|
|
55
57
|
'ds-accordion--border-aligned': this.borderAligned
|
|
56
58
|
}), "aria-labelledby": `${this.accordionId}-close-button ${this.accordionId}`, id: `${this.accordionId}-close-button`, onClick: this.handleClick, onKeyDown: this.handleKeyDown }, index.h("ds-icon", { key: '295bb76f0130566900081b90e5d80033bbe9758f', hidden: true, name: "keyboard_arrow_up" }), index.h("span", { key: '90dcf29559c485707ea8517e0056249027b1e45b' }, this.closeButtonLabel))))));
|
|
57
59
|
}
|
|
58
|
-
get host() { return index.getElement(this); }
|
|
59
60
|
static get watchers() { return {
|
|
60
61
|
"isExpanded": ["watchHandler"]
|
|
61
62
|
}; }
|
|
@@ -852,12 +853,14 @@ const DsIconStyle0 = dsIconCss;
|
|
|
852
853
|
const DsIcon = class {
|
|
853
854
|
constructor(hostRef) {
|
|
854
855
|
index.registerInstance(this, hostRef);
|
|
855
|
-
this.size = '1.5rem';
|
|
856
|
-
this.title = 'Icon';
|
|
857
|
-
this.role = 'img';
|
|
858
|
-
this.hidden = true;
|
|
859
|
-
this.message = '';
|
|
860
856
|
}
|
|
857
|
+
name;
|
|
858
|
+
colour;
|
|
859
|
+
size = '1.5rem';
|
|
860
|
+
title = 'Icon';
|
|
861
|
+
role = 'img';
|
|
862
|
+
hidden = true;
|
|
863
|
+
message = '';
|
|
861
864
|
getIcon() {
|
|
862
865
|
const selectedIcon = icons.find(icon => icon.name === this.name);
|
|
863
866
|
if (!selectedIcon) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-fd4f6cd2.js');
|
|
6
6
|
const index$1 = require('./index-5b0b9d4c.js');
|
|
7
7
|
|
|
8
8
|
const inheritAttributes = (el, attributes = []) => {
|
|
@@ -85,56 +85,61 @@ const DsButtonStyle0 = dsButtonCss;
|
|
|
85
85
|
const DsButton = class {
|
|
86
86
|
constructor(hostRef) {
|
|
87
87
|
index.registerInstance(this, hostRef);
|
|
88
|
-
this.inheritedAttributes = {};
|
|
89
|
-
this.pressedKeys = new Set();
|
|
90
|
-
this.value = '';
|
|
91
|
-
this.variant = 'primary';
|
|
92
|
-
this.colour = 'blue';
|
|
93
|
-
this.size = 'medium';
|
|
94
|
-
this.fontWeight = 'normal';
|
|
95
|
-
this.icon = '';
|
|
96
|
-
this.iconPosition = 'start';
|
|
97
|
-
this.type = 'button';
|
|
98
|
-
this.disabled = false;
|
|
99
|
-
this.ariaDisabled = 'false';
|
|
100
|
-
this.handleKeyDown = (event) => {
|
|
101
|
-
if (event.repeat) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
switch (event.key) {
|
|
105
|
-
case 'Enter':
|
|
106
|
-
case ' ':
|
|
107
|
-
this.pressedKeys.add(event.key);
|
|
108
|
-
this.buttonEl.classList.add(`${this.colour}--active`);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
this.handleKeyUp = (event) => {
|
|
113
|
-
switch (event.key) {
|
|
114
|
-
case 'Enter':
|
|
115
|
-
case ' ':
|
|
116
|
-
this.pressedKeys.delete(event.key);
|
|
117
|
-
if (this.pressedKeys.size === 0) {
|
|
118
|
-
this.buttonEl.classList.remove(`${this.colour}--active`);
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
88
|
}
|
|
89
|
+
inheritedAttributes = {};
|
|
90
|
+
buttonEl;
|
|
91
|
+
pressedKeys = new Set();
|
|
92
|
+
get el() { return index.getElement(this); }
|
|
93
|
+
value = '';
|
|
94
|
+
variant = 'primary';
|
|
95
|
+
colour = 'blue';
|
|
96
|
+
size = 'medium';
|
|
97
|
+
fontWeight = 'normal';
|
|
98
|
+
icon = '';
|
|
99
|
+
iconPosition = 'start';
|
|
100
|
+
type = 'button';
|
|
101
|
+
disabled = false;
|
|
102
|
+
ariaDisabled = 'false';
|
|
124
103
|
componentWillLoad() {
|
|
125
|
-
this.inheritedAttributes =
|
|
126
|
-
'
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
104
|
+
this.inheritedAttributes = {
|
|
105
|
+
...inheritAriaAttributes(this.el, ['aria-disabled']),
|
|
106
|
+
...inheritAttributes(this.el, [
|
|
107
|
+
'autofocus',
|
|
108
|
+
'form',
|
|
109
|
+
'formaction',
|
|
110
|
+
'formenctype',
|
|
111
|
+
'formmethod',
|
|
112
|
+
'formnovalidate',
|
|
113
|
+
'formtarget',
|
|
114
|
+
'name',
|
|
115
|
+
'popovertarget',
|
|
116
|
+
'popovertargetaction',
|
|
117
|
+
]),
|
|
118
|
+
};
|
|
137
119
|
}
|
|
120
|
+
handleKeyDown = (event) => {
|
|
121
|
+
if (event.repeat) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
switch (event.key) {
|
|
125
|
+
case 'Enter':
|
|
126
|
+
case ' ':
|
|
127
|
+
this.pressedKeys.add(event.key);
|
|
128
|
+
this.buttonEl.classList.add(`${this.colour}--active`);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
handleKeyUp = (event) => {
|
|
133
|
+
switch (event.key) {
|
|
134
|
+
case 'Enter':
|
|
135
|
+
case ' ':
|
|
136
|
+
this.pressedKeys.delete(event.key);
|
|
137
|
+
if (this.pressedKeys.size === 0) {
|
|
138
|
+
this.buttonEl.classList.remove(`${this.colour}--active`);
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
138
143
|
render() {
|
|
139
144
|
const classes = index$1.classNames(`${this.variant} ${this.colour} ${this.size}`, {
|
|
140
145
|
'icon-start': this.icon && this.iconPosition === 'start' && this.value,
|
|
@@ -143,9 +148,9 @@ const DsButton = class {
|
|
|
143
148
|
});
|
|
144
149
|
const iconSize = this.size === 'small' ? '1rem' : undefined;
|
|
145
150
|
const isDisabled = this.disabled || this.ariaDisabled === 'true';
|
|
146
|
-
|
|
151
|
+
console.log('foo');
|
|
152
|
+
return (index.h("button", { key: 'bf1cd8f28ef9701931c8c7c6f552e58b38e39290', ref: el => (this.buttonEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp, class: classes, style: { fontWeight: this.fontWeight }, type: this.type, "aria-disabled": isDisabled ? 'true' : 'false', ...this.inheritedAttributes }, index.h("slot", { key: '2c8eab3447d3a88236a7b23d95613bfc7f6c2f4e', name: "prefix" }, this.icon && this.iconPosition === 'start' && index.h("ds-icon", { key: '3adff40a2a2841164d5fc02fa815bf2cf6904856', name: this.icon, size: iconSize })), this.value && index.h("span", { key: '3291dd24092bf5e0a4d622e6b1d487f62fc33a2f', class: "button-value" }, this.value), index.h("slot", { key: '1f9865ee665c3963746d3fa27c1313bbf02c5ff2', name: "suffix" }, this.icon && this.iconPosition === 'end' && index.h("ds-icon", { key: '11cc53787dd9caeea4a778197064ac49bc95fac4', name: this.icon, size: iconSize }))));
|
|
147
153
|
}
|
|
148
|
-
get el() { return index.getElement(this); }
|
|
149
154
|
};
|
|
150
155
|
DsButton.style = DsButtonStyle0;
|
|
151
156
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-fd4f6cd2.js');
|
|
6
6
|
const index$1 = require('./index-5b0b9d4c.js');
|
|
7
7
|
|
|
8
8
|
function* idGenerator(id) {
|
|
@@ -29,29 +29,42 @@ const errorTextIdGenerator = idGenerator('error-text');
|
|
|
29
29
|
const DsTextInput = class {
|
|
30
30
|
constructor(hostRef) {
|
|
31
31
|
index.registerInstance(this, hostRef);
|
|
32
|
-
this.assistiveTextId = assistiveTextIdGenerator.next().value;
|
|
33
|
-
this.visuallyHiddenAssistiveTextId = visuallyHiddenAssistiveTextIdGenerator.next().value;
|
|
34
|
-
this.successTextId = successTextIdGenerator.next().value;
|
|
35
|
-
this.errorTextId = errorTextIdGenerator.next().value;
|
|
36
|
-
this.id = 'input';
|
|
37
|
-
this.icon = '';
|
|
38
|
-
this.type = 'text';
|
|
39
|
-
this.hasFocus = false;
|
|
40
|
-
this.clearButtonVisible = false;
|
|
41
|
-
this.passwordInputVisible = false;
|
|
42
|
-
this.inputActive = false;
|
|
43
|
-
this.onActionButtonClicked = (e) => {
|
|
44
|
-
e.stopPropagation();
|
|
45
|
-
switch (this.type) {
|
|
46
|
-
case 'password':
|
|
47
|
-
return this.togglePasswordVisibility();
|
|
48
|
-
case 'search':
|
|
49
|
-
this.clearInput();
|
|
50
|
-
default:
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
32
|
}
|
|
33
|
+
suffixButtonElement;
|
|
34
|
+
inputElement;
|
|
35
|
+
assistiveTextId = assistiveTextIdGenerator.next().value;
|
|
36
|
+
visuallyHiddenAssistiveTextId = visuallyHiddenAssistiveTextIdGenerator.next().value;
|
|
37
|
+
successTextId = successTextIdGenerator.next().value;
|
|
38
|
+
errorTextId = errorTextIdGenerator.next().value;
|
|
39
|
+
label;
|
|
40
|
+
placeholder;
|
|
41
|
+
dsId = 'input';
|
|
42
|
+
name;
|
|
43
|
+
disabled;
|
|
44
|
+
required;
|
|
45
|
+
readonly;
|
|
46
|
+
value;
|
|
47
|
+
min;
|
|
48
|
+
max;
|
|
49
|
+
maxlength;
|
|
50
|
+
pattern;
|
|
51
|
+
autocomplete;
|
|
52
|
+
errorText;
|
|
53
|
+
successText;
|
|
54
|
+
assistiveText;
|
|
55
|
+
actionButtonAriaLabel;
|
|
56
|
+
hiddenAssistiveText;
|
|
57
|
+
prefixText;
|
|
58
|
+
suffixText;
|
|
59
|
+
icon = '';
|
|
60
|
+
type = 'text';
|
|
61
|
+
ariaLabel;
|
|
62
|
+
ariaLabelledBy;
|
|
63
|
+
ariaDescribedby;
|
|
64
|
+
hasFocus = false;
|
|
65
|
+
clearButtonVisible = false;
|
|
66
|
+
passwordInputVisible = false;
|
|
67
|
+
inputActive = false;
|
|
55
68
|
async togglePasswordVisibility() {
|
|
56
69
|
return (this.passwordInputVisible = !this.passwordInputVisible);
|
|
57
70
|
}
|
|
@@ -60,6 +73,17 @@ const DsTextInput = class {
|
|
|
60
73
|
this.inputElement.focus();
|
|
61
74
|
this.clearButtonVisible = false;
|
|
62
75
|
}
|
|
76
|
+
onActionButtonClicked = (e) => {
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
switch (this.type) {
|
|
79
|
+
case 'password':
|
|
80
|
+
return this.togglePasswordVisibility();
|
|
81
|
+
case 'search':
|
|
82
|
+
this.clearInput();
|
|
83
|
+
default:
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
63
87
|
renderValidityMessage(type) {
|
|
64
88
|
const textId = type === 'success' ? this.successTextId : this.errorTextId;
|
|
65
89
|
const text = type === 'success' ? this.successText : this.errorText;
|
|
@@ -78,11 +102,10 @@ const DsTextInput = class {
|
|
|
78
102
|
return null;
|
|
79
103
|
}
|
|
80
104
|
renderSuffixContent() {
|
|
81
|
-
var _a, _b;
|
|
82
105
|
if (this.suffixText) {
|
|
83
106
|
return (index.h("slot", { name: "suffix" }, index.h("span", { class: "suffix" }, this.suffixText)));
|
|
84
107
|
}
|
|
85
|
-
const actionButtonIcon =
|
|
108
|
+
const actionButtonIcon = INPUT_TYPE_ACTION_BUTTON_ICON_MAP[this.type]?.(this) ?? '';
|
|
86
109
|
const ariaPressed = this.type === 'password' ? this.passwordInputVisible : undefined;
|
|
87
110
|
if (actionButtonIcon) {
|
|
88
111
|
return (index.h("slot", { name: "suffix" }, index.h("ds-button", { ref: e => (this.suffixButtonElement = e), variant: "supplementary", colour: "black", class: "suffix", disabled: false, icon: actionButtonIcon, onClick: this.onActionButtonClicked, "aria-pressed": ariaPressed, "aria-label": this.actionButtonAriaLabel })));
|
|
@@ -96,14 +119,14 @@ const DsTextInput = class {
|
|
|
96
119
|
}
|
|
97
120
|
render() {
|
|
98
121
|
const inputType = this.type === 'password' && this.passwordInputVisible ? 'text' : this.type;
|
|
99
|
-
return (index.h(index.Fragment, { key: '
|
|
122
|
+
return (index.h(index.Fragment, { key: 'b36b842382f0f0635c5372a856b140f05f7f5cff' }, index.h("div", { key: '4cedfdd4a891b8317f8b948824c5fe18b8f2c345', class: "label-container" }, index.h("slot", { key: '5072f7cab04c4c6dcf3bc2a72f88c83f3da5c74b', name: "label" }, index.h("label", { key: '513249ab30b24df9ad204ec533eb5b0714a5b36e', class: index$1.classNames({ required: this.required }), htmlFor: this.dsId }, this.label)), index.h("slot", { key: 'c3e05ad3e51365c7e8df7a276b4fc089af4edba7', name: "help-text" }, index.h("small", { key: 'fdf1904fe96fd22b4ba650e693db0d3fcecdf33a', id: this.assistiveTextId }, this.assistiveText), index.h("ds-visually-hidden", { key: 'd9726a8a031a786169ff47a809f8309117d00eaa', id: this.visuallyHiddenAssistiveTextId }, this.hiddenAssistiveText))), index.h("div", { key: 'c0fb788b2f35f478015169d2fc558885fc9c205a', onMouseDown: () => (this.inputActive = true), onMouseUp: () => (this.inputActive = false), onClick: e => this.handleInputContainerClick(e), class: index$1.classNames('input-container', {
|
|
100
123
|
disabled: this.disabled,
|
|
101
124
|
readonly: this.readonly,
|
|
102
125
|
valid: !!this.successText,
|
|
103
126
|
invalid: !!this.errorText,
|
|
104
127
|
focus: this.hasFocus,
|
|
105
128
|
active: !!this.inputActive,
|
|
106
|
-
}) }, this.renderPrefixContent(), index.h("input", { key: '
|
|
129
|
+
}) }, this.renderPrefixContent(), index.h("input", { key: 'adb2aa8a54d45aeeca8e209f0c0a28d2aa0141f8', ref: e => (this.inputElement = e), id: this.dsId, name: this.name, "aria-label": this.ariaLabel, "aria-labelledby": this.ariaLabelledBy, "aria-describedby": this.ariaDescribedby ||
|
|
107
130
|
index$1.classNames(this.assistiveTextId, this.visuallyHiddenAssistiveTextId, {
|
|
108
131
|
[this.successTextId]: this.successText,
|
|
109
132
|
[this.errorTextId]: this.errorText,
|
|
@@ -21,7 +21,7 @@ function _interopNamespace(e) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'component-library';
|
|
24
|
-
const BUILD = /* component-library */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, modernPropertyDecls:
|
|
24
|
+
const BUILD = /* component-library */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, modernPropertyDecls: true, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: false, propNumber: true, propString: true, reflect: false, scoped: true, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
|
|
25
25
|
|
|
26
26
|
/*
|
|
27
27
|
Stencil Client Platform v4.25.1 | MIT Licensed | https://stenciljs.com
|
|
@@ -32,11 +32,38 @@ var __export = (target, all) => {
|
|
|
32
32
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
// src/utils/es2022-rewire-class-members.ts
|
|
36
|
+
var reWireGetterSetter = (instance, hostRef) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
39
|
+
const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
|
|
40
|
+
members.map(([memberName, [memberFlags]]) => {
|
|
41
|
+
if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
|
|
42
|
+
const ogValue = instance[memberName];
|
|
43
|
+
const ogDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), memberName);
|
|
44
|
+
Object.defineProperty(instance, memberName, {
|
|
45
|
+
get() {
|
|
46
|
+
return ogDescriptor.get.call(this);
|
|
47
|
+
},
|
|
48
|
+
set(newValue) {
|
|
49
|
+
ogDescriptor.set.call(this, newValue);
|
|
50
|
+
},
|
|
51
|
+
configurable: true,
|
|
52
|
+
enumerable: true
|
|
53
|
+
});
|
|
54
|
+
instance[memberName] = hostRef.$instanceValues$.has(memberName) ? hostRef.$instanceValues$.get(memberName) : ogValue;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
35
59
|
// src/client/client-host-ref.ts
|
|
36
60
|
var hostRefs = /* @__PURE__ */ new WeakMap();
|
|
37
61
|
var getHostRef = (ref) => hostRefs.get(ref);
|
|
38
62
|
var registerInstance = (lazyInstance, hostRef) => {
|
|
39
63
|
hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
|
|
64
|
+
{
|
|
65
|
+
reWireGetterSetter(lazyInstance, hostRef);
|
|
66
|
+
}
|
|
40
67
|
};
|
|
41
68
|
var registerHost = (hostElement, cmpMeta) => {
|
|
42
69
|
const hostRef = {
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-fd4f6cd2.js');
|
|
6
6
|
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
7
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await appGlobals.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["ds-accordion_2.cjs",[[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"],"isExpanded":[32]},null,{"isExpanded":["watchHandler"]}],[1,"ds-icon",{"name":[1],"colour":[1],"size":[1],"title":[1],"role":[1],"hidden":[4],"message":[32]}]]],["ds-button_2.cjs",[[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],"ariaDisabled":[1,"aria-disabled"]}],[1,"ds-visually-hidden"]]],["ds-text-input.cjs",[[6,"ds-text-input",{"label":[1],"placeholder":[1],"
|
|
11
|
+
return index.bootstrapLazy([["ds-accordion_2.cjs",[[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"],"isExpanded":[32]},null,{"isExpanded":["watchHandler"]}],[1,"ds-icon",{"name":[1],"colour":[1],"size":[1],"title":[1],"role":[1],"hidden":[4],"message":[32]}]]],["ds-button_2.cjs",[[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],"ariaDisabled":[1,"aria-disabled"]}],[1,"ds-visually-hidden"]]],["ds-text-input.cjs",[[6,"ds-text-input",{"label":[1],"placeholder":[1],"dsId":[1,"ds-id"],"name":[1],"disabled":[4],"required":[4],"readonly":[4],"value":[1],"min":[2],"max":[2],"maxlength":[2],"pattern":[1],"autocomplete":[1],"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],"togglePasswordVisibility":[64],"clearInput":[64]}]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
export class DsAccordion {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
16
|
-
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
17
|
-
this.isExpanded = !this.isExpanded;
|
|
18
|
-
};
|
|
19
|
-
this.handleKeyDown = (event) => {
|
|
20
|
-
switch (event.key) {
|
|
21
|
-
case 'Enter':
|
|
22
|
-
case ' ':
|
|
23
|
-
event.preventDefault();
|
|
24
|
-
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
25
|
-
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
26
|
-
this.isExpanded = !this.isExpanded;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
4
|
+
variant = 'default';
|
|
5
|
+
borderAligned = false;
|
|
6
|
+
openByDefault = false;
|
|
7
|
+
accordionId = 'dsaccordion';
|
|
8
|
+
headingLevel = 2;
|
|
9
|
+
useCloseButton = false;
|
|
10
|
+
closeButtonLabel = 'Close';
|
|
11
|
+
isExpanded = this.openByDefault;
|
|
12
|
+
host;
|
|
13
|
+
headerButtonRef;
|
|
14
|
+
shouldMoveFocus = false;
|
|
31
15
|
watchHandler(isExpanded) {
|
|
32
16
|
if (!isExpanded && this.shouldMoveFocus && this.headerButtonRef) {
|
|
33
17
|
this.headerButtonRef.focus();
|
|
34
18
|
this.shouldMoveFocus = false;
|
|
35
19
|
}
|
|
36
20
|
}
|
|
21
|
+
handleClick = (event) => {
|
|
22
|
+
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
23
|
+
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
24
|
+
this.isExpanded = !this.isExpanded;
|
|
25
|
+
};
|
|
26
|
+
handleKeyDown = (event) => {
|
|
27
|
+
switch (event.key) {
|
|
28
|
+
case 'Enter':
|
|
29
|
+
case ' ':
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
const isCloseButton = event.target.closest('.ds-accordion__close-button');
|
|
32
|
+
this.shouldMoveFocus = isCloseButton ? true : false;
|
|
33
|
+
this.isExpanded = !this.isExpanded;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
37
|
render() {
|
|
38
38
|
return (h("div", { key: '2cc1b7c39897a2437b1c1b2a2dda3c73366f2406', class: classNames('ds-accordion', `ds-accordion--${this.variant}`, {
|
|
39
39
|
'ds-accordion--border-aligned': this.borderAligned
|
package/dist/collection/components/01-base-components/ds-accordion/stories/ds-accordion.stories.js
CHANGED
|
@@ -77,7 +77,12 @@ export const Playground = {
|
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
|
-
Playground.args =
|
|
80
|
+
Playground.args = {
|
|
81
|
+
...Default.args,
|
|
82
|
+
Header: exampleHeader,
|
|
83
|
+
Content: exampleContent,
|
|
84
|
+
Items: 3,
|
|
85
|
+
};
|
|
81
86
|
Playground.render = (args) => {
|
|
82
87
|
const accordions = Array.from({ length: args.Items }, (_, index) => `
|
|
83
88
|
<ds-accordion
|