@ukho/admiralty-core 0.4.6 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admiralty/admiralty.esm.js +1 -1
- package/dist/admiralty/admiralty.esm.js.map +1 -1
- package/dist/admiralty/p-20c06ebe.entry.js +2 -0
- package/dist/admiralty/p-20c06ebe.entry.js.map +1 -0
- package/dist/admiralty/{p-27286b0d.entry.js → p-3e91e95a.entry.js} +2 -2
- package/dist/admiralty/p-3e91e95a.entry.js.map +1 -0
- package/dist/admiralty/p-40bc8d7f.entry.js +2 -0
- package/dist/admiralty/p-40bc8d7f.entry.js.map +1 -0
- package/dist/admiralty/{p-f43f9ff4.entry.js → p-620e0985.entry.js} +2 -2
- package/dist/admiralty/{p-f43f9ff4.entry.js.map → p-620e0985.entry.js.map} +1 -1
- package/dist/admiralty/p-b5beb563.entry.js +2 -0
- package/dist/admiralty/p-b5beb563.entry.js.map +1 -0
- package/dist/cjs/admiralty-hint_3.cjs.entry.js +4 -4
- package/dist/cjs/admiralty-hint_3.cjs.entry.js.map +1 -1
- package/dist/cjs/admiralty-input.cjs.entry.js +2 -2
- package/dist/cjs/admiralty-input.cjs.entry.js.map +1 -1
- package/dist/cjs/admiralty-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/admiralty-radio-group.cjs.entry.js.map +1 -1
- package/dist/cjs/admiralty-select.cjs.entry.js +5 -5
- package/dist/cjs/admiralty-select.cjs.entry.js.map +1 -1
- package/dist/cjs/admiralty-textarea.cjs.entry.js +1 -1
- package/dist/cjs/admiralty-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/admiralty.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/input/input.css +1 -1
- package/dist/collection/components/input/input.js +1 -1
- package/dist/collection/components/input/input.js.map +1 -1
- package/dist/collection/components/input/input.spec.js +8 -8
- package/dist/collection/components/input/input.spec.js.map +1 -1
- package/dist/collection/components/input-invalid/input-invalid.e2e.js +10 -0
- package/dist/collection/components/input-invalid/input-invalid.e2e.js.map +1 -0
- package/dist/collection/components/{input-error/input-error.js → input-invalid/input-invalid.js} +6 -6
- package/dist/collection/components/input-invalid/input-invalid.js.map +1 -0
- package/dist/collection/components/input-invalid/input-invalid.spec.js +19 -0
- package/dist/collection/components/input-invalid/input-invalid.spec.js.map +1 -0
- package/dist/collection/components/radio-group/radio-group.js +1 -1
- package/dist/collection/components/radio-group/radio-group.js.map +1 -1
- package/dist/collection/components/radio-group/radio-group.spec.js +3 -3
- package/dist/collection/components/radio-group/radio-group.spec.js.map +1 -1
- package/dist/collection/components/select/select.css +1 -1
- package/dist/collection/components/select/select.js +10 -10
- package/dist/collection/components/select/select.js.map +1 -1
- package/dist/collection/components/select/select.spec.js +10 -5
- package/dist/collection/components/select/select.spec.js.map +1 -1
- package/dist/collection/components/textarea/textarea.js +1 -1
- package/dist/collection/components/textarea/textarea.js.map +1 -1
- package/dist/collection/components/textarea/textarea.spec.js +7 -3
- package/dist/collection/components/textarea/textarea.spec.js.map +1 -1
- package/dist/components/admiralty-input-invalid.d.ts +11 -0
- package/dist/components/admiralty-input-invalid.js +8 -0
- package/dist/components/admiralty-input-invalid.js.map +1 -0
- package/dist/components/admiralty-radio-group.js +4 -4
- package/dist/components/admiralty-radio-group.js.map +1 -1
- package/dist/components/admiralty-select.js +10 -10
- package/dist/components/admiralty-select.js.map +1 -1
- package/dist/components/admiralty-textarea.js +4 -4
- package/dist/components/admiralty-textarea.js.map +1 -1
- package/dist/components/admiralty-type-ahead.js +3 -3
- package/dist/components/{input-error.js → input-invalid.js} +9 -9
- package/dist/components/input-invalid.js.map +1 -0
- package/dist/components/input.js +5 -5
- package/dist/components/input.js.map +1 -1
- package/dist/esm/admiralty-hint_3.entry.js +4 -4
- package/dist/esm/admiralty-hint_3.entry.js.map +1 -1
- package/dist/esm/admiralty-input.entry.js +2 -2
- package/dist/esm/admiralty-input.entry.js.map +1 -1
- package/dist/esm/admiralty-radio-group.entry.js +1 -1
- package/dist/esm/admiralty-radio-group.entry.js.map +1 -1
- package/dist/esm/admiralty-select.entry.js +5 -5
- package/dist/esm/admiralty-select.entry.js.map +1 -1
- package/dist/esm/admiralty-textarea.entry.js +1 -1
- package/dist/esm/admiralty-textarea.entry.js.map +1 -1
- package/dist/esm/admiralty.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/input-invalid/input-invalid.d.ts +7 -0
- package/dist/types/components/select/select.d.ts +4 -4
- package/dist/types/components.d.ts +21 -21
- package/package.json +11 -11
- package/dist/admiralty/p-27286b0d.entry.js.map +0 -1
- package/dist/admiralty/p-5d46659e.entry.js +0 -2
- package/dist/admiralty/p-5d46659e.entry.js.map +0 -1
- package/dist/admiralty/p-869d7709.entry.js +0 -2
- package/dist/admiralty/p-869d7709.entry.js.map +0 -1
- package/dist/admiralty/p-c027f79d.entry.js +0 -2
- package/dist/admiralty/p-c027f79d.entry.js.map +0 -1
- package/dist/collection/components/input-error/input-error.e2e.js +0 -10
- package/dist/collection/components/input-error/input-error.e2e.js.map +0 -1
- package/dist/collection/components/input-error/input-error.js.map +0 -1
- package/dist/collection/components/input-error/input-error.spec.js +0 -19
- package/dist/collection/components/input-error/input-error.spec.js.map +0 -1
- package/dist/components/admiralty-input-error.d.ts +0 -11
- package/dist/components/admiralty-input-error.js +0 -8
- package/dist/components/admiralty-input-error.js.map +0 -1
- package/dist/components/input-error.js.map +0 -1
- package/dist/types/components/input-error/input-error.d.ts +0 -7
- /package/dist/collection/components/{input-error/input-error.css → input-invalid/input-invalid.css} +0 -0
|
@@ -20,7 +20,7 @@ const patchBrowser = () => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
patchBrowser().then(options => {
|
|
23
|
-
return index.bootstrapLazy([["admiralty-type-ahead.cjs",[[6,"admiralty-type-ahead",{"value":[1],"label":[1],"hint":[1],"placeholder":[1],"resultsOnInitFocus":[4,"results-on-init-focus"],"filterResult":[32]}]]],["admiralty-select.cjs",[[6,"admiralty-select",{"disabled":[4],"
|
|
23
|
+
return index.bootstrapLazy([["admiralty-type-ahead.cjs",[[6,"admiralty-type-ahead",{"value":[1],"label":[1],"hint":[1],"placeholder":[1],"resultsOnInitFocus":[4,"results-on-init-focus"],"filterResult":[32]}]]],["admiralty-select.cjs",[[6,"admiralty-select",{"disabled":[4],"invalid":[4],"invalidMessage":[1,"invalid-message"],"hint":[1],"label":[1],"width":[2],"value":[1032]}]]],["admiralty-textarea.cjs",[[2,"admiralty-textarea",{"label":[1],"hint":[1],"width":[2],"maxLength":[2,"max-length"],"disabled":[4],"invalid":[4],"invalidMessage":[1,"invalid-message"],"value":[1032]}]]],["admiralty-colour-block.cjs",[[6,"admiralty-colour-block",{"width":[2],"height":[2],"heading":[1],"colour":[1],"clickAction":[16],"actionText":[1,"action-text"]}]]],["admiralty-filter.cjs",[[6,"admiralty-filter",{"filterTitle":[1,"filter-title"]}]]],["admiralty-filter-group.cjs",[[6,"admiralty-filter-group",{"groupTitle":[1,"group-title"]}]]],["admiralty-paginator.cjs",[[2,"admiralty-paginator",{"pages":[2],"currentPage":[2,"current-page"],"label":[1]}]]],["admiralty-radio-group.cjs",[[6,"admiralty-radio-group",{"name":[1],"value":[1032],"displayVertical":[4,"display-vertical"],"invalid":[4],"invalidMessage":[1,"invalid-message"]}]]],["admiralty-breadcrumb.cjs",[[6,"admiralty-breadcrumb",{"active":[4],"first":[4],"href":[1]}]]],["admiralty-dialogue.cjs",[[6,"admiralty-dialogue",{"type":[1],"heading":[1]}]]],["admiralty-file-input.cjs",[[2,"admiralty-file-input",{"label":[1],"multiple":[4],"files":[32]}]]],["admiralty-header.cjs",[[6,"admiralty-header",{"headerTitle":[1,"header-title"],"headerTitleUrl":[1,"header-title-url"],"logoLinkUrl":[1,"logo-link-url"],"logoImgUrl":[1,"logo-img-url"],"logoAltText":[1,"logo-alt-text"],"mobileMenuOpen":[32],"displayHamburger":[32]}]]],["admiralty-progress-bar.cjs",[[2,"admiralty-progress-bar",{"label":[1],"progression":[2],"error":[4],"progressionValue":[32]}]]],["admiralty-read-more.cjs",[[6,"admiralty-read-more",{"heading":[1],"expanded":[32]}]]],["admiralty-breadcrumbs.cjs",[[6,"admiralty-breadcrumbs"]]],["admiralty-card.cjs",[[6,"admiralty-card",{"heading":[1]}]]],["admiralty-checkbox.cjs",[[2,"admiralty-checkbox",{"checkboxRight":[4,"checkbox-right"],"disabled":[4],"name":[1],"checked":[1028],"value":[8],"labelText":[1,"label-text"]}]]],["admiralty-footer.cjs",[[6,"admiralty-footer",{"imageLink":[1,"image-link"],"imageSrc":[1,"image-src"],"imageAlt":[1,"image-alt"],"text":[1]}]]],["admiralty-header-menu-item.cjs",[[6,"admiralty-header-menu-item",{"menuTitle":[1,"menu-title"],"active":[4]}]]],["admiralty-header-profile.cjs",[[2,"admiralty-header-profile",{"isSignedIn":[4,"is-signed-in"],"signedInText":[1,"signed-in-text"]}]]],["admiralty-header-sub-menu-item.cjs",[[2,"admiralty-header-sub-menu-item",{"menuTitle":[1,"menu-title"]}]]],["admiralty-hr.cjs",[[2,"admiralty-hr"]]],["admiralty-link.cjs",[[6,"admiralty-link",{"href":[1],"newTab":[4,"new-tab"]}]]],["admiralty-paginator-wrapper.cjs",[[4,"admiralty-paginator-wrapper",null,[[0,"pageChange","pageChangedHandler"]]]]],["admiralty-phase-banner.cjs",[[2,"admiralty-phase-banner",{"phase":[1],"link":[1]}]]],["admiralty-radio.cjs",[[6,"admiralty-radio",{"name":[1],"value":[1025],"disabled":[4],"checked":[1028],"invalid":[4],"buttonTabindex":[32],"setButtonTabindex":[64]}]]],["admiralty-side-nav.cjs",[[6,"admiralty-side-nav",{"label":[1]}]]],["admiralty-side-nav-item.cjs",[[2,"admiralty-side-nav-item",{"sideNavItemId":[1,"side-nav-item-id"],"headingTitle":[1,"heading-title"],"navActive":[4,"nav-active"]}]]],["admiralty-side-nav-wrapper.cjs",[[4,"admiralty-side-nav-wrapper",null,[[0,"sideNavItemSelected","onSideNavItemSelected"]]]]],["admiralty-tab.cjs",[[6,"admiralty-tab",{"label":[1],"tabLabelId":[1,"tab-label-id"],"tabContentId":[1,"tab-content-id"]}]]],["admiralty-tab-group.cjs",[[6,"admiralty-tab-group",{"selectedIndex":[1026,"selected-index"]}]]],["admiralty-table.cjs",[[6,"admiralty-table",{"caption":[1]}]]],["admiralty-table-body.cjs",[[6,"admiralty-table-body"]]],["admiralty-table-cell.cjs",[[6,"admiralty-table-cell"]]],["admiralty-table-header.cjs",[[6,"admiralty-table-header"]]],["admiralty-table-header-cell.cjs",[[6,"admiralty-table-header-cell"]]],["admiralty-table-row.cjs",[[6,"admiralty-table-row"]]],["admiralty-type-ahead-item.cjs",[[2,"admiralty-type-ahead-item",{"value":[1]}]]],["admiralty-icon.cjs",[[1,"admiralty-icon",{"iconName":[1,"icon-name"],"iconPrefix":[1,"icon-prefix"]}]]],["admiralty-input.cjs",[[2,"admiralty-input",{"name":[1],"label":[1],"hint":[1],"disabled":[4],"type":[1],"placeholder":[1],"width":[2],"maxLength":[2,"max-length"],"required":[4],"invalid":[4],"invalidMessage":[1,"invalid-message"],"autocomplete":[1],"value":[1032]}]]],["admiralty-expansion.cjs",[[6,"admiralty-expansion",{"heading":[1],"expanded":[1540],"alignHeadingRight":[4,"align-heading-right"],"hideBorder":[4,"hide-border"]}]]],["admiralty-button.cjs",[[6,"admiralty-button",{"variant":[1],"icon":[1],"disabled":[516],"type":[1]}]]],["admiralty-hint_3.cjs",[[6,"admiralty-hint",{"disabled":[4]}],[6,"admiralty-input-invalid"],[6,"admiralty-label",{"disabled":[4],"for":[1]}]]]], options);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
exports.setNonce = index.setNonce;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["admiralty-type-ahead.cjs",[[6,"admiralty-type-ahead",{"value":[1],"label":[1],"hint":[1],"placeholder":[1],"resultsOnInitFocus":[4,"results-on-init-focus"],"filterResult":[32]}]]],["admiralty-select.cjs",[[6,"admiralty-select",{"disabled":[4],"
|
|
17
|
+
return index.bootstrapLazy([["admiralty-type-ahead.cjs",[[6,"admiralty-type-ahead",{"value":[1],"label":[1],"hint":[1],"placeholder":[1],"resultsOnInitFocus":[4,"results-on-init-focus"],"filterResult":[32]}]]],["admiralty-select.cjs",[[6,"admiralty-select",{"disabled":[4],"invalid":[4],"invalidMessage":[1,"invalid-message"],"hint":[1],"label":[1],"width":[2],"value":[1032]}]]],["admiralty-textarea.cjs",[[2,"admiralty-textarea",{"label":[1],"hint":[1],"width":[2],"maxLength":[2,"max-length"],"disabled":[4],"invalid":[4],"invalidMessage":[1,"invalid-message"],"value":[1032]}]]],["admiralty-colour-block.cjs",[[6,"admiralty-colour-block",{"width":[2],"height":[2],"heading":[1],"colour":[1],"clickAction":[16],"actionText":[1,"action-text"]}]]],["admiralty-filter.cjs",[[6,"admiralty-filter",{"filterTitle":[1,"filter-title"]}]]],["admiralty-filter-group.cjs",[[6,"admiralty-filter-group",{"groupTitle":[1,"group-title"]}]]],["admiralty-paginator.cjs",[[2,"admiralty-paginator",{"pages":[2],"currentPage":[2,"current-page"],"label":[1]}]]],["admiralty-radio-group.cjs",[[6,"admiralty-radio-group",{"name":[1],"value":[1032],"displayVertical":[4,"display-vertical"],"invalid":[4],"invalidMessage":[1,"invalid-message"]}]]],["admiralty-breadcrumb.cjs",[[6,"admiralty-breadcrumb",{"active":[4],"first":[4],"href":[1]}]]],["admiralty-dialogue.cjs",[[6,"admiralty-dialogue",{"type":[1],"heading":[1]}]]],["admiralty-file-input.cjs",[[2,"admiralty-file-input",{"label":[1],"multiple":[4],"files":[32]}]]],["admiralty-header.cjs",[[6,"admiralty-header",{"headerTitle":[1,"header-title"],"headerTitleUrl":[1,"header-title-url"],"logoLinkUrl":[1,"logo-link-url"],"logoImgUrl":[1,"logo-img-url"],"logoAltText":[1,"logo-alt-text"],"mobileMenuOpen":[32],"displayHamburger":[32]}]]],["admiralty-progress-bar.cjs",[[2,"admiralty-progress-bar",{"label":[1],"progression":[2],"error":[4],"progressionValue":[32]}]]],["admiralty-read-more.cjs",[[6,"admiralty-read-more",{"heading":[1],"expanded":[32]}]]],["admiralty-breadcrumbs.cjs",[[6,"admiralty-breadcrumbs"]]],["admiralty-card.cjs",[[6,"admiralty-card",{"heading":[1]}]]],["admiralty-checkbox.cjs",[[2,"admiralty-checkbox",{"checkboxRight":[4,"checkbox-right"],"disabled":[4],"name":[1],"checked":[1028],"value":[8],"labelText":[1,"label-text"]}]]],["admiralty-footer.cjs",[[6,"admiralty-footer",{"imageLink":[1,"image-link"],"imageSrc":[1,"image-src"],"imageAlt":[1,"image-alt"],"text":[1]}]]],["admiralty-header-menu-item.cjs",[[6,"admiralty-header-menu-item",{"menuTitle":[1,"menu-title"],"active":[4]}]]],["admiralty-header-profile.cjs",[[2,"admiralty-header-profile",{"isSignedIn":[4,"is-signed-in"],"signedInText":[1,"signed-in-text"]}]]],["admiralty-header-sub-menu-item.cjs",[[2,"admiralty-header-sub-menu-item",{"menuTitle":[1,"menu-title"]}]]],["admiralty-hr.cjs",[[2,"admiralty-hr"]]],["admiralty-link.cjs",[[6,"admiralty-link",{"href":[1],"newTab":[4,"new-tab"]}]]],["admiralty-paginator-wrapper.cjs",[[4,"admiralty-paginator-wrapper",null,[[0,"pageChange","pageChangedHandler"]]]]],["admiralty-phase-banner.cjs",[[2,"admiralty-phase-banner",{"phase":[1],"link":[1]}]]],["admiralty-radio.cjs",[[6,"admiralty-radio",{"name":[1],"value":[1025],"disabled":[4],"checked":[1028],"invalid":[4],"buttonTabindex":[32],"setButtonTabindex":[64]}]]],["admiralty-side-nav.cjs",[[6,"admiralty-side-nav",{"label":[1]}]]],["admiralty-side-nav-item.cjs",[[2,"admiralty-side-nav-item",{"sideNavItemId":[1,"side-nav-item-id"],"headingTitle":[1,"heading-title"],"navActive":[4,"nav-active"]}]]],["admiralty-side-nav-wrapper.cjs",[[4,"admiralty-side-nav-wrapper",null,[[0,"sideNavItemSelected","onSideNavItemSelected"]]]]],["admiralty-tab.cjs",[[6,"admiralty-tab",{"label":[1],"tabLabelId":[1,"tab-label-id"],"tabContentId":[1,"tab-content-id"]}]]],["admiralty-tab-group.cjs",[[6,"admiralty-tab-group",{"selectedIndex":[1026,"selected-index"]}]]],["admiralty-table.cjs",[[6,"admiralty-table",{"caption":[1]}]]],["admiralty-table-body.cjs",[[6,"admiralty-table-body"]]],["admiralty-table-cell.cjs",[[6,"admiralty-table-cell"]]],["admiralty-table-header.cjs",[[6,"admiralty-table-header"]]],["admiralty-table-header-cell.cjs",[[6,"admiralty-table-header-cell"]]],["admiralty-table-row.cjs",[[6,"admiralty-table-row"]]],["admiralty-type-ahead-item.cjs",[[2,"admiralty-type-ahead-item",{"value":[1]}]]],["admiralty-icon.cjs",[[1,"admiralty-icon",{"iconName":[1,"icon-name"],"iconPrefix":[1,"icon-prefix"]}]]],["admiralty-input.cjs",[[2,"admiralty-input",{"name":[1],"label":[1],"hint":[1],"disabled":[4],"type":[1],"placeholder":[1],"width":[2],"maxLength":[2,"max-length"],"required":[4],"invalid":[4],"invalidMessage":[1,"invalid-message"],"autocomplete":[1],"value":[1032]}]]],["admiralty-expansion.cjs",[[6,"admiralty-expansion",{"heading":[1],"expanded":[1540],"alignHeadingRight":[4,"align-heading-right"],"hideBorder":[4,"hide-border"]}]]],["admiralty-button.cjs",[[6,"admiralty-button",{"variant":[1],"icon":[1],"disabled":[516],"type":[1]}]]],["admiralty-hint_3.cjs",[[6,"admiralty-hint",{"disabled":[4]}],[6,"admiralty-input-invalid"],[6,"admiralty-label",{"disabled":[4],"for":[1]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./components/horizontal-rule/horizontal-rule.js",
|
|
22
22
|
"./components/icon/icon.js",
|
|
23
23
|
"./components/input/input.js",
|
|
24
|
-
"./components/input-
|
|
24
|
+
"./components/input-invalid/input-invalid.js",
|
|
25
25
|
"./components/label/label.js",
|
|
26
26
|
"./components/paginator/paginator.js",
|
|
27
27
|
"./components/paginator/paginator.stories.data.js",
|
|
@@ -46,7 +46,7 @@ export class InputComponent {
|
|
|
46
46
|
const value = this.getValue();
|
|
47
47
|
return (h("div", { class: "text-input-container" }, this.label ? (h("admiralty-label", { disabled: this.disabled, for: this.inputId }, this.label)) : null, this.hint ? h("admiralty-hint", { disabled: this.disabled }, this.hint) : null, h("input", { ref: input => (this.nativeInput = input), class: { disabled: this.disabled, invalid: this.invalid }, disabled: this.disabled, id: this.inputId, name: this.name, type: this.type, value: value, maxLength: this.maxLength, onInput: this.onInput, placeholder: this.placeholder, autoComplete: this.autocomplete, required: this.required, style: {
|
|
48
48
|
maxWidth: this.width ? `${this.width}px` : null,
|
|
49
|
-
} }), h("admiralty-input-
|
|
49
|
+
} }), h("admiralty-input-invalid", { style: { visibility: this.invalid && this.invalidMessage ? 'visible' : 'hidden' } }, this.invalidMessage)));
|
|
50
50
|
}
|
|
51
51
|
static get is() { return "admiralty-input"; }
|
|
52
52
|
static get encapsulation() { return "scoped"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGnG;;;;;GAKG;AAOH,MAAM,OAAO,cAAc;;IACzB,YAAO,GAAW,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAuFxC,YAAO,GAAG,CAAC,EAAS,EAAE,EAAE;MAC9B,MAAM,KAAK,GAAG,EAAE,CAAC,MAAiC,CAAC;M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IAAI,MAAM,GAAG,CAAC,CAAC","sourcesContent":["import { Component, ComponentInterface, Event, EventEmitter, h, Prop, Watch } from '@stencil/core';\nimport { InputChangeEventDetail } from './input.interface';\n\n/**\n * Once this component works, review whether a form field component should be created so\n * that shared properties such as `label`, `hint`, `disabled` etc. can be defined once.\n * Examples of similar components that can extend that base component are area, select\n * and checkbox.\n */\n\n@Component({\n tag: 'admiralty-input',\n styleUrl: 'input.scss',\n scoped: true,\n})\nexport class InputComponent implements ComponentInterface {\n inputId: string = `admiralty-input-${++nextId}`;\n\n private nativeInput?: HTMLInputElement;\n\n /**\n * The name of the control, which is submitted with the form data.\n */\n @Prop() name: string = this.inputId;\n\n /**\n * The label which will be used above the input to describe the input.\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * This dictates whether the form field is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * The input type, options are: `text | date | time | email | password | tel | url`\n */\n @Prop() type: 'text' | 'date' | 'time' | 'email' | 'password' | 'tel' | 'url' = 'text';\n\n /**\n * The placeholder text to show in the input\n */\n @Prop() placeholder: string;\n\n /**\n * The maximum width for the input field.\n */\n @Prop() width: number;\n\n /**\n * The maximum string length for the input field.\n */\n @Prop() maxLength?: number;\n\n /**\n * This dictates whether the input is required or not\n */\n @Prop() required: boolean = false;\n\n /**\n * Whether to show the input in an invalid state\n */\n @Prop() invalid: boolean = false;\n\n /**\n * The message to show when the input is invalid\n */\n @Prop() invalidMessage: string;\n\n /**\n * Indicates whether the value of the control can be automatically completed by the browser.\n */\n @Prop() autocomplete: string = 'off';\n\n /**\n * The value of the input.\n */\n @Prop({ mutable: true }) value?: string | number | null = '';\n\n /**\n * Emitted when the value has changed.\n */\n @Event() admiraltyInput: EventEmitter<InputChangeEventDetail>;\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged() {\n const nativeInput = this.nativeInput;\n const value = this.getValue();\n if (nativeInput && nativeInput.value !== value) {\n nativeInput.value = value;\n }\n this.admiraltyInput.emit({ value: this.value == null ? this.getValue() : this.value.toString() });\n }\n\n private onInput = (ev: Event) => {\n const input = ev.target as HTMLInputElement | null;\n if (input) {\n this.value = input.value || '';\n }\n };\n\n private getValue(): string {\n return typeof this.value === 'number' ? this.value.toString() : (this.value || '').toString();\n }\n\n render() {\n const value = this.getValue();\n return (\n <div class=\"text-input-container\">\n {this.label ? (\n <admiralty-label disabled={this.disabled} for={this.inputId}>\n {this.label}\n </admiralty-label>\n ) : null}\n {this.hint ? <admiralty-hint disabled={this.disabled}>{this.hint}</admiralty-hint> : null}\n <input\n ref={input => (this.nativeInput = input)}\n class={{ disabled: this.disabled, invalid: this.invalid }}\n disabled={this.disabled}\n id={this.inputId}\n name={this.name}\n type={this.type}\n value={value}\n maxLength={this.maxLength}\n onInput={this.onInput}\n placeholder={this.placeholder}\n autoComplete={this.autocomplete}\n required={this.required}\n style={{\n maxWidth: this.width ? `${this.width}px` : null,\n }}\n />\n <admiralty-input-invalid style={{ visibility: this.invalid && this.invalidMessage ? 'visible' : 'hidden' }}>{this.invalidMessage}</admiralty-input-invalid>\n </div>\n );\n }\n}\nlet nextId = 0;\n"]}
|
|
@@ -10,7 +10,7 @@ describe('admiralty-input', () => {
|
|
|
10
10
|
<admiralty-input>
|
|
11
11
|
<div class="text-input-container">
|
|
12
12
|
<input autocomplete="off" id="admiralty-input-1" name="admiralty-input-1" type="text" value="">
|
|
13
|
-
<admiralty-input-
|
|
13
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
14
14
|
</div>
|
|
15
15
|
</admiralty-input>
|
|
16
16
|
`);
|
|
@@ -25,7 +25,7 @@ describe('admiralty-input', () => {
|
|
|
25
25
|
<div class="text-input-container">
|
|
26
26
|
<admiralty-label for="admiralty-input-2">test-label</admiralty-label>
|
|
27
27
|
<input autocomplete="off" id="admiralty-input-2" name="admiralty-input-2" type="text" value="">
|
|
28
|
-
<admiralty-input-
|
|
28
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
29
29
|
</div>
|
|
30
30
|
</admiralty-input>
|
|
31
31
|
`);
|
|
@@ -39,7 +39,7 @@ describe('admiralty-input', () => {
|
|
|
39
39
|
<admiralty-input disabled>
|
|
40
40
|
<div class="text-input-container">
|
|
41
41
|
<input disabled autocomplete="off" class="disabled" id="admiralty-input-3" name="admiralty-input-3" type="text" value="">
|
|
42
|
-
<admiralty-input-
|
|
42
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
43
43
|
</div>
|
|
44
44
|
</admiralty-input>
|
|
45
45
|
`);
|
|
@@ -53,7 +53,7 @@ describe('admiralty-input', () => {
|
|
|
53
53
|
<admiralty-input invalid="true">
|
|
54
54
|
<div class="text-input-container">
|
|
55
55
|
<input autocomplete="off" class="invalid" id="admiralty-input-4" name="admiralty-input-4" type="text" value="">
|
|
56
|
-
<admiralty-input-
|
|
56
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
57
57
|
</div>
|
|
58
58
|
</admiralty-input>
|
|
59
59
|
`);
|
|
@@ -67,9 +67,9 @@ describe('admiralty-input', () => {
|
|
|
67
67
|
<admiralty-input invalid="true" invalid-message="This is invalid!">
|
|
68
68
|
<div class="text-input-container">
|
|
69
69
|
<input autocomplete="off" class="invalid" id="admiralty-input-5" name="admiralty-input-5" type="text" value="">
|
|
70
|
-
<admiralty-input-
|
|
70
|
+
<admiralty-input-invalid style="visibility: visible;">
|
|
71
71
|
This is invalid!
|
|
72
|
-
</admiralty-input-
|
|
72
|
+
</admiralty-input-invalid>
|
|
73
73
|
</div>
|
|
74
74
|
</admiralty-input>
|
|
75
75
|
`);
|
|
@@ -83,7 +83,7 @@ describe('admiralty-input', () => {
|
|
|
83
83
|
<admiralty-input type="date">
|
|
84
84
|
<div class="text-input-container">
|
|
85
85
|
<input type="date" autocomplete="off" id="admiralty-input-6" name="admiralty-input-6" value="">
|
|
86
|
-
<admiralty-input-
|
|
86
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
87
87
|
</div>
|
|
88
88
|
</admiralty-input>
|
|
89
89
|
`);
|
|
@@ -98,7 +98,7 @@ it('renders with maxlength', async () => {
|
|
|
98
98
|
<admiralty-input max-length="1">
|
|
99
99
|
<div class="text-input-container">
|
|
100
100
|
<input autocomplete="off" class="" id="admiralty-input-7" maxlength="1" name="admiralty-input-7" type="text" value="">
|
|
101
|
-
<admiralty-input-
|
|
101
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
102
102
|
</div>
|
|
103
103
|
</admiralty-input>
|
|
104
104
|
`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.spec.js","sourceRoot":"","sources":["../../../src/components/input/input.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;EAC/B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,cAAc,CAAC;MAC5B,IAAI,EAAE,qCAAqC;KAC5C,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;KAO7B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;IACpC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,cAAc,CAAC;MAC5B,IAAI,EAAE,wDAAwD;KAC/D,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;KAQ7B,CAAC,CAAC;EACL,CAAC,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,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;IAC7B,UAAU,EAAE,CAAC,cAAc,CAAC;IAC5B,IAAI,EAAE,oDAAoD;GAC3D,CAAC,CAAC;EACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;GAO7B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { InputComponent } from './input';\n\ndescribe('admiralty-input', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input>\n <div class=\"text-input-container\">\n <input autocomplete=\"off\" id=\"admiralty-input-1\" name=\"admiralty-input-1\" type=\"text\" value=\"\">\n <admiralty-input-
|
|
1
|
+
{"version":3,"file":"input.spec.js","sourceRoot":"","sources":["../../../src/components/input/input.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;EAC/B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,cAAc,CAAC;MAC5B,IAAI,EAAE,qCAAqC;KAC5C,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;KAO7B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;IACpC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,cAAc,CAAC;MAC5B,IAAI,EAAE,wDAAwD;KAC/D,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAA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AAC,CAAC;AAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;EACtC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;IAC7B,UAAU,EAAE,CAAC,cAAc,CAAC;IAC5B,IAAI,EAAE,oDAAoD;GAC3D,CAAC,CAAC;EACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;GAO7B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { InputComponent } from './input';\n\ndescribe('admiralty-input', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input>\n <div class=\"text-input-container\">\n <input autocomplete=\"off\" id=\"admiralty-input-1\" name=\"admiralty-input-1\" type=\"text\" value=\"\">\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-input>\n `);\n });\n\n it('renders with a label', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input label=\"test-label\"></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input label=\"test-label\">\n <div class=\"text-input-container\">\n <admiralty-label for=\"admiralty-input-2\">test-label</admiralty-label>\n <input autocomplete=\"off\" id=\"admiralty-input-2\" name=\"admiralty-input-2\" type=\"text\" value=\"\">\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-input>\n `);\n });\n\n it('renders disabled', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input disabled></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input disabled>\n <div class=\"text-input-container\">\n <input disabled autocomplete=\"off\" class=\"disabled\" id=\"admiralty-input-3\" name=\"admiralty-input-3\" type=\"text\" value=\"\">\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-input>\n `);\n });\n\n it('renders invalid even without invalidMessage', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input invalid=\"true\"></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input invalid=\"true\">\n <div class=\"text-input-container\">\n <input autocomplete=\"off\" class=\"invalid\" id=\"admiralty-input-4\" name=\"admiralty-input-4\" type=\"text\" value=\"\">\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-input>\n `);\n });\n\n it('renders invalid with invalidMessage', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input invalid=\"true\" invalid-message=\"This is invalid!\"></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input invalid=\"true\" invalid-message=\"This is invalid!\">\n <div class=\"text-input-container\">\n <input autocomplete=\"off\" class=\"invalid\" id=\"admiralty-input-5\" name=\"admiralty-input-5\" type=\"text\" value=\"\">\n <admiralty-input-invalid style=\"visibility: visible;\">\n This is invalid!\n </admiralty-input-invalid>\n </div>\n </admiralty-input>\n `);\n });\n\n it('renders with type', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input type=\"date\"></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input type=\"date\">\n <div class=\"text-input-container\">\n <input type=\"date\" autocomplete=\"off\" id=\"admiralty-input-6\" name=\"admiralty-input-6\" value=\"\">\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-input>\n `);\n });\n});\n\nit('renders with maxlength', async () => {\n const page = await newSpecPage({\n components: [InputComponent],\n html: `<admiralty-input max-length=\"1\"></admiralty-input>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input max-length=\"1\">\n <div class=\"text-input-container\">\n <input autocomplete=\"off\" class=\"\" id=\"admiralty-input-7\" maxlength=\"1\" name=\"admiralty-input-7\" type=\"text\" value=\"\">\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-input>\n `);\n});\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
+
describe('admiralty-input-invalid', () => {
|
|
3
|
+
it('renders', async () => {
|
|
4
|
+
const page = await newE2EPage();
|
|
5
|
+
await page.setContent('<admiralty-input-invalid></admiralty-input-invalid>');
|
|
6
|
+
const element = await page.find('admiralty-input-invalid');
|
|
7
|
+
expect(element).toHaveClass('hydrated');
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=input-invalid.e2e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-invalid.e2e.js","sourceRoot":"","sources":["../../../src/components/input-invalid/input-invalid.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;EACvC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;IAChC,MAAM,IAAI,CAAC,UAAU,CAAC,qDAAqD,CAAC,CAAC;IAE7E,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC3D,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;EAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newE2EPage } from '@stencil/core/testing';\n\ndescribe('admiralty-input-invalid', () => {\n it('renders', async () => {\n const page = await newE2EPage();\n await page.setContent('<admiralty-input-invalid></admiralty-input-invalid>');\n\n const element = await page.find('admiralty-input-invalid');\n expect(element).toHaveClass('hydrated');\n });\n});\n"]}
|
package/dist/collection/components/{input-error/input-error.js → input-invalid/input-invalid.js}
RENAMED
|
@@ -2,23 +2,23 @@ import { h, Host } from '@stencil/core';
|
|
|
2
2
|
import { faExclamation } from '@fortawesome/free-solid-svg-icons';
|
|
3
3
|
/**
|
|
4
4
|
* @slot - The error content should be placed in the slot e.g.
|
|
5
|
-
* `<admiralty-input-
|
|
5
|
+
* `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`
|
|
6
6
|
*/
|
|
7
|
-
export class
|
|
7
|
+
export class InputInvalidComponent {
|
|
8
8
|
render() {
|
|
9
9
|
return (h(Host, null, h("admiralty-icon", { "icon-name": faExclamation.iconName, class: "error-icon" }), h("p", null, h("slot", null))));
|
|
10
10
|
}
|
|
11
|
-
static get is() { return "admiralty-input-
|
|
11
|
+
static get is() { return "admiralty-input-invalid"; }
|
|
12
12
|
static get encapsulation() { return "scoped"; }
|
|
13
13
|
static get originalStyleUrls() {
|
|
14
14
|
return {
|
|
15
|
-
"$": ["input-
|
|
15
|
+
"$": ["input-invalid.scss"]
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
static get styleUrls() {
|
|
19
19
|
return {
|
|
20
|
-
"$": ["input-
|
|
20
|
+
"$": ["input-invalid.css"]
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=input-
|
|
24
|
+
//# sourceMappingURL=input-invalid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-invalid.js","sourceRoot":"","sources":["../../../src/components/input-invalid/input-invalid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE;;;GAGG;AAMH,MAAM,OAAO,qBAAqB;EAChC,MAAM;IACJ,OAAO,CACL,EAAC,IAAI;MACH,mCAA2B,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,YAAY,GAAkB;MACvF;QACE,eAAa,CACX,CACC,CACR,CAAC;EACJ,CAAC;;;;;;;;;CACF","sourcesContent":["import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { newSpecPage } from '@stencil/core/testing';
|
|
2
|
+
import { InputInvalidComponent } from './input-invalid';
|
|
3
|
+
describe('input-invalid', () => {
|
|
4
|
+
it('renders', async () => {
|
|
5
|
+
const page = await newSpecPage({
|
|
6
|
+
components: [InputInvalidComponent],
|
|
7
|
+
html: `<admiralty-input-invalid>Test</admiralty-input-invalid>`,
|
|
8
|
+
});
|
|
9
|
+
expect(page.root).toEqualHtml(`
|
|
10
|
+
<admiralty-input-invalid>
|
|
11
|
+
<admiralty-icon class="error-icon" icon-name="exclamation"></admiralty-icon>
|
|
12
|
+
<p>
|
|
13
|
+
Test
|
|
14
|
+
</p>
|
|
15
|
+
</admiralty-input-invalid>
|
|
16
|
+
`);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=input-invalid.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-invalid.spec.js","sourceRoot":"","sources":["../../../src/components/input-invalid/input-invalid.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;EAC7B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,qBAAqB,CAAC;MACnC,IAAI,EAAE,yDAAyD;KAChE,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;KAO7B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { InputInvalidComponent } from './input-invalid';\n\ndescribe('input-invalid', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [InputInvalidComponent],\n html: `<admiralty-input-invalid>Test</admiralty-input-invalid>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-input-invalid>\n <admiralty-icon class=\"error-icon\" icon-name=\"exclamation\"></admiralty-icon>\n <p>\n Test\n </p>\n</admiralty-input-invalid>\n `);\n });\n});\n"]}
|
|
@@ -57,7 +57,7 @@ export class RadioGroupComponent {
|
|
|
57
57
|
}
|
|
58
58
|
render() {
|
|
59
59
|
const { displayVertical } = this;
|
|
60
|
-
return (h(Host, null, h("div", { class: { 'radio-group': true, 'stack': displayVertical }, role: "radiogroup", onClick: this.onClick }, h("slot", null), h("admiralty-input-
|
|
60
|
+
return (h(Host, null, h("div", { class: { 'radio-group': true, 'stack': displayVertical }, role: "radiogroup", onClick: this.onClick }, h("slot", null), h("admiralty-input-invalid", { style: { visibility: this.invalid && this.invalidMessage ? 'visible' : 'hidden' } }, this.invalidMessage))));
|
|
61
61
|
}
|
|
62
62
|
static get is() { return "admiralty-radio-group"; }
|
|
63
63
|
static get encapsulation() { return "scoped"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../../src/components/radio-group/radio-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,aAAa,GAAW,CAAC,CAAC","sourcesContent":["import { Component, Host, h, Prop, Element, Event, EventEmitter, ComponentInterface, Watch } from '@stencil/core';\nimport { RadioGroupChangeEventDetail } from './radio-group-interface';\n\n@Component({\n tag: 'admiralty-radio-group',\n styleUrl: 'radio-group.scss',\n scoped: true,\n})\nexport class RadioGroupComponent implements ComponentInterface {\n private inputId = `admiralty-rg-${radioGroupIds++}`;\n\n @Element() el!: HTMLElement;\n\n /**\n * The name of the control, which is submitted with the form data\n */\n @Prop() name: string = this.inputId;\n\n /**\n * The value of the radio group\n */\n @Prop({ mutable: true }) value: any | null;\n\n /**\n * Setting this true displays the radio options vertically (defaults to false)\n */\n @Prop() displayVertical: boolean = false;\n\n /**\n * Whether to show the input in an invalid state\n */\n @Prop() invalid: boolean = false;\n\n /**\n * The message to show when the input is invalid\n */\n @Prop() invalidMessage: string;\n\n @Watch('value')\n valueChanged(value: any) {\n this.setRadioTabindex(value);\n this.admiraltyChange.emit({ value });\n }\n\n /**\n * Event fired when the checked radio button changes\n */\n @Event() admiraltyChange: EventEmitter<RadioGroupChangeEventDetail>;\n\n @Watch('invalid')\n invalidChanged(value: boolean) {\n this.getRadios().forEach(radio => {\n if (value) {\n radio.setAttribute('invalid', 'true');\n } else {\n radio.removeAttribute('invalid');\n }\n });\n }\n\n componentDidLoad(): void {\n this.setRadioTabindex(this.value);\n this.invalidChanged(this.invalid);\n }\n\n private setRadioTabindex = (value: any | undefined) => {\n const radios = this.getRadios();\n\n // Get the first radio that is not disabled and the checked one\n const first = radios.find(radio => !radio.disabled);\n const checked = radios.find(radio => radio.value === value && !radio.disabled);\n\n if (!first && !checked) {\n return;\n }\n\n // If an enabled checked radio exists, set it to be the focusable radio\n // otherwise we default to focus the first radio\n const focusable = checked || first;\n\n for (const radio of radios) {\n const tabindex = radio === focusable ? 0 : -1;\n radio.setButtonTabindex(tabindex);\n }\n };\n\n private getRadios(): HTMLAdmiraltyRadioElement[] {\n return Array.from(this.el.querySelectorAll('admiralty-radio'));\n }\n private onClick = (e: Event) => {\n const selectedRadio = e.target && (e.target as HTMLElement).closest('admiralty-radio');\n\n if (selectedRadio) {\n const currentValue = this.value;\n const newValue = selectedRadio.value;\n\n if (newValue !== currentValue) {\n this.value = newValue;\n }\n }\n };\n\n render() {\n const { displayVertical } = this;\n\n return (\n <Host>\n <div class={{ 'radio-group': true, 'stack': displayVertical }} role=\"radiogroup\" onClick={this.onClick}>\n <slot></slot>\n <admiralty-input-invalid style={{ visibility: this.invalid && this.invalidMessage ? 'visible' : 'hidden' }}>{this.invalidMessage}</admiralty-input-invalid>\n </div>\n </Host>\n );\n }\n}\n\nlet radioGroupIds: number = 0;\n"]}
|
|
@@ -11,7 +11,7 @@ describe('radio-group', () => {
|
|
|
11
11
|
<admiralty-radio-group>
|
|
12
12
|
<div class="radio-group" role="radiogroup">
|
|
13
13
|
|
|
14
|
-
<admiralty-input-
|
|
14
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
15
15
|
</div>
|
|
16
16
|
</admiralty-radio-group>
|
|
17
17
|
`);
|
|
@@ -48,7 +48,7 @@ describe('radio-group', () => {
|
|
|
48
48
|
</label>
|
|
49
49
|
</div>
|
|
50
50
|
</admiralty-radio>
|
|
51
|
-
<admiralty-input-
|
|
51
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
52
52
|
</div>
|
|
53
53
|
</admiralty-radio-group>
|
|
54
54
|
`);
|
|
@@ -85,7 +85,7 @@ describe('radio-group', () => {
|
|
|
85
85
|
</label>
|
|
86
86
|
</div>
|
|
87
87
|
</admiralty-radio>
|
|
88
|
-
<admiralty-input-
|
|
88
|
+
<admiralty-input-invalid style="visibility: hidden;"></admiralty-input-invalid>
|
|
89
89
|
</div>
|
|
90
90
|
</admiralty-radio-group>
|
|
91
91
|
`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.spec.js","sourceRoot":"","sources":["../../../src/components/radio-group/radio-group.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;EAC3B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,mBAAmB,CAAC;MACjC,IAAI,EAAE,iDAAiD;KACxD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;KAO7B,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;IACpD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,mBAAmB,EAAE,cAAc,CAAC;MACjD,IAAI,EAAE;;;;;OAKL;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;KAyBvC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;IAClD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,mBAAmB,EAAE,cAAc,CAAC;MACjD,IAAI,EAAE;;;;;SAKH;KACJ,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;KAyBvC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;IACnD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;MAC7B,UAAU,EAAE,CAAC,mBAAmB,EAAE,cAAc,CAAC;MACjD,IAAI,EAAE;;;;;SAKH;KACJ,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAE3B,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAEvD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,wBAAwB,CAAqB,CAAC;IAClF,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,wBAAwB,CAAqB,CAAC;IAClF,IAAI,CAAC,KAAK,EAAE,CAAC;IAEb,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;EACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { RadioGroupComponent } from './radio-group';\nimport { RadioComponent } from '../radio/radio';\n\ndescribe('radio-group', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [RadioGroupComponent],\n html: `<admiralty-radio-group></admiralty-radio-group>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-radio-group>\n <div class=\"radio-group\" role=\"radiogroup\">\n\n <admiralty-input-
|
|
1
|
+
{"version":3,"file":"radio-group.spec.js","sourceRoot":"","sources":["../../../src/components/radio-group/radio-group.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,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AAE;;;;;SAKH;KACJ,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAE3B,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAEvD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,wBAAwB,CAAqB,CAAC;IAClF,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,wBAAwB,CAAqB,CAAC;IAClF,IAAI,CAAC,KAAK,EAAE,CAAC;IAEb,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAE5B,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;EACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { RadioGroupComponent } from './radio-group';\nimport { RadioComponent } from '../radio/radio';\n\ndescribe('radio-group', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [RadioGroupComponent],\n html: `<admiralty-radio-group></admiralty-radio-group>`,\n });\n expect(page.root).toEqualHtml(`\n <admiralty-radio-group>\n <div class=\"radio-group\" role=\"radiogroup\">\n\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-radio-group>\n `);\n });\n\n it('renders 2 radio buttons horizontally', async () => {\n const page = await newSpecPage({\n components: [RadioGroupComponent, RadioComponent],\n html: `\n <admiralty-radio-group>\n <admiralty-radio name=\"grp\" value=\"option1\">Option 1</admiralty-radio>\n <admiralty-radio name=\"grp\" value=\"option2\">Option 2</admiralty-radio>\n </admiralty-radio-group>\n `,\n });\n\n expect(page.root).toMatchInlineSnapshot(`\n <admiralty-radio-group>\n <!---->\n <div class=\"radio-group\" role=\"radiogroup\">\n <admiralty-radio name=\"grp\" value=\"option1\">\n <!---->\n <div class=\"admiralty-radio\">\n <input aria-checked=\"false\" aria-labelledby=\"admiralty-radio-0\" class=\"admiralty-radio\" id=\"admiralty-radio-0\" name=\"grp\" tabindex=\"0\" type=\"radio\" value=\"option1\">\n <label htmlfor=\"admiralty-radio-0\">\n Option 1\n </label>\n </div>\n </admiralty-radio>\n <admiralty-radio name=\"grp\" value=\"option2\">\n <!---->\n <div class=\"admiralty-radio\">\n <input aria-checked=\"false\" aria-labelledby=\"admiralty-radio-1\" class=\"admiralty-radio\" id=\"admiralty-radio-1\" name=\"grp\" tabindex=\"-1\" type=\"radio\" value=\"option2\">\n <label htmlfor=\"admiralty-radio-1\">\n Option 2\n </label>\n </div>\n </admiralty-radio>\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-radio-group>\n `);\n });\n\n it('renders 2 radio buttons vertically', async () => {\n const page = await newSpecPage({\n components: [RadioGroupComponent, RadioComponent],\n html: `\n <admiralty-radio-group display-vertical=\"true\">\n <admiralty-radio name=\"grp\" value=\"option1\">Option 1</admiralty-radio>\n <admiralty-radio name=\"grp\" value=\"option2\">Option 2</admiralty-radio>\n </admiralty-radio-group>\n `,\n });\n\n expect(page.root).toMatchInlineSnapshot(`\n <admiralty-radio-group display-vertical=\"true\">\n <!---->\n <div class=\"radio-group stack\" role=\"radiogroup\">\n <admiralty-radio name=\"grp\" value=\"option1\">\n <!---->\n <div class=\"admiralty-radio\">\n <input aria-checked=\"false\" aria-labelledby=\"admiralty-radio-2\" class=\"admiralty-radio\" id=\"admiralty-radio-2\" name=\"grp\" tabindex=\"0\" type=\"radio\" value=\"option1\">\n <label htmlfor=\"admiralty-radio-2\">\n Option 1\n </label>\n </div>\n </admiralty-radio>\n <admiralty-radio name=\"grp\" value=\"option2\">\n <!---->\n <div class=\"admiralty-radio\">\n <input aria-checked=\"false\" aria-labelledby=\"admiralty-radio-3\" class=\"admiralty-radio\" id=\"admiralty-radio-3\" name=\"grp\" tabindex=\"-1\" type=\"radio\" value=\"option2\">\n <label htmlfor=\"admiralty-radio-3\">\n Option 2\n </label>\n </div>\n </admiralty-radio>\n <admiralty-input-invalid style=\"visibility: hidden;\"></admiralty-input-invalid>\n </div>\n </admiralty-radio-group>\n `);\n });\n\n it('fires event on radio button changed', async () => {\n const page = await newSpecPage({\n components: [RadioGroupComponent, RadioComponent],\n html: `\n <admiralty-radio-group display-vertical=\"true\">\n <admiralty-radio name=\"grp\" value=\"option1\">Option 1</admiralty-radio>\n <admiralty-radio name=\"grp\" value=\"option2\">Option 2</admiralty-radio>\n </admiralty-radio-group>\n `,\n });\n\n const eventSpy = jest.fn();\n\n page.doc.addEventListener('admiraltyChange', eventSpy);\n\n const rad1 = page.doc.querySelector('input[value=\"option1\"]') as HTMLInputElement;\n rad1.click();\n await page.waitForChanges();\n\n const rad2 = page.doc.querySelector('input[value=\"option2\"]') as HTMLInputElement;\n rad2.click();\n\n await page.waitForChanges();\n\n expect(eventSpy).toBeCalledTimes(2);\n });\n});\n"]}
|
|
@@ -3,8 +3,8 @@ export class SelectComponent {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
this.id = `admiralty-select-${++nextId}`;
|
|
5
5
|
this.disabled = false;
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
6
|
+
this.invalid = false;
|
|
7
|
+
this.invalidMessage = null;
|
|
8
8
|
this.hint = null;
|
|
9
9
|
this.label = 'Choose a colour';
|
|
10
10
|
this.width = undefined;
|
|
@@ -40,9 +40,9 @@ export class SelectComponent {
|
|
|
40
40
|
this.selectOption();
|
|
41
41
|
}
|
|
42
42
|
render() {
|
|
43
|
-
const { disabled,
|
|
43
|
+
const { disabled, hint, id, label } = this;
|
|
44
44
|
const disabledClass = disabled ? 'disabled' : '';
|
|
45
|
-
return (h(Host, null, h("div", { class: `admiralty-select ${disabledClass}` }, h("admiralty-label", { disabled: this.disabled, for: id }, label), hint ? h("admiralty-hint", { disabled: this.disabled }, hint) : null, h("div", { class: "select-wrapper", style: this.width ? { maxWidth: `${this.width}px` } : {} }, h("select", { ref: select => (this.nativeInput = select), id: id, class: { 'admiralty-form-control': true, '
|
|
45
|
+
return (h(Host, null, h("div", { class: `admiralty-select ${disabledClass}` }, h("admiralty-label", { disabled: this.disabled, for: id }, label), hint ? h("admiralty-hint", { disabled: this.disabled }, hint) : null, h("div", { class: "select-wrapper", style: this.width ? { maxWidth: `${this.width}px` } : {} }, h("select", { ref: select => (this.nativeInput = select), id: id, class: { 'admiralty-form-control': true, 'invalid': this.invalid, 'disabled': disabled }, "aria-disabled": disabled ? 'true' : 'false', "aria-label": label, onChange: event => this.handleSelect(event), onBlur: event => this.handleBlur(event), disabled: disabled }, h("slot", null)), h("admiralty-icon", { class: `select-down-icon ${disabledClass}`, "icon-name": "angle-down" })), h("admiralty-input-invalid", { style: { visibility: this.invalid && this.invalidMessage ? 'visible' : 'hidden' } }, this.invalidMessage))));
|
|
46
46
|
}
|
|
47
47
|
static get is() { return "admiralty-select"; }
|
|
48
48
|
static get encapsulation() { return "scoped"; }
|
|
@@ -76,7 +76,7 @@ export class SelectComponent {
|
|
|
76
76
|
"reflect": false,
|
|
77
77
|
"defaultValue": "false"
|
|
78
78
|
},
|
|
79
|
-
"
|
|
79
|
+
"invalid": {
|
|
80
80
|
"type": "boolean",
|
|
81
81
|
"mutable": false,
|
|
82
82
|
"complexType": {
|
|
@@ -88,13 +88,13 @@ export class SelectComponent {
|
|
|
88
88
|
"optional": false,
|
|
89
89
|
"docs": {
|
|
90
90
|
"tags": [],
|
|
91
|
-
"text": "
|
|
91
|
+
"text": "Whether to show that the select is in an invalid state."
|
|
92
92
|
},
|
|
93
|
-
"attribute": "
|
|
93
|
+
"attribute": "invalid",
|
|
94
94
|
"reflect": false,
|
|
95
95
|
"defaultValue": "false"
|
|
96
96
|
},
|
|
97
|
-
"
|
|
97
|
+
"invalidMessage": {
|
|
98
98
|
"type": "string",
|
|
99
99
|
"mutable": false,
|
|
100
100
|
"complexType": {
|
|
@@ -106,9 +106,9 @@ export class SelectComponent {
|
|
|
106
106
|
"optional": false,
|
|
107
107
|
"docs": {
|
|
108
108
|
"tags": [],
|
|
109
|
-
"text": "The
|
|
109
|
+
"text": "The message to show when the select is invalid."
|
|
110
110
|
},
|
|
111
|
-
"attribute": "
|
|
111
|
+
"attribute": "invalid-message",
|
|
112
112
|
"reflect": false,
|
|
113
113
|
"defaultValue": "null"
|
|
114
114
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/components/select/select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAQ9F,MAAM,OAAO,eAAe;;IAG1B,OAAE,GAAW,oBAAoB,EAAE,MAAM,EAAE,CAAC;oBAIhB,KAAK;
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/components/select/select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAQ9F,MAAM,OAAO,eAAe;;IAG1B,OAAE,GAAW,oBAAoB,EAAE,MAAM,EAAE,CAAC;oBAIhB,KAAK;mBAIN,KAAK;0BAIC,IAAI;gBAId,IAAI;iBAIH,iBAAiB;;iBAiBiB,EAAE;;EAGlD,YAAY;IACpB,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,IAAI,YAAY,IAAI,YAAY,CAAC,KAAK,KAAK,KAAK,EAAE;MAChD,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC;KAC5B;IACD,IAAI,CAAC,eAAe,CAAC,I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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,MAAM,GAAG,CAAC,CAAC","sourcesContent":["import { Component, Event, Prop, Element, EventEmitter, h, Host, Watch } from '@stencil/core';\nimport { SelectChangeEventDetail } from './select.interface';\n\n@Component({\n tag: 'admiralty-select',\n styleUrl: 'select.scss',\n scoped: true,\n})\nexport class SelectComponent {\n @Element() el?: HTMLElement;\n private nativeInput?: HTMLSelectElement;\n id: string = `admiralty-select-${++nextId}`;\n /**\n * If `true`, the user cannot interact with the select.\n */\n @Prop() disabled: boolean = false;\n /**\n * Whether to show that the select is in an invalid state.\n */\n @Prop() invalid: boolean = false;\n /**\n * The message to show when the select is invalid.\n */\n @Prop() invalidMessage: string = null;\n /**\n * The text that will be used as a field label.\n */\n @Prop() hint: string = null;\n /**\n * The text that will be used as a field label.\n */\n @Prop() label: string = 'Choose a colour';\n /**\n * The maximum width (px) for the input field.\n */\n @Prop() width?: number;\n /**\n * Emitted when the value has changed.\n */\n @Event() admiraltyChange: EventEmitter<SelectChangeEventDetail>;\n /**\n * Emitted when the component loses focus.\n */\n @Event() admiraltyBlur: EventEmitter<void>;\n\n /**\n * The value of the input.\n */\n @Prop({ mutable: true }) value?: string | number | null = '';\n\n @Watch('value')\n protected valueChanged() {\n const nativeSelect = this.nativeInput;\n const value = this.getValue();\n if (nativeSelect && nativeSelect.value !== value) {\n nativeSelect.value = value;\n }\n this.admiraltyChange.emit({ value: this.value == null ? this.getValue() : this.value.toString() });\n }\n\n private getValue(): string {\n return typeof this.value === 'number' ? this.value.toString() : (this.value || '').toString();\n }\n\n handleSelect(event: Event) {\n const select = event.target as HTMLSelectElement | null;\n if (select) {\n this.value = select.value || '';\n }\n }\n\n handleBlur(_event: FocusEvent): void {\n this.admiraltyBlur.emit();\n }\n\n selectOption() {\n const options = this.el.querySelectorAll('option');\n options.forEach(option => {\n option.selected = option.value === this.getValue();\n });\n }\n\n componentWillRender() {\n this.selectOption();\n }\n\n render() {\n const { disabled, hint, id, label } = this;\n const disabledClass = disabled ? 'disabled' : '';\n return (\n <Host>\n <div class={`admiralty-select ${disabledClass}`}>\n <admiralty-label disabled={this.disabled} for={id}>\n {label}\n </admiralty-label>\n {hint ? <admiralty-hint disabled={this.disabled}>{hint}</admiralty-hint> : null}\n <div class=\"select-wrapper\" style={this.width ? { maxWidth: `${this.width}px` } : {}}>\n <select\n ref={select => (this.nativeInput = select)}\n id={id}\n class={{ 'admiralty-form-control': true, 'invalid': this.invalid, 'disabled': disabled }}\n aria-disabled={disabled ? 'true' : 'false'}\n aria-label={label}\n onChange={event => this.handleSelect(event)}\n onBlur={event => this.handleBlur(event)}\n disabled={disabled}\n >\n <slot></slot>\n </select>\n <admiralty-icon class={`select-down-icon ${disabledClass}`} icon-name=\"angle-down\"></admiralty-icon>\n </div>\n <admiralty-input-invalid style={{ visibility: this.invalid && this.invalidMessage ? 'visible' : 'hidden' }}>{this.invalidMessage}</admiralty-input-invalid>\n </div>\n </Host>\n );\n }\n}\n\nlet nextId = 0;\n"]}
|