@nanoporetech-digital/components 2.12.0 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/index.cjs.js +4 -2
  3. package/dist/cjs/index.cjs.js.map +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/nano-components.cjs.js +1 -1
  6. package/dist/cjs/nano-field-validator.cjs.entry.js +266 -124
  7. package/dist/cjs/nano-field-validator.cjs.entry.js.map +1 -1
  8. package/dist/cjs/nano-file-upload.cjs.entry.js +1 -1
  9. package/dist/cjs/nano-file-upload.cjs.entry.js.map +1 -1
  10. package/dist/cjs/nano-input.cjs.entry.js +16 -3
  11. package/dist/cjs/nano-input.cjs.entry.js.map +1 -1
  12. package/dist/cjs/nano-nav-item_2.cjs.entry.js +1 -0
  13. package/dist/cjs/nano-nav-item_2.cjs.entry.js.map +1 -1
  14. package/dist/collection/components/accordion/accordion.js +1 -1
  15. package/dist/collection/components/alert/alert.helpers.js +2 -2
  16. package/dist/collection/components/alert/alert.helpers.js.map +1 -1
  17. package/dist/collection/components/alert/alert.js +1 -1
  18. package/dist/collection/components/algolia/algolia-filter.js +2 -2
  19. package/dist/collection/components/algolia/algolia-input.js +5 -5
  20. package/dist/collection/components/algolia/algolia-results.js +1 -1
  21. package/dist/collection/components/algolia/algolia.js +6 -6
  22. package/dist/collection/components/checkbox/checkbox-group.js +2 -2
  23. package/dist/collection/components/checkbox/checkbox.js +3 -3
  24. package/dist/collection/components/datalist/datalist.js +1 -1
  25. package/dist/collection/components/date-input/date-input.js +8 -8
  26. package/dist/collection/components/date-picker/date-picker.js +5 -5
  27. package/dist/collection/components/details/details.js +1 -1
  28. package/dist/collection/components/dialog/dialog.js +1 -1
  29. package/dist/collection/components/dropdown/dropdown.js +1 -1
  30. package/dist/collection/components/field-validator/field-validator-interface.js.map +1 -1
  31. package/dist/collection/components/field-validator/field-validator.js +345 -130
  32. package/dist/collection/components/field-validator/field-validator.js.map +1 -1
  33. package/dist/collection/components/file-upload/file-upload.css +0 -1
  34. package/dist/collection/components/file-upload/file-upload.js +4 -4
  35. package/dist/collection/components/global-nav/global-nav.js +4 -4
  36. package/dist/collection/components/grid/grid-item.js +1 -1
  37. package/dist/collection/components/icon/icon.js +1 -1
  38. package/dist/collection/components/input/input.js +37 -8
  39. package/dist/collection/components/input/input.js.map +1 -1
  40. package/dist/collection/components/nav-item/nav-item.js +4 -4
  41. package/dist/collection/components/range/range.js +4 -4
  42. package/dist/collection/components/resize-observe/resize-observe.js +1 -1
  43. package/dist/collection/components/select/select.js +8 -7
  44. package/dist/collection/components/select/select.js.map +1 -1
  45. package/dist/collection/components/slides/slides.js +7 -7
  46. package/dist/collection/components/tabs/tab-group.js +2 -2
  47. package/dist/collection/index.js +1 -0
  48. package/dist/collection/index.js.map +1 -1
  49. package/dist/components/index.js +3 -2
  50. package/dist/components/index.js.map +1 -1
  51. package/dist/components/input.js +17 -3
  52. package/dist/components/input.js.map +1 -1
  53. package/dist/components/nano-field-validator.js +271 -126
  54. package/dist/components/nano-field-validator.js.map +1 -1
  55. package/dist/components/nano-file-upload.js +1 -1
  56. package/dist/components/nano-file-upload.js.map +1 -1
  57. package/dist/components/select.js +1 -0
  58. package/dist/components/select.js.map +1 -1
  59. package/dist/custom-elements/index.js +288 -132
  60. package/dist/custom-elements/index.js.map +1 -1
  61. package/dist/esm/index.js +3 -2
  62. package/dist/esm/index.js.map +1 -1
  63. package/dist/esm/loader.js +1 -1
  64. package/dist/esm/nano-components.js +1 -1
  65. package/dist/esm/nano-field-validator.entry.js +266 -124
  66. package/dist/esm/nano-field-validator.entry.js.map +1 -1
  67. package/dist/esm/nano-file-upload.entry.js +1 -1
  68. package/dist/esm/nano-file-upload.entry.js.map +1 -1
  69. package/dist/esm/nano-input.entry.js +16 -3
  70. package/dist/esm/nano-input.entry.js.map +1 -1
  71. package/dist/esm/nano-nav-item_2.entry.js +1 -0
  72. package/dist/esm/nano-nav-item_2.entry.js.map +1 -1
  73. package/dist/esm-es5/index.js +2 -2
  74. package/dist/esm-es5/index.js.map +1 -1
  75. package/dist/esm-es5/loader.js +1 -1
  76. package/dist/esm-es5/loader.js.map +1 -1
  77. package/dist/esm-es5/nano-components.js +1 -1
  78. package/dist/esm-es5/nano-components.js.map +1 -1
  79. package/dist/esm-es5/nano-field-validator.entry.js +2 -2
  80. package/dist/esm-es5/nano-field-validator.entry.js.map +1 -1
  81. package/dist/esm-es5/nano-file-upload.entry.js +1 -1
  82. package/dist/esm-es5/nano-file-upload.entry.js.map +1 -1
  83. package/dist/esm-es5/nano-input.entry.js +1 -1
  84. package/dist/esm-es5/nano-input.entry.js.map +1 -1
  85. package/dist/esm-es5/nano-nav-item_2.entry.js +1 -1
  86. package/dist/esm-es5/nano-nav-item_2.entry.js.map +1 -1
  87. package/dist/nano-components/index.esm.js +1 -1
  88. package/dist/nano-components/index.esm.js.map +1 -1
  89. package/dist/nano-components/nano-components.esm.js +1 -1
  90. package/dist/nano-components/nano-components.esm.js.map +1 -1
  91. package/dist/nano-components/p-085e03db.system.entry.js +5 -0
  92. package/dist/nano-components/p-085e03db.system.entry.js.map +1 -0
  93. package/dist/nano-components/p-53957ec6.system.js +1 -1
  94. package/dist/nano-components/p-53957ec6.system.js.map +1 -1
  95. package/dist/nano-components/{p-01667573.entry.js → p-634a58f7.entry.js} +2 -2
  96. package/dist/nano-components/p-634a58f7.entry.js.map +1 -0
  97. package/dist/nano-components/p-a07cf44c.system.entry.js +5 -0
  98. package/dist/nano-components/{p-4558a9c6.system.entry.js.map → p-a07cf44c.system.entry.js.map} +1 -1
  99. package/dist/nano-components/{p-96d9b8b9.system.entry.js → p-c2bbf0fb.system.entry.js} +2 -2
  100. package/dist/nano-components/p-c2bbf0fb.system.entry.js.map +1 -0
  101. package/dist/nano-components/{p-72893d12.system.entry.js → p-cb512cff.system.entry.js} +2 -2
  102. package/dist/nano-components/p-cb512cff.system.entry.js.map +1 -0
  103. package/dist/nano-components/p-e35226a9.entry.js +5 -0
  104. package/dist/nano-components/p-e35226a9.entry.js.map +1 -0
  105. package/dist/nano-components/p-e9fddc1a.entry.js +5 -0
  106. package/dist/nano-components/{p-91614b43.entry.js.map → p-e9fddc1a.entry.js.map} +1 -1
  107. package/dist/nano-components/{p-055f7d35.entry.js → p-ed0bdea9.entry.js} +2 -2
  108. package/dist/nano-components/p-ed0bdea9.entry.js.map +1 -0
  109. package/dist/nano-components/p-f62a40ea.system.js +5 -0
  110. package/dist/nano-components/{p-3258c568.system.js.map → p-f62a40ea.system.js.map} +1 -1
  111. package/dist/themes/nanopore.css +1 -1
  112. package/dist/themes/nanopore.css.map +1 -1
  113. package/dist/types/components/alert/alert.helpers.d.ts +2 -2
  114. package/dist/types/components/field-validator/field-validator-interface.d.ts +5 -1
  115. package/dist/types/components/field-validator/field-validator.d.ts +68 -12
  116. package/dist/types/components/input/input.d.ts +6 -1
  117. package/dist/types/components.d.ts +25 -3
  118. package/dist/types/index.d.ts +1 -0
  119. package/docs-json.json +65 -3
  120. package/docs-vscode.json +6 -2
  121. package/package.json +2 -2
  122. package/dist/nano-components/p-01667573.entry.js.map +0 -1
  123. package/dist/nano-components/p-055f7d35.entry.js.map +0 -1
  124. package/dist/nano-components/p-2b478ca1.system.entry.js +0 -5
  125. package/dist/nano-components/p-2b478ca1.system.entry.js.map +0 -1
  126. package/dist/nano-components/p-3258c568.system.js +0 -5
  127. package/dist/nano-components/p-4558a9c6.system.entry.js +0 -5
  128. package/dist/nano-components/p-5f4fc2b4.entry.js +0 -5
  129. package/dist/nano-components/p-5f4fc2b4.entry.js.map +0 -1
  130. package/dist/nano-components/p-72893d12.system.entry.js.map +0 -1
  131. package/dist/nano-components/p-91614b43.entry.js +0 -5
  132. package/dist/nano-components/p-96d9b8b9.system.entry.js.map +0 -1
