@grayscale-dev/dragon 0.1.8 → 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,7 +142,41 @@ 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
 
@@ -152,9 +186,6 @@ dui-input::part(input) {
152
186
  - Example unlimited digits: `\d*`
153
187
  - Example phone validation shape: `^\(\d{3}\)\s\d{3}-\d{4}$`
154
188
  - 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.
158
189
 
159
190
  Example:
160
191
 
@@ -163,7 +194,6 @@ Example:
163
194
  label="Phone"
164
195
  label-position="floating"
165
196
  regex="^\(\d{3}\)\s\d{3}-\d{4}$"
166
- regex-placeholder="(xxx) xxx-xxxx"
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;
@@ -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
21
  private compiledRegex;
20
- private isFocused;
21
22
  constructor();
22
23
  connectedCallback(): void;
23
24
  willUpdate(changed: Map<string, unknown>): void;
@@ -28,12 +29,18 @@ export declare class DuiInput extends LitElement {
28
29
  formStateRestoreCallback(state: unknown): void;
29
30
  formDisabledCallback(disabled: boolean): void;
30
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 {