@grayscale-dev/dragon 0.1.8 → 0.1.10

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/README.md CHANGED
@@ -142,19 +142,50 @@ dui-input::part(input) {
142
142
 
143
143
  - `label-position="above"` (default): label sits above the field.
144
144
  - `label-position="floating"`: label sits like a placeholder and floats to the top-left on focus or when the input has a value.
145
- - Floating mode hides placeholder text to avoid overlap with the label, unless regex placeholder mode is enabled while focused.
145
+ - Floating mode hides placeholder text to avoid overlap with the label.
146
+
147
+ **Affixes**
148
+
149
+ Use `prefix` and `suffix` to show fixed text around the user value.
150
+
151
+ - Affixes are always displayed in the input.
152
+ - Input masking still applies to what the user types (`value` stays unprefixed/unsuffixed).
153
+
154
+ Example:
155
+
156
+ ```html
157
+ <dui-input label="Amount" prefix="$" input-mask="9{1,10}"></dui-input>
158
+ <dui-input label="Width" suffix="px" input-mask="9{1,10}"></dui-input>
159
+ ```
160
+
161
+ **Template Masks**
162
+
163
+ Use `template` to keep literal characters visible while `x` positions are filled by the typed value.
164
+
165
+ - `x` = value slot
166
+ - Non-`x` characters stay visible in the field
167
+ - Works with `input-mask`, `prefix`, and `suffix`
168
+
169
+ Example:
170
+
171
+ ```html
172
+ <dui-input
173
+ label="Phone"
174
+ template="(xxx) xxx-xxxx"
175
+ input-mask="9{1,10}"
176
+ ></dui-input>
177
+ ```
178
+
179
+ Typing `8` shows `(8xx) xxx-xxxx`.
146
180
 
147
181
  **Masking**
148
182
 
149
- `regex` uses the IMask regex engine with full JavaScript `RegExp` syntax.
183
+ `input-mask` uses the Inputmask pattern syntax.
150
184
 
151
- - Example single digit: `\d`
152
- - Example unlimited digits: `\d*`
153
- - Example phone validation shape: `^\(\d{3}\)\s\d{3}-\d{4}$`
154
- - As the user types, input is constrained by the regex.
155
- - `regex-placeholder` provides explicit placeholder text for regex mode.
156
- - If `regex-placeholder` is empty, no regex placeholder is shown.
157
- - With `label-position="floating"`, regex placeholder appears only while focused.
185
+ - Example 4 digits: `9999`
186
+ - Example 1-10 digits: `9{1,10}`
187
+ - Example phone shape: `(999) 999-9999`
188
+ - As the user types, input is constrained by the mask.
158
189
 
159
190
  Example:
160
191
 
@@ -162,8 +193,7 @@ Example:
162
193
  <dui-input
163
194
  label="Phone"
164
195
  label-position="floating"
165
- regex="^\(\d{3}\)\s\d{3}-\d{4}$"
166
- regex-placeholder="(xxx) xxx-xxxx"
196
+ input-mask="(999) 999-9999"
167
197
  ></dui-input>
168
198
  ```
169
199
 
@@ -4,6 +4,9 @@ export declare class DuiInput extends LitElement {
4
4
  static styles: import("lit").CSSResult;
5
5
  value: string;
6
6
  placeholder: string;
7
+ prefix: string;
8
+ suffix: string;
9
+ template: string;
7
10
  name: string;
8
11
  disabled: boolean;
9
12
  required: boolean;
@@ -11,29 +14,31 @@ export declare class DuiInput extends LitElement {
11
14
  autocomplete?: string;
12
15
  label: string;
13
16
  labelPosition: 'floating' | 'above';
14
- regex: string;
15
- regexPlaceholder: string;
17
+ inputMask: string;
16
18
  private inputEl?;
17
19
  private internals?;
18
20
  private defaultValue?;
19
- private compiledRegex;
20
- private isFocused;
21
21
  constructor();
22
22
  connectedCallback(): void;
23
- willUpdate(changed: Map<string, unknown>): void;
24
23
  updated(changed: Map<string, unknown>): void;
25
24
  focus(options?: FocusOptions): void;
26
25
  blur(): void;
27
26
  formResetCallback(): void;
28
27
  formStateRestoreCallback(state: unknown): void;
29
28
  formDisabledCallback(disabled: boolean): void;
30
- private normalizeWithRegex;
29
+ private normalizeWithInputMask;
30
+ private stripAffixes;
31
+ private getTemplateCapacity;
32
+ private capToTemplate;
33
+ private extractTemplateValue;
34
+ private normalizeFromValue;
35
+ private normalizeFromUserInput;
36
+ private applyTemplate;
37
+ private formatDisplayValue;
31
38
  private syncFormValue;
32
39
  private handleInput;
33
40
  private handleChange;
34
41
  private handleKeydown;
35
- private handleFocus;
36
- private handleBlur;
37
42
  render(): import("lit-html").TemplateResult<1>;
38
43
  }
39
44
  declare global {