@@ -3,7 +3,6 @@ import { ObservableMap } from '@stencil/store';
3
3
  import { ValidationState, ValidatorValueStore } from '../../interface';
4
4
  /**
5
5
  * A toolbox for `nano-...` form fields and form validation.
6
- *
7
6
  * - Easy to add validation accross field dependencies - e.g. "When Field1 contains '123' Field2 must contain '456'"
8
7
  * - Easy access to whole form and individual field validity states
9
8
  * - Easy access to form data payload
@@ -12,14 +11,17 @@ import { ValidationState, ValidatorValueStore } from '../../interface';
12
11
  */
13
12
  export declare class FieldValidator implements ComponentInterface {
14
13
  host: HTMLNanoFieldValidatorElement;
15
- userForm: HTMLFormElement;
16
14
  submitted: boolean;
15
+ userForm: HTMLFormElement;
17
16
  userFormChange(): void;
18
17
  private get activeForm();
19
18
  private set activeForm(value);
20
19
  private _activeForm;
21
20
  private mo;
22
- private fields;
21
+ private allFields;
22
+ private nanoFields;
23
+ private plainFields;
24
+ private nanoFieldSelector;
23
25
  private internalValidate;
24
26
  /** When should the fields perform validation. Will override / sync all nested `nano-...` controls */
25
27
  validateOn?: 'dirty' | 'submit' | 'submitThenDirty';
@@ -38,7 +40,7 @@ export declare class FieldValidator implements ComponentInterface {
38
40
  _store: ObservableMap<ValidatorValueStore>;
39
41
  /** The current form payload as a reactive proxy. @readonly */
40
42
  get payload(): ValidatorValueStore;
41
- /** Returns true if validation errors will be displayed to the user */
43
+ /** Returns true if validation errors will be displayed to the user. @readonly */
42
44
  get showValidation(): boolean;
43
45
  /** Get the current validation state of all form fields. @readonly
44
46
  * ```
@@ -53,6 +55,11 @@ export declare class FieldValidator implements ComponentInterface {
53
55
  ```
54
56
  */
55
57
  get validationState(): ValidationState[];
58
+ /** By default, `nano-field-validator` will also track all native form field elements.
59
+ * You can add extra web-component form fields to listen to
60
+ * (as long as they match the standard form field spec) by using the `fieldSelector` prop.
61
+ */
62
+ extraFieldSelector: string;
56
63
  /** A validation callback method.
57
64
  * @param field - The field name currently being evaluated
58
65
  * @param value - The value of the field currently being evaluated
@@ -73,6 +80,18 @@ export declare class FieldValidator implements ComponentInterface {
73
80
  * @param state - the state to load in the store
74
81
  */
75
82
  setStore(state: ValidatorValueStore): Promise<void>;
83
+ /**
84
+ * Sets custom validity for all / some form fields.
85
+ * @param validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error.
86
+ */
87
+ setCustomValidity(validity: {
88
+ [key: string]: string;
89
+ }): Promise<void[]>;
90
+ /**
91
+ * Clear all custom validation.
92
+ * @param validity
93
+ */
94
+ resetValidity(): Promise<void[]>;
76
95
  /** Fired whenever the payload changes */
77
96
  nanoPayloadChange: EventEmitter<ValidatorValueStore>;
78
97
  /**
@@ -88,14 +107,35 @@ export declare class FieldValidator implements ComponentInterface {
88
107
  nanoSubmit: EventEmitter;
89
108
  /** Fire on invalid form submission attempt */
90
109
  nanoInvalid: EventEmitter;
91
- private attachSlotObserver;
110
+ attachSlotObserver(): void;
111
+ /**
112
+ * During spec tests, mockelement props aren't set - only attributes.
113
+ * This irons out that kink
114
+ * @param field
115
+ * @returns
116
+ */
117
+ private getName;
92
118
  /** Checks for new `nano-...` fields and adds them to our watch array and value store */
93
119
  private setupFields;
94
120
  private storeToFields;
95
121
  /** Loops through all `nano-...` fields and extracts their values into our store */
96
122
  private fieldsToStore;
97
- /** Checks for user defined validations */
123
+ /**
124
+ * Tries to ascertain whether the current model
125
+ * value is the same as the `nano-file-upload` value
126
+ * @param fieldName - the key to access from the data store
127
+ * @param field - the nano-file-upload field to assess against
128
+ * @returns true for equal, false for not equal
129
+ */
130
+ private fileStateEqual;
131
+ /**
132
+ * Checks for user defined validations
133
+ * @param key - current key of the data model to validate
134
+ * @param newVal - the newly set, incoming value to validate
135
+ */
98
136
  private validate;
137
+ /** Loops through all store entries and checks custom validation */
138
+ private validateAllFields;
99
139
  /**
100
140
  * Utility to smooth out setting error messages
101
141
  * (it's a different method on `nano-checkbox` 'cos they don't show errors themselves)
@@ -103,17 +143,33 @@ export declare class FieldValidator implements ComponentInterface {
103
143
  * @param msg
104
144
  */
105
145
  private setFieldError;
106
- /** Loops through all store entries and checks field validity */
107
- private validateAllFields;
108
146
  private scrollToFirstInvalid;
109
147
  private submitForm;
110
- /** Fired whenever store values change and potentially checks validity */
148
+ /**
149
+ * Fired whenever store values change and potentially checks validity
150
+ * @param key - the key of the store that's just changed
151
+ * @param newVal - the incoming, new value
152
+ */
111
153
  private handleStoreChange;
112
- /** Handles field value changes and passes to store */
154
+ /**
155
+ * Handles nano field value changes and passes to store
156
+ * @param ev - the incoming change event
157
+ */
113
158
  private handleFieldChange;
114
- /** Handles default field validation events */
159
+ /**
160
+ * Handles non-nano field value changes and passes to store
161
+ * @param ev - the incoming change event
162
+ */
163
+ private handlePlainFieldChange;
164
+ /**
165
+ * Handles default field validation events
166
+ * @param ev - the invalid event
167
+ */
115
168
  private handleFormInvalid;
116
- /** stops default form submission, checks if valid, then submits manually */
169
+ /**
170
+ * stops default form submission, checks if valid, then submits manually
171
+ * @param e - a submit event from the nested form element
172
+ */
117
173
  private handleSubmit;
118
174
  connectedCallback(): void;
119
175
  componentDidLoad(): void;
@@ -235,6 +235,11 @@ export declare class Input implements ComponentInterface {
235
235
  * `input.focus()`.
236
236
  */
237
237
  setFocus(): Promise<void>;
238
+ /**
239
+ * Sets focus and select the text on the specified `nano-input`. Use this method instead of the global
240
+ * `input.select()`.
241
+ */
242
+ select(): Promise<void>;
238
243
  /**
239
244
  * Returns the native `<input>` element used under the hood.
240
245
  */
@@ -244,7 +249,7 @@ export declare class Input implements ComponentInterface {
244
249
  */
245
250
  showError(message: string): Promise<void>;
246
251
  onReset(e: any): void;
247
- handleBlur(e: KeyboardEvent | MouseEvent): void;
252
+ handleBlur(e: KeyboardEvent | MouseEvent | FocusEvent): void;
248
253
  private shouldClearOnEdit;
249
254
  private getValue;
250
255
  private validate;
@@ -5,7 +5,7 @@
5
5
  * It contains typing information for all components that exist in this project.
6
6
  */
7
7
  import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
- import { AlgoliaNetworkError, AloliaSearchResultDetail, CheckboxChangeEventDetail, Color, ControlValidity, ControlValidityEventDetail, DateDisabledPredicate, DateInputChangeEventDetail, DragEvent, DuetLocalizedText, FileInputChangeEventDetail, FileWithUrl, FilterChangeEventDetail, Flickity, FlickityOptions, GridSizes, IndexResult, InputChangeEventDetail, LocalDateOpts, NavItemEventDetail, OptionInterface, PageChangeEventDetail, PickerChangeEvent, RangeChangeEventDetail, RangeValue, ResizeStateChangeEventDetail, SearchIndex, SelectChangeEventDetail, SlideAnimation, StyleEventDetail, TextFieldTypes, ValidationState, ValidatorValueStore } from "./interface.d";
8
+ import { AlgoliaNetworkError, AloliaSearchResultDetail, CheckboxChangeEventDetail, Color, ControlValidity, ControlValidityEventDetail, DateDisabledPredicate, DateInputChangeEventDetail, DragEvent, DuetLocalizedText, FileInputChangeEventDetail, FileWithUrl, FilterChangeEventDetail, Flickity, FlickityOptions, GridSizes, IndexResult, InputChangeEventDetail, LocalDateOpts, NanoFormEles, NavItemEventDetail, OptionInterface, PageChangeEventDetail, PickerChangeEvent, PlainFormEles, RangeChangeEventDetail, RangeValue, ResizeStateChangeEventDetail, SearchIndex, SelectChangeEventDetail, SlideAnimation, StyleEventDetail, TextFieldTypes, ValidationState, ValidatorValueStore } from "./interface.d";
9
9
  import { StorageMethods } from "./utils/store/component-store";
10
10
  import { DaysOfWeek } from "./utils/date-utils";
11
11
  import { PopoverPlacement } from "./utils/popover";
@@ -743,21 +743,35 @@ export namespace Components {
743
743
  * Returns true if any nested fields have been changed @readonly
744
744
  */
745
745
  "dirty": boolean;
746
+ /**
747
+ * By default, `nano-field-validator` will also track all native form field elements. You can add extra web-component form fields to listen to (as long as they match the standard form field spec) by using the `fieldSelector` prop.
748
+ */
749
+ "extraFieldSelector": string;
746
750
  /**
747
751
  * The current form payload as a reactive proxy. @readonly
748
752
  */
749
753
  "payload": ValidatorValueStore;
754
+ /**
755
+ * Clear all custom validation.
756
+ * @param validity
757
+ */
758
+ "resetValidity": () => Promise<void[]>;
750
759
  /**
751
760
  * Tries to scroll to the first invalid field on submit
752
761
  */
753
762
  "scrollToInvalid": boolean;
763
+ /**
764
+ * Sets custom validity for all / some form fields.
765
+ * @param validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error.
766
+ */
767
+ "setCustomValidity": (validity: { [key: string]: string; }) => Promise<void[]>;
754
768
  /**
755
769
  * Sets the state of the form using an object of key / value pairs.
756
770
  * @param state - the state to load in the store
757
771
  */
758
772
  "setStore": (state: ValidatorValueStore) => Promise<void>;
759
773
  /**
760
- * Returns true if validation errors will be displayed to the user
774
+ * Returns true if validation errors will be displayed to the user. @readonly
761
775
  */
762
776
  "showValidation": boolean;
763
777
  /**
@@ -1290,6 +1304,10 @@ export namespace Components {
1290
1304
  * relevant to type="textarea". Default number of rows to show
1291
1305
  */
1292
1306
  "rows": number;
1307
+ /**
1308
+ * Sets focus and select the text on the specified `nano-input`. Use this method instead of the global `input.select()`.
1309
+ */
1310
+ "select": () => Promise<void>;
1293
1311
  /**
1294
1312
  * Sets focus on the specified `nano-input`. Use this method instead of the global `input.focus()`.
1295
1313
  */
@@ -3116,6 +3134,10 @@ declare namespace LocalJSX {
3116
3134
  * Returns true if any nested fields have been changed @readonly
3117
3135
  */
3118
3136
  "dirty"?: boolean;
3137
+ /**
3138
+ * By default, `nano-field-validator` will also track all native form field elements. You can add extra web-component form fields to listen to (as long as they match the standard form field spec) by using the `fieldSelector` prop.
3139
+ */
3140
+ "extraFieldSelector"?: string;
3119
3141
  /**
3120
3142
  * Fire on invalid form submission attempt
3121
3143
  */
@@ -3137,7 +3159,7 @@ declare namespace LocalJSX {
3137
3159
  */
3138
3160
  "scrollToInvalid"?: boolean;
3139
3161
  /**
3140
- * Returns true if validation errors will be displayed to the user
3162
+ * Returns true if validation errors will be displayed to the user. @readonly
3141
3163
  */
3142
3164
  "showValidation"?: boolean;
3143
3165
  /**
@@ -2,3 +2,4 @@ export * from './components/alert/alert.helpers';
2
2
  export * from './components/dialog/dialog.helpers';
3
3
  export { debounce as nanoDebounce, throttle as nanoThrottle, } from './utils/throttle';
4
4
  export { raf as nanoRaf } from './utils';
5
+ export { getTabbableElements as nanoGetTabElements } from './utils/tabbable';
package/docs-json.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2022-08-11T13:25:20",
2
+ "timestamp": "2022-09-26T10:25:39",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "2.12.2",
@@ -5375,7 +5375,7 @@
5375
5375
  "encapsulation": "none",
5376
5376
  "tag": "nano-field-validator",
5377
5377
  "readme": "# nano-field-validator\n\n\n",
5378
- "docs": "A toolbox for `nano-...` form fields and form validation.\n\n- Easy to add validation accross field dependencies - e.g. \"When Field1 contains '123' Field2 must contain '456'\"\n- Easy access to whole form and individual field validity states\n- Easy access to form data payload\n= Access to 2-way, data bound reactive store\n- Scroll to invalid field on submit",
5378
+ "docs": "A toolbox for `nano-...` form fields and form validation.\n- Easy to add validation accross field dependencies - e.g. \"When Field1 contains '123' Field2 must contain '456'\"\n- Easy access to whole form and individual field validity states\n- Easy access to form data payload\n= Access to 2-way, data bound reactive store\n- Scroll to invalid field on submit",
5379
5379
  "docsTags": [],
5380
5380
  "usage": {},
5381
5381
  "props": [
@@ -5398,6 +5398,25 @@
5398
5398
  "getter": true,
5399
5399
  "setter": false
5400
5400
  },
5401
+ {
5402
+ "name": "extraFieldSelector",
5403
+ "type": "string",
5404
+ "mutable": false,
5405
+ "attr": "extra-field-selector",
5406
+ "reflectToAttr": false,
5407
+ "docs": "By default, `nano-field-validator` will also track all native form field elements.\nYou can add extra web-component form fields to listen to\n(as long as they match the standard form field spec) by using the `fieldSelector` prop.",
5408
+ "docsTags": [],
5409
+ "default": "'input, select, textarea'",
5410
+ "values": [
5411
+ {
5412
+ "type": "string"
5413
+ }
5414
+ ],
5415
+ "optional": false,
5416
+ "required": false,
5417
+ "getter": false,
5418
+ "setter": false
5419
+ },
5401
5420
  {
5402
5421
  "name": "payload",
5403
5422
  "type": "ValidatorValueStore",
@@ -5440,7 +5459,7 @@
5440
5459
  "mutable": false,
5441
5460
  "attr": "show-validation",
5442
5461
  "reflectToAttr": false,
5443
- "docs": "Returns true if validation errors will be displayed to the user",
5462
+ "docs": "Returns true if validation errors will be displayed to the user. @readonly",
5444
5463
  "docsTags": [],
5445
5464
  "values": [
5446
5465
  {
@@ -5568,6 +5587,38 @@
5568
5587
  }
5569
5588
  ],
5570
5589
  "methods": [
5590
+ {
5591
+ "name": "resetValidity",
5592
+ "returns": {
5593
+ "type": "Promise<void[]>",
5594
+ "docs": ""
5595
+ },
5596
+ "signature": "resetValidity() => Promise<void[]>",
5597
+ "parameters": [],
5598
+ "docs": "Clear all custom validation.",
5599
+ "docsTags": [
5600
+ {
5601
+ "name": "param",
5602
+ "text": "validity"
5603
+ }
5604
+ ]
5605
+ },
5606
+ {
5607
+ "name": "setCustomValidity",
5608
+ "returns": {
5609
+ "type": "Promise<void[]>",
5610
+ "docs": ""
5611
+ },
5612
+ "signature": "setCustomValidity(validity: { [key: string]: string; }) => Promise<void[]>",
5613
+ "parameters": [],
5614
+ "docs": "Sets custom validity for all / some form fields.",
5615
+ "docsTags": [
5616
+ {
5617
+ "name": "param",
5618
+ "text": "validity - a validity object of `{fieldName: errorString}` pairs. Set as an empty string to clear the error."
5619
+ }
5620
+ ]
5621
+ },
5571
5622
  {
5572
5623
  "name": "setStore",
5573
5624
  "returns": {
@@ -9124,6 +9175,17 @@
9124
9175
  }
9125
9176
  ]
9126
9177
  },
9178
+ {
9179
+ "name": "select",
9180
+ "returns": {
9181
+ "type": "Promise<void>",
9182
+ "docs": ""
9183
+ },
9184
+ "signature": "select() => Promise<void>",
9185
+ "parameters": [],
9186
+ "docs": "Sets focus and select the text on the specified `nano-input`. Use this method instead of the global\n`input.select()`.",
9187
+ "docsTags": []
9188
+ },
9127
9189
  {
9128
9190
  "name": "setFocus",
9129
9191
  "returns": {
package/docs-vscode.json CHANGED
@@ -1067,20 +1067,24 @@
1067
1067
  "name": "nano-field-validator",
1068
1068
  "description": {
1069
1069
  "kind": "markdown",
1070
- "value": "A toolbox for `nano-...` form fields and form validation.\n\n- Easy to add validation accross field dependencies - e.g. \"When Field1 contains '123' Field2 must contain '456'\"\n- Easy access to whole form and individual field validity states\n- Easy access to form data payload\n= Access to 2-way, data bound reactive store\n- Scroll to invalid field on submit"
1070
+ "value": "A toolbox for `nano-...` form fields and form validation.\n- Easy to add validation accross field dependencies - e.g. \"When Field1 contains '123' Field2 must contain '456'\"\n- Easy access to whole form and individual field validity states\n- Easy access to form data payload\n= Access to 2-way, data bound reactive store\n- Scroll to invalid field on submit"
1071
1071
  },
1072
1072
  "attributes": [
1073
1073
  {
1074
1074
  "name": "dirty",
1075
1075
  "description": "Returns true if any nested fields have been changed @readonly"
1076
1076
  },
1077
+ {
1078
+ "name": "extra-field-selector",
1079
+ "description": "By default, `nano-field-validator` will also track all native form field elements.\nYou can add extra web-component form fields to listen to\n(as long as they match the standard form field spec) by using the `fieldSelector` prop."
1080
+ },
1077
1081
  {
1078
1082
  "name": "scroll-to-invalid",
1079
1083
  "description": "Tries to scroll to the first invalid field on submit"
1080
1084
  },
1081
1085
  {
1082
1086
  "name": "show-validation",
1083
- "description": "Returns true if validation errors will be displayed to the user"
1087
+ "description": "Returns true if validation errors will be displayed to the user. @readonly"
1084
1088
  },
1085
1089
  {
1086
1090
  "name": "valid",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanoporetech-digital/components",
3
- "version": "2.12.0",
3
+ "version": "2.13.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://git.oxfordnanolabs.local/Digital/nano-components"
@@ -126,5 +126,5 @@
126
126
  "peerDependencies": {
127
127
  "@stencil/core": "^2.5.0"
128
128
  },
129
- "gitHead": "59dd487ec0208b7265427e8c451c1f2d61f339fa"
129
+ "gitHead": "58854e51957cd823eec733c84789825d596fc6f6"
130
130
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["src/components/input/input.scss?tag=nano-input&encapsulation=scoped","src/components/input/input.tsx"],"names":["inputCss","inputIds","Input","[object Object]","hostRef","this","inputId","didBlurAfterEdit","rtl","charCount","hasRendered","hasFocus","hasLabelSlot","hasHelperSlot","hasHelperEndSlot","errorMessage","datalist","_invalid","autocapitalise","autocomplete","autocorrect","autofocus","clearInput","debounce","disabled","validateOn","showInlineError","hideLabel","floatLabel","name","readonly","required","spellcheck","type","value","resize","rows","showCharCount","validate","ev","nativeInput","validity","valid","preventDefault","validationMessage","nanoValidate","emit","isValid","originalEvent","onInput","input","target","nanoInput","onBlur","focusChanged","nanoBlur","onFocus","nanoFocus","onKeydown","shouldClearOnEdit","hasValue","clearTextInput","stopPropagation","event","window","Event","dispatchEvent","nativeInputWrap","_nativeInputWrap","ele","setDataListOpts","currDWConfig","dropDownConfig","Object","assign","skidding","tetherTo","invalid","validityMessage","requestAnimationFrame","nanoChange","length","style","height","scrollHeight","debounceEvent","validateFirst","Promise","resolve","setTimeout","focus","click","message","setCustomValidity","e","form","document","querySelector","el","closest","kev","raf","key","activeElement","closestElement","tagName","toLowerCase","clearOnEdit","undefined","getValue","mo","disconnect","MutationObserver","processSlottedContent","observe","childList","subtree","querySelectorAll","console","warn","debounceChanged","CustomEvent","detail","slotChangeObserver","_","setFocus","labelId","moreId","helperEndId","ownerDocument","dir","compWrapOptions","label","placeholder","maxlength","wrapOptions","controlId","controlOptions","clearControl","h","Host","aria-disabled","class","createColorClasses","color","has-value","has-focus","is-invalid","FormControlWrap","FormControl","onClearText","control","ref","id","aria-labelledby","accept","autoCapitalize","autoComplete","autoCorrect","autoFocus","inputMode","inputmode","min","max","minLength","minlength","maxLength","multiple","pattern","readOnly","step","size","onChange","onKeyDown","onInvalid","input__native-ctrl","input__resizable"],"mappings":";;;6PAAA,MAAMA,EAAW,g0jBCgCjB,IAAIC,EAAW,MAqBFC,EAAK,MAqBhBC,YAAAC,kSAnBQC,KAAAC,QAAU,cAAcL,MACxBI,KAAAE,iBAAmB,MACnBF,KAAAG,IAAe,MAEfH,KAAAI,UAAY,EACZJ,KAAAK,YAAc,MAkBbL,KA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,kBACzB5B,EAAU,IAAMC,EAAS,IAAMC,EAChDxG,SAAUnB,KAAKmB,SACfoI,eAAgBvJ,KAAKa,eACrB4I,YAAazJ,KAAKe,YAClB2I,UAAW1J,KAAKgB,UAChB2I,UAAW3J,KAAK4J,UAChBlE,KAAM1F,KAAK0F,KACXqE,UAAW/J,KAAKgK,UAChBC,UAAWjK,KAAKiI,UAChBzG,KAAMxB,KAAKwB,KACXwG,YAAahI,KAAKgI,YAClBoC,SAAUpK,KAAKyB,SACfC,SAAU1B,KAAK0B,SACfC,WAAY3B,KAAK2B,WACjBE,MAAOA,EACPe,QAAS5C,KAAK4C,QACd2H,SAAUvK,KAAK4C,QACfO,QAASnD,KAAKmD,QACdqH,UAAWxK,KAAKqD,UAChBoH,UAAWzK,KAAKiC,YAItBqG,EAAA,OAAA","sourcesContent":["@import '../../global/style/utilities/globals';\n@import '../../global/style/nano-theme/form';\n@import '../form-control/form-control';\n@import '../form-control/form-control-vars';\n\n:host {\n @include formControlVars;\n\n position: relative;\n width: 100%;\n padding: 0 !important;\n color: currentColor;\n display: block;\n}\n\n:host(.nano-color) {\n color: current-color(base);\n\n --input-border-style--focus: #{$input-border-style} var(--nano-color-tint, #{nano-color(primary, tint)});\n}\n\n.input__native-ctrl {\n @include text-inherit();\n\n padding-left: unset;\n padding-right: unset;\n padding-top: 0;\n padding-bottom: 0;\n padding-inline-start: var(--padding-start);\n padding-inline-end: var(--padding-end);\n border-radius: var(--input-border-radius);\n text-overflow: ellipsis;\n color: var(--input-text-color);\n display: inline-block;\n flex: 1;\n width: 100%;\n max-width: 100%;\n max-height: 100%;\n border: 0;\n outline: none;\n background: transparent;\n appearance: none;\n margin: 0;\n box-sizing: border-box;\n resize: none;\n overflow: hidden;\n line-height: 2.5em;\n min-height: 2.5em;\n\n .has-float-label & {\n line-height: 2.1em;\n min-height: 2.1em;\n padding-top: 1.4em;\n }\n\n &::placeholder {\n color: var(--placeholder-color);\n font-family: inherit;\n font-style: var(--placeholder-font-style);\n font-weight: var(--placeholder-font-weight);\n opacity: var(--placeholder-opacity);\n line-height: inherit;\n min-height: inherit;\n }\n\n &::-moz-placeholder {\n line-height: 2.8em;\n text-overflow: ellipsis;\n }\n\n &:-webkit-autofill {\n background-color: transparent;\n }\n\n &::-webkit-search-decoration,\n &::-webkit-search-cancel-button,\n &::-webkit-search-results-button,\n &::-webkit-search-results-decoration {\n appearance: none;\n }\n\n &:invalid {\n box-shadow: none;\n }\n\n &::-ms-clear,\n &::-ms-reveal {\n display: none;\n }\n\n &.input__resizable {\n resize: vertical;\n overflow: auto;\n }\n\n .form-ctrl__textarea & {\n line-height: 1.5em;\n padding-top: var(--padding-top);\n padding-bottom: 0.25em;\n white-space: pre-wrap;\n\n &::placeholder {\n line-height: 1.5em;\n }\n\n .has-float-label & {\n padding-top: 1.75em;\n }\n }\n\n :host([readonly]:not([readonly='false'])) & {\n user-select: none;\n }\n}\n","import {\n Build,\n Component,\n ComponentInterface,\n Element,\n Event,\n EventEmitter,\n Host,\n Method,\n Prop,\n State,\n Watch,\n h,\n Listen,\n} from '@stencil/core';\n\nimport {\n Color,\n ControlValidity,\n ControlValidityEventDetail,\n InputChangeEventDetail,\n TextFieldTypes,\n} from '../../interface';\nimport {\n debounceEvent,\n closestElement,\n createColorClasses,\n raf,\n debounce,\n} from '../../utils';\nimport { FormControl, FormControlWrap } from '../form-control/form-control';\n\nlet inputIds = 0;\n\n/**\n * The input component is a wrapper to the HTML input element with custom styling and additional functionality. It accepts most of the same properties as the HTML [input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input), but works great on desktop devices and integrates with the keyboard on mobile devices.\n\nIt is meant for text type inputs only, such as \"text\", \"password\", \"email\", \"number\", \"search\", \"tel\", and \"url\". It supports all standard text input events including keyup, keydown, keypress, and more.\nThe default styling reference comes from the [ONT styleguide](https://nanoporetech.zeroheight.com/styleguide/s/31282/p/230c74-text-input--textarea/b/942ee4)\n * @slot start - suitable for inline action buttons or icons that may add extra contextual information\n * @slot end - suitable for inline action buttons or icons that may add extra contextual information\n * @slot value-start - similar to 'start', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist\n * @slot value-end - similar to 'end', however clicking elements using this slot will activate the input control. This would be suitable to show a secodary 'value' for context or to show a dropdown arrow if using a datalist\n * @slot label - if you do not set a label attribute, you can use this slot for more complex markup\n * @slot helper - helper text to accompany the form field underneath.\n * @slot helper-end - helper text to accompany the form field on the side.\n * @slot - can be used with a `nano-datalist`. See the `nano-datalist` docs for more information\n */\n@Component({\n tag: 'nano-input',\n styleUrl: 'input.scss',\n scoped: true,\n})\nexport class Input implements ComponentInterface {\n private nativeInput?: HTMLInputElement | HTMLTextAreaElement;\n private inputId = `nano-input-${inputIds++}`;\n private didBlurAfterEdit = false;\n private rtl: boolean = false;\n private mo?: MutationObserver;\n private charCount = 0;\n private hasRendered = false;\n\n // we don't want these rendered eles decorated with @State\n // because that will cause re-renders. User get/set to set datalist options\n private _nativeInputWrap: HTMLElement;\n private get nativeInputWrap() {\n return this._nativeInputWrap;\n }\n private set nativeInputWrap(ele: HTMLElement) {\n if (this._nativeInputWrap === ele) return;\n this._nativeInputWrap = ele;\n this.setDataListOpts();\n }\n\n constructor() {\n this.validate = debounce(this.validate, 50);\n }\n\n @State() hasFocus = false;\n @State() hasLabelSlot = false;\n @State() hasHelperSlot = false;\n @State() hasHelperEndSlot = false;\n @State() errorMessage: string = '';\n @State() datalist: HTMLNanoDatalistElement = null;\n\n @Watch('datalist')\n setDataListOpts() {\n if (!this.datalist) return;\n const currDWConfig = this.datalist.dropDownConfig || {};\n this.datalist.dropDownConfig = {\n ...currDWConfig,\n skidding: -1,\n tetherTo: this.nativeInputWrap,\n };\n }\n\n @Element() el!: HTMLNanoInputElement;\n\n /**\n * This will be true when the control is in an invalid state.\n * Validity is determined by the `required` prop. Or if custom validity message is set. @readonly\n */\n @Prop({ reflect: true })\n get invalid() {\n return this._invalid;\n }\n @State() _invalid = false;\n\n /**\n * Current validation message - if any. @readonly\n */\n @Prop()\n get validityMessage() {\n if (!this.nativeInput) return '';\n return this.nativeInput.validationMessage;\n }\n\n /**\n * The color to use from the application's color palette.\n */\n @Prop() color?: Color;\n\n /**\n * If the value of the type attribute is `\"file\"`, then this attribute will indicate the types of files that the server accepts, otherwise it will be ignored. The value must be a comma-separated list of unique content type specifiers.\n */\n @Prop() accept?: string;\n\n /**\n * Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.\n */\n @Prop() autocapitalise: 'none' | 'sentences' | 'words' | 'characters' =\n 'none';\n\n /**\n * Indicates whether the value of the control can be automatically completed by the browser.\n */\n @Prop() autocomplete: 'on' | 'off' = 'off';\n\n /**\n * Whether auto correction should be enabled when the user is entering/editing the text value.\n */\n @Prop() autocorrect: 'on' | 'off' = 'off';\n\n /**\n * This Boolean attribute lets you specify that a form control should have input focus when the page loads.\n */\n @Prop() autofocus = false;\n\n /**\n * If `true`, a clear icon will appear in the input when there is a value. Clicking it clears the input.\n */\n @Prop() clearInput = false;\n\n /**\n * If `true`, the value will be cleared after focus upon edit. Defaults to `true` when `type` is `\"password\"`, `false` for all other types.\n */\n @Prop() clearOnEdit?: boolean;\n\n /**\n * Set the amount of time, in milliseconds, to wait to trigger the `nanoChange` event after each keystroke.\n */\n @Prop() debounce = 0;\n\n /**\n * If `true`, the user cannot interact with the input.\n */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * A hint to the browser for which keyboard to display.\n * Possible values: `\"none\"`, `\"text\"`, `\"tel\"`, `\"url\"`,\n * `\"email\"`, `\"numeric\"`, `\"decimal\"`, and `\"search\"`.\n */\n @Prop() inputmode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search';\n\n /**\n * When should the field perform validation\n */\n @Prop({ mutable: true }) validateOn: 'dirty' | 'submit' | 'submitThenDirty' =\n 'submitThenDirty';\n\n /**\n * Whether to show validation errors underneath input\n */\n @Prop({ reflect: true }) showInlineError = true;\n\n /**\n * String to place within a label element. Alternatively you may use a label slot.\n */\n @Prop() label!: string;\n\n /**\n * Visually hide the label - but make it accessible.\n */\n @Prop() hideLabel?: boolean = false;\n\n /**\n * Enable floating label behaviour. Will disable placeholder if set.\n */\n @Prop() floatLabel: boolean = false;\n\n /**\n * The maximum value, which must not be less than its minimum (min attribute) value.\n */\n @Prop() max?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the maximum number of characters that the user can enter.\n */\n @Prop() maxlength?: number;\n\n /**\n * The minimum value, which must not be greater than its maximum (max attribute) value.\n */\n @Prop() min?: string;\n\n /**\n * If the value of the type attribute is `text`, `email`, `search`, `password`, `tel`, or `url`, this attribute specifies the minimum number of characters that the user can enter.\n */\n @Prop() minlength?: number;\n\n /**\n * If `true`, the user can enter more than one value. This attribute applies when the type attribute is set to `\"email\"` or `\"file\"`, otherwise it is ignored.\n */\n @Prop() multiple?: boolean;\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 * A regular expression that the value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() pattern?: string;\n\n /**\n * Instructional text that shows before the input has a value.\n */\n @Prop() placeholder?: string | null;\n\n /**\n * If `true`, the user cannot modify the value.\n */\n @Prop({ reflect: true }) readonly = false;\n\n /**\n * If `true`, the user must fill in a value before submitting a form.\n */\n @Prop() required = false;\n\n /**\n * If `true`, the element will have its spelling and grammar checked.\n */\n @Prop() spellcheck = false;\n\n /**\n * Works with the min and max attributes to limit the increments at which a value can be set.\n * Possible values are: `\"any\"` or a positive floating point number.\n */\n @Prop() step?: string;\n\n /**\n * The initial size of the control. This value is in pixels unless the value of the type attribute is `\"text\"` or `\"password\"`, in which case it is an integer number of characters. This attribute applies only when the `type` attribute is set to `\"text\"`, `\"search\"`, `\"tel\"`, `\"url\"`, `\"email\"`, or `\"password\"`, otherwise it is ignored.\n */\n @Prop() size?: number;\n\n /**\n * The type of control to display. The default type is text.\n */\n @Prop({ reflect: true }) type: TextFieldTypes = 'text';\n\n /**\n * The form element to associate the input with (its form owner). Must be the id of a form.\n */\n @Prop() form?: string | null;\n\n /**\n * The value of the input.\n */\n @Prop({ mutable: true }) value?: string | null = '';\n\n /**\n * relevant to type=\"textarea\". Vertical resizing - enable / disable or make automatic.\n */\n @Prop() resize: 'true' | 'false' | 'auto' = 'auto';\n\n /**\n * relevant to type=\"textarea\". Default number of rows to show\n */\n @Prop() rows = 2;\n\n /**\n * relevant to type=\"textarea\".\n */\n @Prop() showCharCount = false;\n\n @Watch('minlength')\n @Watch('maxlength')\n @Watch('min')\n @Watch('max')\n @Watch('required')\n @Watch('disabled')\n @Watch('readonly')\n @Watch('pattern')\n @Watch('inputmode')\n protected shouldValidate() {\n if (!this.hasRendered) return;\n requestAnimationFrame(() => {\n if (this.validateOn === 'dirty') this.validate();\n });\n }\n\n /**\n * Update the native input element when the value changes\n */\n @Watch('value')\n protected valueChanged() {\n this.nanoChange.emit({ value: this.value });\n this.charCount = this.value.length;\n\n if (this.type === 'textarea' && this.resize === 'auto') {\n this.nativeInput.style.height = 'auto';\n if (this.value.length)\n this.nativeInput.style.height = this.nativeInput.scrollHeight + 'px';\n }\n\n requestAnimationFrame(() => {\n if (this.validateOn === 'dirty') this.validate();\n });\n }\n\n @Watch('debounce')\n protected debounceChanged() {\n this.nanoChange = debounceEvent(this.nanoChange, this.debounce);\n }\n\n /**\n * Emitted when a keyboard input occurred.\n */\n @Event() nanoInput!: EventEmitter<InputEvent>;\n\n /**\n * Emitted when the value has changed.\n */\n @Event() nanoChange!: EventEmitter<InputChangeEventDetail>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() nanoBlur!: EventEmitter<void>;\n\n /**\n * Emitted when the input has focus.\n */\n @Event() nanoFocus!: EventEmitter<void>;\n\n /**\n * Emitted when the input has been created.\n * @internal\n */\n @Event() nanoDidLoad!: EventEmitter<void>;\n\n /**\n * Emitted when the input has been removed.\n * @internal\n */\n @Event() nanoDidUnload!: EventEmitter<void>;\n\n /**\n * Called when validation is performed (which depends on `validateOn`).\n * @returns event.detail: `{ isValid: boolean, errorMessage: string, originalEvent: Event }`.\n */\n @Event() nanoValidate: EventEmitter<ControlValidityEventDetail>;\n\n /**\n * Get the current state of the control.\n * @param validateFirst - perform validation first before reporting\n * @returns `{ isValid: boolean, errorMessage: string }`\n */\n @Method()\n async reportValidity(validateFirst: boolean): Promise<ControlValidity> {\n return new Promise((resolve) => {\n if (validateFirst) this.validate();\n setTimeout(() => {\n resolve({\n isValid: !this._invalid,\n errorMessage: this.nativeInput.validationMessage,\n });\n }, 50);\n });\n }\n\n /**\n * Sets focus on the specified `nano-input`. Use this method instead of the global\n * `input.focus()`.\n */\n @Method()\n async setFocus() {\n if (this.nativeInput) {\n this.nativeInput.focus();\n this.nativeInput.click();\n }\n }\n\n /**\n * Returns the native `<input>` element used under the hood.\n */\n @Method()\n getInputElement(): Promise<HTMLInputElement | HTMLTextAreaElement> {\n return Promise.resolve(this.nativeInput);\n }\n\n /**\n * Invalidate the field and show a custom error message. To clear the error you will need to re-call this method with an empty string.\n */\n @Method()\n async showError(message: string) {\n if (this.nativeInput) {\n this.nativeInput.setCustomValidity(message);\n this.validate();\n }\n }\n\n @Listen('reset', { target: 'body' })\n onReset(e) {\n const form = this.form\n ? document.querySelector('#' + this.form)\n : this.el.closest('form');\n if (!form || e.target !== this.el.closest('form')) return;\n\n this.value = '';\n }\n\n @Listen('mousedown', { target: 'body' })\n @Listen('keydown')\n handleBlur(e: KeyboardEvent | MouseEvent) {\n if (!this.hasFocus) return;\n\n const kev = e as KeyboardEvent;\n let target: Element;\n\n raf(() => {\n if (kev.key) {\n if (kev.key !== 'Tab') return;\n target = document.activeElement;\n } else target = e.target as Element;\n\n if (closestElement(this.el.tagName.toLowerCase(), target) !== this.el) {\n this.onBlur();\n }\n });\n }\n\n private shouldClearOnEdit() {\n const { type, clearOnEdit } = this;\n return clearOnEdit === undefined ? type === 'password' : clearOnEdit;\n }\n\n private getValue(): string {\n return this.value || '';\n }\n\n private validate = (ev?: Event) => {\n if (this.validateOn === 'submitThenDirty') this.validateOn = 'dirty';\n\n if (!this.nativeInput.validity.valid) {\n if (this.showInlineError) {\n if (ev) ev.preventDefault();\n this.errorMessage = this.nativeInput.validationMessage;\n }\n this._invalid = true;\n } else this._invalid = false;\n\n this.nanoValidate.emit({\n isValid: !this._invalid,\n errorMessage: this.nativeInput.validationMessage,\n originalEvent: ev,\n });\n };\n\n private onInput = (ev: InputEvent) => {\n const input = ev.target as HTMLInputElement | null;\n this.value = input?.value || '';\n this.nanoInput.emit(ev);\n };\n\n private onBlur = () => {\n this.hasFocus = false;\n this.focusChanged();\n if (this.validateOn === 'dirty') this.validate();\n this.nanoBlur.emit();\n };\n\n private onFocus = () => {\n this.hasFocus = true;\n this.focusChanged();\n this.nanoFocus.emit();\n };\n\n private onKeydown = () => {\n if (this.shouldClearOnEdit()) {\n // Did the input value change after it was blurred and edited?\n if (this.didBlurAfterEdit && this.hasValue()) {\n // Clear the input\n this.clearTextInput();\n }\n\n // Reset the flag\n this.didBlurAfterEdit = false;\n }\n };\n\n private clearTextInput = (ev?: Event) => {\n if (this.clearInput && !this.readonly && !this.disabled && ev) {\n ev.preventDefault();\n ev.stopPropagation();\n }\n\n this.value = '';\n this.nativeInput.value = '';\n const event = new window.Event('change');\n this.nativeInput.dispatchEvent(event);\n };\n\n private focusChanged() {\n // If clearOnEdit is enabled and the input blurred but has a value, set a flag\n if (!this.hasFocus && this.shouldClearOnEdit() && this.hasValue()) {\n this.didBlurAfterEdit = true;\n }\n }\n\n private hasValue(): boolean {\n return this.getValue().length > 0;\n }\n\n private slotChangeObserver() {\n if (!Build.isBrowser) return;\n\n if (this.mo) this.mo.disconnect();\n const mo = (this.mo = new MutationObserver(() =>\n this.processSlottedContent()\n ));\n mo.observe(this.el, { childList: true, subtree: true });\n }\n\n private processSlottedContent() {\n // see if we have label / button content\n this.hasLabelSlot = !!this.el.querySelectorAll('[slot=\"label\"]');\n this.hasHelperSlot = !!this.el.querySelector('[slot=\"helper\"]');\n this.hasHelperEndSlot = !!this.el.querySelector('[slot=\"helper-end\"]');\n this.datalist = this.el.querySelector('nano-datalist:not([slot])');\n\n // breaking change introduced in v2. Rm in v3\n if (!!this.el.querySelector('[slot=\"inline-button\"]')) {\n console.warn(\n 'The `inline-button` slot was renamed to `end` in v2 - please update your code',\n this.el\n );\n }\n\n // breaking change introduced in v2. Rm in v3\n if (!!this.el.querySelector('[slot=\"legacy\"]')) {\n console.warn(\n 'The `legacy` slot has been removed. Please update your code',\n this.el\n );\n }\n }\n\n connectedCallback() {\n this.debounceChanged();\n if (Build.isBrowser) {\n this.el.dispatchEvent(\n new CustomEvent('nanoDidLoad', {\n detail: this.el,\n })\n );\n }\n }\n\n disconnectedCallback() {\n if (Build.isBrowser) {\n document.dispatchEvent(\n new CustomEvent('nanoDidUnload', {\n detail: this.el,\n })\n );\n }\n if (this.mo) this.mo.disconnect();\n }\n\n componentDidLoad() {\n this.slotChangeObserver();\n this.hasRendered = true;\n if (this.autofocus) setTimeout((_) => this.setFocus(), 300);\n }\n\n componentWillLoad() {\n this.processSlottedContent();\n }\n\n render() {\n const value = this.getValue();\n const labelId = this.inputId + '-lbl';\n const moreId =\n this.showInlineError || this.hasHelperSlot ? this.inputId + '-more' : '';\n const helperEndId = this.hasHelperEndSlot ? this.inputId + '-helper' : '';\n this.rtl = (this.el.ownerDocument as Document).dir === 'rtl';\n\n const compWrapOptions = (({\n el,\n floatLabel,\n label,\n errorMessage,\n type,\n showInlineError,\n hasHelperSlot,\n hasLabelSlot,\n hideLabel,\n placeholder,\n maxlength,\n charCount,\n showCharCount,\n rtl,\n hasHelperEndSlot,\n }) => ({\n el,\n floatLabel,\n label,\n errorMessage,\n type,\n showInlineError,\n hasHelperSlot,\n hasLabelSlot,\n hideLabel,\n placeholder,\n maxlength,\n charCount,\n showCharCount,\n rtl,\n hasHelperEndSlot,\n }))(this);\n const wrapOptions = {\n ...compWrapOptions,\n labelId,\n moreId,\n helperEndId,\n hasValue: this.hasValue(),\n controlId: this.inputId,\n };\n\n const controlOptions = (({ clearInput, readonly, disabled }) => ({\n clearInput,\n readonly,\n disabled,\n clearControl: this.clearInput,\n }))(this);\n\n return (\n <Host\n aria-disabled={this.disabled ? 'true' : null}\n dir={this.rtl ? 'rtl' : null}\n class={{\n ...createColorClasses(this.color),\n 'has-value': this.hasValue(),\n 'has-focus': this.hasFocus,\n 'is-invalid': this._invalid,\n }}\n >\n <FormControlWrap {...wrapOptions}>\n <FormControl\n {...controlOptions}\n onClearText={this.clearTextInput}\n control={this.el}\n ref={(el) => (this.nativeInputWrap = el)}\n >\n {this.type !== 'textarea' && (\n <input\n id={this.inputId}\n class=\"input__native-ctrl\"\n ref={(input) => (this.nativeInput = input)}\n aria-labelledby={labelId + ' ' + moreId + ' ' + helperEndId}\n disabled={this.disabled}\n accept={this.accept}\n autoCapitalize={this.autocapitalise}\n autoComplete={this.autocomplete}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n form={this.form}\n min={this.min}\n max={this.max}\n minLength={this.minlength}\n maxLength={this.maxlength}\n multiple={this.multiple}\n name={this.name}\n pattern={this.pattern}\n placeholder={this.placeholder}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n step={this.step}\n size={this.size}\n type={this.type}\n value={value}\n onInput={this.onInput}\n onChange={this.onInput}\n onFocus={this.onFocus}\n onKeyDown={this.onKeydown}\n onInvalid={this.validate}\n />\n )}\n {this.type === 'textarea' && (\n <textarea\n rows={this.floatLabel ? 1 : this.rows}\n id={this.inputId}\n class={{\n 'input__native-ctrl': true,\n input__resizable: this.resize === 'true',\n }}\n ref={(input) => (this.nativeInput = input)}\n aria-labelledby={labelId + ' ' + moreId + ' ' + helperEndId}\n disabled={this.disabled}\n autoCapitalize={this.autocapitalise}\n autoCorrect={this.autocorrect}\n autoFocus={this.autofocus}\n inputMode={this.inputmode}\n form={this.form}\n minLength={this.minlength}\n maxLength={this.maxlength}\n name={this.name}\n placeholder={this.placeholder}\n readOnly={this.readonly}\n required={this.required}\n spellcheck={this.spellcheck}\n value={value}\n onInput={this.onInput}\n onChange={this.onInput}\n onFocus={this.onFocus}\n onKeyDown={this.onKeydown}\n onInvalid={this.validate}\n ></textarea>\n )}\n </FormControl>\n <slot />\n </FormControlWrap>\n </Host>\n );\n }\n}\n"]}