@grayscale-dev/dragon 0.1.7 → 0.1.9

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,17 +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
+ - Regex masking still applies to what the user types (`value` stays unprefixed/unsuffixed).
153
+
154
+ Example:
155
+
156
+ ```html
157
+ <dui-input label="Amount" prefix="$" regex="^\\d*$"></dui-input>
158
+ <dui-input label="Width" suffix="px" regex="^\\d*$"></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 `regex`, `prefix`, and `suffix`
168
+
169
+ Example:
170
+
171
+ ```html
172
+ <dui-input
173
+ label="Phone"
174
+ template="(xxx) xxx-xxxx"
175
+ regex="^\\d*$"
176
+ ></dui-input>
177
+ ```
178
+
179
+ Typing `8` shows `(8xx) xxx-xxxx`.
146
180
 
147
181
  **Masking**
148
182
 
149
- `regex` enables mask formatting using a supported regex-like pattern.
183
+ `regex` uses the IMask regex engine with full JavaScript `RegExp` syntax.
150
184
 
151
- - Example phone pattern: `^\(\d{3}\)\s\d{3}-\d{4}$`
152
- - As the user types, input is normalized to the mask shape.
153
- - `regex-placeholder` provides explicit placeholder text for regex mode.
154
- - If `regex-placeholder` is empty, no regex placeholder is shown.
155
- - With `label-position="floating"`, regex placeholder appears only while focused.
185
+ - Example single digit: `\d`
186
+ - Example unlimited digits: `\d*`
187
+ - Example phone validation shape: `^\(\d{3}\)\s\d{3}-\d{4}$`
188
+ - As the user types, input is constrained by the regex.
156
189
 
157
190
  Example:
158
191
 
@@ -161,7 +194,6 @@ Example:
161
194
  label="Phone"
162
195
  label-position="floating"
163
196
  regex="^\(\d{3}\)\s\d{3}-\d{4}$"
164
- regex-placeholder="(xxx) xxx-xxxx"
165
197
  ></dui-input>
166
198
  ```
167
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;
@@ -12,12 +15,10 @@ export declare class DuiInput extends LitElement {
12
15
  label: string;
13
16
  labelPosition: 'floating' | 'above';
14
17
  regex: string;
15
- regexPlaceholder: string;
16
18
  private inputEl?;
17
19
  private internals?;
18
20
  private defaultValue?;
19
- private mask;
20
- private isFocused;
21
+ private compiledRegex;
21
22
  constructor();
22
23
  connectedCallback(): void;
23
24
  willUpdate(changed: Map<string, unknown>): void;
@@ -27,13 +28,19 @@ export declare class DuiInput extends LitElement {
27
28
  formResetCallback(): void;
28
29
  formStateRestoreCallback(state: unknown): void;
29
30
  formDisabledCallback(disabled: boolean): void;
30
- private normalizeMaskedValue;
31
+ private normalizeWithRegex;
32
+ private stripAffixes;
33
+ private getTemplateCapacity;
34
+ private capToTemplate;
35
+ private extractTemplateValue;
36
+ private normalizeFromValue;
37
+ private normalizeFromUserInput;
38
+ private applyTemplate;
39
+ private formatDisplayValue;
31
40
  private syncFormValue;
32
41
  private handleInput;
33
42
  private handleChange;
34
43
  private handleKeydown;
35
- private handleFocus;
36
- private handleBlur;
37
44
  render(): import("lit-html").TemplateResult<1>;
38
45
  }
39
46
  declare global {