@quaffui/quaff 1.0.0-alpha2 → 1.0.0-beta12
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 +2 -0
- package/dist/classes/QScrollObserver.svelte.d.ts +4 -4
- package/dist/classes/QScrollObserver.svelte.js +26 -13
- package/dist/components/avatar/QAvatar.svelte +4 -0
- package/dist/components/avatar/QAvatar.svelte.d.ts +4 -14
- package/dist/components/breadcrumbs/QBreadcrumbs.scss +9 -5
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte +46 -16
- package/dist/components/breadcrumbs/QBreadcrumbs.svelte.d.ts +24 -12
- package/dist/components/breadcrumbs/QBreadcrumbsEl.scss +22 -3
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte +50 -38
- package/dist/components/breadcrumbs/QBreadcrumbsEl.svelte.d.ts +4 -14
- package/dist/components/breadcrumbs/props.d.ts +4 -4
- package/dist/components/button/QBtn.scss +3 -1
- package/dist/components/button/QBtn.svelte +38 -22
- package/dist/components/button/QBtn.svelte.d.ts +4 -14
- package/dist/components/button/props.d.ts +9 -2
- package/dist/components/card/QCard.svelte +9 -5
- package/dist/components/card/QCard.svelte.d.ts +4 -14
- package/dist/components/card/QCardActions.svelte +4 -0
- package/dist/components/card/QCardActions.svelte.d.ts +4 -14
- package/dist/components/card/QCardSection.svelte +2 -0
- package/dist/components/card/QCardSection.svelte.d.ts +4 -14
- package/dist/components/checkbox/QCheckbox.svelte +6 -4
- package/dist/components/checkbox/QCheckbox.svelte.d.ts +4 -14
- package/dist/components/checkbox/props.d.ts +1 -1
- package/dist/components/chip/QChip.scss +3 -1
- package/dist/components/chip/QChip.svelte +24 -14
- package/dist/components/chip/QChip.svelte.d.ts +4 -14
- package/dist/components/codeBlock/QCodeBlock.svelte +8 -0
- package/dist/components/codeBlock/QCodeBlock.svelte.d.ts +4 -14
- package/dist/components/dialog/QDialog.scss +17 -0
- package/dist/components/dialog/QDialog.svelte +34 -9
- package/dist/components/dialog/QDialog.svelte.d.ts +8 -21
- package/dist/components/drawer/QDrawer.scss +2 -2
- package/dist/components/drawer/QDrawer.svelte +124 -69
- package/dist/components/drawer/QDrawer.svelte.d.ts +8 -21
- package/dist/components/drawer/props.d.ts +3 -3
- package/dist/components/expansion-item/QExpansionItem.scss +59 -0
- package/dist/components/expansion-item/QExpansionItem.svelte +319 -0
- package/dist/components/expansion-item/QExpansionItem.svelte.d.ts +8 -0
- package/dist/components/expansion-item/docs.d.ts +2 -0
- package/dist/components/expansion-item/docs.js +17 -0
- package/dist/components/expansion-item/props.d.ts +129 -0
- package/dist/components/expansion-item/props.js +1 -0
- package/dist/components/footer/QFooter.scss +1 -1
- package/dist/components/footer/QFooter.svelte +32 -28
- package/dist/components/footer/QFooter.svelte.d.ts +4 -14
- package/dist/components/header/QHeader.scss +1 -1
- package/dist/components/header/QHeader.svelte +41 -33
- package/dist/components/header/QHeader.svelte.d.ts +4 -14
- package/dist/components/icon/QIcon.svelte +6 -4
- package/dist/components/icon/QIcon.svelte.d.ts +4 -14
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/input/QInput.svelte +139 -17
- package/dist/components/input/QInput.svelte.d.ts +4 -14
- package/dist/components/input/docs.js +2 -2
- package/dist/components/input/mask.d.ts +10 -0
- package/dist/components/input/mask.js +204 -0
- package/dist/components/input/props.d.ts +37 -4
- package/dist/components/layout/QLayout.svelte +248 -93
- package/dist/components/layout/QLayout.svelte.d.ts +67 -15
- package/dist/components/layout/props.d.ts +1 -1
- package/dist/components/list/QItem.scss +7 -4
- package/dist/components/list/QItem.svelte +44 -24
- package/dist/components/list/QItem.svelte.d.ts +17 -13
- package/dist/components/list/QItemSection.scss +24 -3
- package/dist/components/list/QItemSection.svelte +19 -21
- package/dist/components/list/QItemSection.svelte.d.ts +4 -14
- package/dist/components/list/QList.scss +17 -4
- package/dist/components/list/QList.svelte +30 -8
- package/dist/components/list/QList.svelte.d.ts +17 -13
- package/dist/components/list/props.d.ts +3 -3
- package/dist/components/menu/QMenu.scss +37 -0
- package/dist/components/menu/QMenu.svelte +314 -0
- package/dist/components/menu/QMenu.svelte.d.ts +8 -0
- package/dist/components/menu/docs.d.ts +2 -0
- package/dist/components/menu/docs.js +27 -0
- package/dist/components/menu/props.d.ts +48 -0
- package/dist/components/menu/props.js +1 -0
- package/dist/components/progress/QCircularProgress.svelte +17 -14
- package/dist/components/progress/QCircularProgress.svelte.d.ts +4 -14
- package/dist/components/progress/QLinearProgress.svelte +15 -15
- package/dist/components/progress/QLinearProgress.svelte.d.ts +4 -14
- package/dist/components/radio/QRadio.svelte +6 -4
- package/dist/components/radio/QRadio.svelte.d.ts +4 -14
- package/dist/components/radio/props.d.ts +1 -1
- package/dist/components/railbar/QRailbar.scss +1 -1
- package/dist/components/railbar/QRailbar.svelte +36 -35
- package/dist/components/railbar/QRailbar.svelte.d.ts +4 -14
- package/dist/components/select/QSelect.svelte +316 -102
- package/dist/components/select/QSelect.svelte.d.ts +4 -14
- package/dist/components/select/filter.d.ts +13 -0
- package/dist/components/select/filter.js +73 -0
- package/dist/components/select/index.scss +28 -27
- package/dist/components/select/option.d.ts +9 -0
- package/dist/components/select/option.js +59 -0
- package/dist/components/select/props.d.ts +40 -7
- package/dist/components/separator/QSeparator.scss +2 -0
- package/dist/components/separator/QSeparator.svelte +9 -8
- package/dist/components/separator/QSeparator.svelte.d.ts +4 -14
- package/dist/components/switch/QSwitch.scss +12 -6
- package/dist/components/switch/QSwitch.svelte +7 -1
- package/dist/components/switch/QSwitch.svelte.d.ts +4 -14
- package/dist/components/table/QTable.svelte +31 -19
- package/dist/components/table/QTable.svelte.d.ts +4 -14
- package/dist/components/table/index.scss +1 -1
- package/dist/components/tabs/QTab.scss +2 -0
- package/dist/components/tabs/QTab.svelte +19 -22
- package/dist/components/tabs/QTab.svelte.d.ts +4 -14
- package/dist/components/tabs/QTabs.svelte +59 -32
- package/dist/components/tabs/QTabs.svelte.d.ts +18 -18
- package/dist/components/toolbar/QToolbar.svelte +2 -0
- package/dist/components/toolbar/QToolbar.svelte.d.ts +4 -14
- package/dist/components/toolbar/QToolbarTitle.svelte +2 -0
- package/dist/components/toolbar/QToolbarTitle.svelte.d.ts +4 -14
- package/dist/components/tooltip/QTooltip.svelte +48 -38
- package/dist/components/tooltip/QTooltip.svelte.d.ts +29 -17
- package/dist/components/tooltip/QTooltipBase.svelte +18 -8
- package/dist/components/tooltip/QTooltipBase.svelte.d.ts +4 -14
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.js +2 -0
- package/dist/composables/useColor.d.ts +1 -0
- package/dist/composables/useColor.js +19 -0
- package/dist/composables/useRevealScrollObserver.svelte.d.ts +9 -0
- package/dist/composables/useRevealScrollObserver.svelte.js +25 -0
- package/dist/composables/useRouterLink.d.ts +3 -2
- package/dist/composables/useRouterLink.js +2 -2
- package/dist/css/_components.scss +2 -0
- package/dist/css/classes/_grid.scss +12 -1
- package/dist/css/index.css +1 -1
- package/dist/css/mixins/_design.scss +1 -1
- package/dist/css/mixins/_field.scss +3 -2
- package/dist/css/mixins/_table.scss +1 -1
- package/dist/css/mixins/_toolbar.scss +1 -1
- package/dist/css/shared/q-field.scss +7 -6
- package/dist/css/theme/_page.scss +8 -6
- package/dist/css/theme/_reset.scss +2 -1
- package/dist/helpers/clickOutside.js +5 -4
- package/dist/helpers/ripple.js +5 -6
- package/dist/helpers/version.d.ts +1 -1
- package/dist/helpers/version.js +1 -1
- package/dist/{components/private/ContextReseter.svelte → internal/ContextResetter.svelte} +2 -3
- package/dist/internal/ContextResetter.svelte.d.ts +8 -0
- package/dist/{components/private → internal}/QIconSnippet.svelte +2 -2
- package/dist/internal/QIconSnippet.svelte.d.ts +10 -0
- package/dist/utils/context.d.ts +49 -32
- package/dist/utils/context.js +82 -33
- package/dist/utils/dom.d.ts +6 -0
- package/dist/utils/dom.js +33 -0
- package/dist/utils/events.d.ts +0 -24
- package/dist/utils/events.js +0 -24
- package/package.json +44 -38
- package/dist/classes/QContext.svelte.d.ts +0 -42
- package/dist/classes/QContext.svelte.js +0 -63
- package/dist/components/avatar/docs.props.d.ts +0 -3
- package/dist/components/avatar/docs.props.js +0 -87
- package/dist/components/breadcrumbs/docs.props.d.ts +0 -5
- package/dist/components/breadcrumbs/docs.props.js +0 -144
- package/dist/components/button/docs.props.d.ts +0 -3
- package/dist/components/button/docs.props.js +0 -227
- package/dist/components/card/docs.props.d.ts +0 -7
- package/dist/components/card/docs.props.js +0 -89
- package/dist/components/checkbox/docs.props.d.ts +0 -3
- package/dist/components/checkbox/docs.props.js +0 -41
- package/dist/components/chip/docs.props.d.ts +0 -3
- package/dist/components/chip/docs.props.js +0 -137
- package/dist/components/codeBlock/docs.props.d.ts +0 -3
- package/dist/components/codeBlock/docs.props.js +0 -83
- package/dist/components/dialog/docs.props.d.ts +0 -3
- package/dist/components/dialog/docs.props.js +0 -65
- package/dist/components/drawer/docs.props.d.ts +0 -3
- package/dist/components/drawer/docs.props.js +0 -149
- package/dist/components/footer/docs.props.d.ts +0 -3
- package/dist/components/footer/docs.props.js +0 -65
- package/dist/components/header/docs.props.d.ts +0 -7
- package/dist/components/header/docs.props.js +0 -131
- package/dist/components/icon/docs.props.d.ts +0 -3
- package/dist/components/icon/docs.props.js +0 -107
- package/dist/components/input/docs.props.d.ts +0 -3
- package/dist/components/input/docs.props.js +0 -162
- package/dist/components/layout/docs.props.d.ts +0 -3
- package/dist/components/layout/docs.props.js +0 -81
- package/dist/components/list/docs.props.d.ts +0 -11
- package/dist/components/list/docs.props.js +0 -434
- package/dist/components/private/ContextReseter.svelte.d.ts +0 -14
- package/dist/components/private/QApi.svelte +0 -296
- package/dist/components/private/QApi.svelte.d.ts +0 -14
- package/dist/components/private/QDocs.svelte +0 -155
- package/dist/components/private/QDocs.svelte.d.ts +0 -14
- package/dist/components/private/QDocsSection.svelte +0 -62
- package/dist/components/private/QDocsSection.svelte.d.ts +0 -14
- package/dist/components/private/QIconSnippet.svelte.d.ts +0 -14
- package/dist/components/private/index.d.ts +0 -6
- package/dist/components/private/index.js +0 -6
- package/dist/components/progress/docs.props.d.ts +0 -5
- package/dist/components/progress/docs.props.js +0 -314
- package/dist/components/radio/docs.props.d.ts +0 -3
- package/dist/components/radio/docs.props.js +0 -53
- package/dist/components/railbar/docs.props.d.ts +0 -3
- package/dist/components/railbar/docs.props.js +0 -47
- package/dist/components/select/docs.props.d.ts +0 -3
- package/dist/components/select/docs.props.js +0 -198
- package/dist/components/separator/docs.props.d.ts +0 -5
- package/dist/components/separator/docs.props.js +0 -196
- package/dist/components/switch/docs.props.d.ts +0 -3
- package/dist/components/switch/docs.props.js +0 -119
- package/dist/components/table/docs.props.d.ts +0 -3
- package/dist/components/table/docs.props.js +0 -94
- package/dist/components/tabs/docs.props.d.ts +0 -5
- package/dist/components/tabs/docs.props.js +0 -86
- package/dist/components/toolbar/docs.props.d.ts +0 -5
- package/dist/components/toolbar/docs.props.js +0 -68
- package/dist/components/tooltip/docs.props.d.ts +0 -3
- package/dist/components/tooltip/docs.props.js +0 -77
- package/dist/utils/types.json +0 -31
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
const NAMED_MASKS = {
|
|
2
|
+
date: "####/##/##",
|
|
3
|
+
datetime: "####/##/## ##:##",
|
|
4
|
+
time: "##:##",
|
|
5
|
+
fulltime: "##:##:##",
|
|
6
|
+
phone: "(###) ### - ####",
|
|
7
|
+
card: "#### #### #### ####",
|
|
8
|
+
};
|
|
9
|
+
const TOKENS = {
|
|
10
|
+
"#": { regex: /\d/ },
|
|
11
|
+
S: { regex: /[a-zA-Z]/ },
|
|
12
|
+
N: { regex: /[0-9a-zA-Z]/ },
|
|
13
|
+
A: { regex: /[a-zA-Z]/, transform: (value) => value.toLocaleUpperCase() },
|
|
14
|
+
a: { regex: /[a-zA-Z]/, transform: (value) => value.toLocaleLowerCase() },
|
|
15
|
+
X: { regex: /[0-9a-zA-Z]/, transform: (value) => value.toLocaleUpperCase() },
|
|
16
|
+
x: { regex: /[0-9a-zA-Z]/, transform: (value) => value.toLocaleLowerCase() },
|
|
17
|
+
};
|
|
18
|
+
function normalizeMask(mask) {
|
|
19
|
+
return NAMED_MASKS[mask] ?? mask;
|
|
20
|
+
}
|
|
21
|
+
function tokenFor(maskChar) {
|
|
22
|
+
return TOKENS[maskChar];
|
|
23
|
+
}
|
|
24
|
+
function fillEnabled(fillMask) {
|
|
25
|
+
return fillMask !== undefined && fillMask !== false;
|
|
26
|
+
}
|
|
27
|
+
function fillChar(fillMask) {
|
|
28
|
+
return typeof fillMask === "string" && fillMask.length > 0 ? fillMask[0] : "_";
|
|
29
|
+
}
|
|
30
|
+
function applyToken(token, value) {
|
|
31
|
+
return token.transform ? token.transform(value) : value;
|
|
32
|
+
}
|
|
33
|
+
function readMaskedToken(value, start, token, fillMask) {
|
|
34
|
+
const placeholder = fillChar(fillMask);
|
|
35
|
+
const fill = fillEnabled(fillMask);
|
|
36
|
+
for (let index = start; index < value.length; index += 1) {
|
|
37
|
+
const char = value[index];
|
|
38
|
+
if (fill && char === placeholder) {
|
|
39
|
+
return { value: "", next: index + 1 };
|
|
40
|
+
}
|
|
41
|
+
if (token.regex.test(char)) {
|
|
42
|
+
return { value: applyToken(token, char), next: index + 1 };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { value: "", next: value.length };
|
|
46
|
+
}
|
|
47
|
+
function readRawToken(raw, start, token) {
|
|
48
|
+
for (let index = start; index < raw.length; index += 1) {
|
|
49
|
+
const char = raw[index];
|
|
50
|
+
if (token.regex.test(char)) {
|
|
51
|
+
return { value: applyToken(token, char), next: index + 1 };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { value: "", next: raw.length };
|
|
55
|
+
}
|
|
56
|
+
function tokenPositions(normalizedMask) {
|
|
57
|
+
const positions = [];
|
|
58
|
+
for (let index = 0; index < normalizedMask.length; index += 1) {
|
|
59
|
+
if (tokenFor(normalizedMask[index])) {
|
|
60
|
+
positions.push(index);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return positions;
|
|
64
|
+
}
|
|
65
|
+
function isMaskLikeValue(value, normalizedMask) {
|
|
66
|
+
for (let index = 0; index < normalizedMask.length; index += 1) {
|
|
67
|
+
const maskChar = normalizedMask[index];
|
|
68
|
+
if (!tokenFor(maskChar) && value[index] === maskChar) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
function normalizeFilledValue(value, normalizedMask, fillMask) {
|
|
75
|
+
const placeholder = fillChar(fillMask);
|
|
76
|
+
const overflow = value.slice(normalizedMask.length);
|
|
77
|
+
let overflowIndex = 0;
|
|
78
|
+
let result = "";
|
|
79
|
+
for (let index = 0; index < normalizedMask.length; index += 1) {
|
|
80
|
+
const maskChar = normalizedMask[index];
|
|
81
|
+
const token = tokenFor(maskChar);
|
|
82
|
+
const valueChar = value[index];
|
|
83
|
+
if (!token) {
|
|
84
|
+
result += maskChar;
|
|
85
|
+
}
|
|
86
|
+
else if (valueChar === placeholder) {
|
|
87
|
+
const next = readRawToken(overflow, overflowIndex, token);
|
|
88
|
+
overflowIndex = next.next;
|
|
89
|
+
result += next.value || placeholder;
|
|
90
|
+
}
|
|
91
|
+
else if (valueChar && token.regex.test(valueChar)) {
|
|
92
|
+
result += applyToken(token, valueChar);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const next = readRawToken(overflow, overflowIndex, token);
|
|
96
|
+
overflowIndex = next.next;
|
|
97
|
+
result += next.value || placeholder;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
function deleteTokenIndex(caret, positions, direction) {
|
|
103
|
+
if (direction === "backward") {
|
|
104
|
+
for (let index = positions.length - 1; index >= 0; index -= 1) {
|
|
105
|
+
if (positions[index] < caret) {
|
|
106
|
+
return index;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return -1;
|
|
110
|
+
}
|
|
111
|
+
for (let index = 0; index < positions.length; index += 1) {
|
|
112
|
+
if (positions[index] >= caret) {
|
|
113
|
+
return index;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return -1;
|
|
117
|
+
}
|
|
118
|
+
export function unmaskValue(value, mask, fillMask) {
|
|
119
|
+
const normalizedMask = normalizeMask(mask);
|
|
120
|
+
let result = "";
|
|
121
|
+
let valueIndex = 0;
|
|
122
|
+
for (const maskChar of normalizedMask) {
|
|
123
|
+
const token = tokenFor(maskChar);
|
|
124
|
+
if (!token) {
|
|
125
|
+
valueIndex += value[valueIndex] === maskChar ? 1 : 0;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const next = readMaskedToken(value, valueIndex, token, fillMask);
|
|
129
|
+
result += next.value;
|
|
130
|
+
valueIndex = next.next;
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
export function maskValue(value, mask, fillMask) {
|
|
135
|
+
const normalizedMask = normalizeMask(mask);
|
|
136
|
+
const fill = fillEnabled(fillMask);
|
|
137
|
+
const placeholder = fillChar(fillMask);
|
|
138
|
+
if (fill && isMaskLikeValue(value, normalizedMask)) {
|
|
139
|
+
return normalizeFilledValue(value, normalizedMask, fillMask);
|
|
140
|
+
}
|
|
141
|
+
const raw = unmaskValue(value, normalizedMask, fillMask);
|
|
142
|
+
let result = "";
|
|
143
|
+
let rawIndex = 0;
|
|
144
|
+
let hasValue = false;
|
|
145
|
+
for (const maskChar of normalizedMask) {
|
|
146
|
+
const token = tokenFor(maskChar);
|
|
147
|
+
if (!token) {
|
|
148
|
+
result += fill || hasValue || rawIndex < raw.length ? maskChar : "";
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const next = readRawToken(raw, rawIndex, token);
|
|
152
|
+
rawIndex = next.next;
|
|
153
|
+
if (next.value) {
|
|
154
|
+
result += next.value;
|
|
155
|
+
hasValue = true;
|
|
156
|
+
}
|
|
157
|
+
else if (fill) {
|
|
158
|
+
result += placeholder;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
export function maskCaretPosition(tokenCount, mask, displayLength) {
|
|
167
|
+
const positions = tokenPositions(normalizeMask(mask));
|
|
168
|
+
if (tokenCount <= 0) {
|
|
169
|
+
return positions[0] ?? 0;
|
|
170
|
+
}
|
|
171
|
+
return Math.min(positions[tokenCount] ?? displayLength, displayLength);
|
|
172
|
+
}
|
|
173
|
+
export function deleteMaskedToken(value, mask, caret, direction, fillMask) {
|
|
174
|
+
const normalizedMask = normalizeMask(mask);
|
|
175
|
+
const positions = tokenPositions(normalizedMask);
|
|
176
|
+
const tokenIndex = deleteTokenIndex(caret, positions, direction);
|
|
177
|
+
if (tokenIndex < 0) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
if (fillEnabled(fillMask)) {
|
|
181
|
+
const masked = maskValue(value, normalizedMask, fillMask);
|
|
182
|
+
const position = positions[tokenIndex];
|
|
183
|
+
if (position === undefined || masked[position] === fillChar(fillMask)) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const nextMasked = `${masked.slice(0, position)}${fillChar(fillMask)}${masked.slice(position + 1)}`;
|
|
187
|
+
return {
|
|
188
|
+
masked: nextMasked,
|
|
189
|
+
unmasked: unmaskValue(nextMasked, normalizedMask, fillMask),
|
|
190
|
+
caret: position,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const raw = unmaskValue(value, normalizedMask, fillMask);
|
|
194
|
+
if (tokenIndex >= raw.length) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const unmasked = `${raw.slice(0, tokenIndex)}${raw.slice(tokenIndex + 1)}`;
|
|
198
|
+
const masked = maskValue(unmasked, normalizedMask, fillMask);
|
|
199
|
+
return {
|
|
200
|
+
masked,
|
|
201
|
+
unmasked,
|
|
202
|
+
caret: maskCaretPosition(tokenIndex, normalizedMask, masked.length),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { NativeProps } from "../../utils";
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
-
|
|
3
|
+
import type { HTMLAttributes, HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
import type { QInputFillMask } from "./mask";
|
|
5
|
+
type QInputNativeAttributes = Omit<HTMLInputAttributes, "class" | "style" | "value" | "disabled">;
|
|
6
|
+
export interface QInputProps extends NativeProps, QInputNativeAttributes {
|
|
5
7
|
/**
|
|
6
8
|
* Makes the input component more compact.
|
|
7
9
|
*
|
|
@@ -13,7 +15,7 @@ export interface QInputProps extends NativeProps, HTMLAttributes<HTMLDivElement>
|
|
|
13
15
|
*
|
|
14
16
|
* @default false
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
disabled?: boolean;
|
|
17
19
|
/**
|
|
18
20
|
* Indicates an error state for the input.
|
|
19
21
|
*
|
|
@@ -56,10 +58,40 @@ export interface QInputProps extends NativeProps, HTMLAttributes<HTMLDivElement>
|
|
|
56
58
|
* @default false
|
|
57
59
|
*/
|
|
58
60
|
rounded?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Applies a mask to text input. Supports tokens (#, S, N, A, a, X, x) and named masks: date, datetime, time, fulltime, phone, card.
|
|
63
|
+
*
|
|
64
|
+
* @default undefined
|
|
65
|
+
*/
|
|
66
|
+
mask?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Fills empty mask token positions with underscores, or with the first character of the provided string.
|
|
69
|
+
*
|
|
70
|
+
* @default undefined
|
|
71
|
+
*/
|
|
72
|
+
fillMask?: QInputFillMask;
|
|
73
|
+
/**
|
|
74
|
+
* Stores only mask token characters in the bindable value.
|
|
75
|
+
*
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
unmaskedValue?: boolean;
|
|
59
79
|
/**
|
|
60
80
|
* Current value of the input field. This property is bindable.
|
|
61
81
|
*/
|
|
62
|
-
value: string;
|
|
82
|
+
value: string | number;
|
|
83
|
+
/**
|
|
84
|
+
* Classes applied to the field wrapper.
|
|
85
|
+
*
|
|
86
|
+
* @default undefined
|
|
87
|
+
*/
|
|
88
|
+
class?: HTMLAttributes<HTMLDivElement>["class"];
|
|
89
|
+
/**
|
|
90
|
+
* Styles applied to the field wrapper.
|
|
91
|
+
*
|
|
92
|
+
* @default undefined
|
|
93
|
+
*/
|
|
94
|
+
style?: HTMLAttributes<HTMLDivElement>["style"];
|
|
63
95
|
/**
|
|
64
96
|
* Content to be placed before the input wrapper element, usually an icon.
|
|
65
97
|
*
|
|
@@ -85,3 +117,4 @@ export interface QInputProps extends NativeProps, HTMLAttributes<HTMLDivElement>
|
|
|
85
117
|
*/
|
|
86
118
|
after?: Snippet;
|
|
87
119
|
}
|
|
120
|
+
export {};
|
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import { onMount
|
|
3
|
-
import { QContext } from "../../
|
|
4
|
-
import
|
|
5
|
-
import { QLayoutCtxName } from "../../utils";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import { QContext } from "../../utils";
|
|
4
|
+
import ContextResetter from "../../internal/ContextResetter.svelte";
|
|
6
5
|
import type { QLayoutProps } from "./props";
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
interface AppbarContext {
|
|
8
|
+
readonly view: string;
|
|
9
9
|
height: number;
|
|
10
10
|
collapsed: boolean;
|
|
11
11
|
ready: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
interface DrawerContext {
|
|
15
|
+
readonly view: string;
|
|
15
16
|
width: number;
|
|
16
17
|
takesSpace: boolean;
|
|
17
18
|
ready: boolean;
|
|
18
19
|
}
|
|
20
|
+
|
|
21
|
+
export const headerCtx = QContext<AppbarContext>("QHeader");
|
|
22
|
+
export const footerCtx = QContext<AppbarContext>("QFooter");
|
|
23
|
+
|
|
24
|
+
export const leftRailbarCtx = QContext<DrawerContext>("QRailbarLeft");
|
|
25
|
+
export const rightRailbarCtx = QContext<DrawerContext>("QRailbarRight");
|
|
26
|
+
export const leftDrawerCtx = QContext<DrawerContext>("QDrawerLeft");
|
|
27
|
+
export const rightDrawerCtx = QContext<DrawerContext>("QDrawerRight");
|
|
19
28
|
</script>
|
|
20
29
|
|
|
21
30
|
<script lang="ts">
|
|
31
|
+
// #region: --- Props
|
|
22
32
|
let {
|
|
23
33
|
view = "hhh lpr fff",
|
|
24
34
|
content,
|
|
@@ -33,81 +43,56 @@
|
|
|
33
43
|
children,
|
|
34
44
|
...props
|
|
35
45
|
}: QLayoutProps = $props();
|
|
46
|
+
// #endregion: --- Props
|
|
36
47
|
|
|
48
|
+
// #region: --- Reactive variables
|
|
37
49
|
let layoutEl = $state<HTMLDivElement>();
|
|
38
50
|
let contentEl = $state<HTMLDivElement>();
|
|
39
51
|
|
|
40
|
-
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
if (contentEl) {
|
|
43
|
-
contentEl.style.transition = "margin 0.3s";
|
|
44
|
-
}
|
|
45
|
-
}, 100);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
setContext(QLayoutCtxName.view, {
|
|
49
|
-
get value() {
|
|
50
|
-
return view;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const headerCtx = new QContext<AppbarContext>(QLayoutCtxName.header, {
|
|
52
|
+
const headerInfo = $state({
|
|
55
53
|
height: 0,
|
|
56
54
|
collapsed: false,
|
|
57
55
|
ready: false,
|
|
58
56
|
});
|
|
59
|
-
|
|
60
|
-
const footerCtx = new QContext<AppbarContext>(QLayoutCtxName.footer, {
|
|
57
|
+
const footerInfo = $state({
|
|
61
58
|
height: 0,
|
|
62
59
|
collapsed: false,
|
|
63
60
|
ready: false,
|
|
64
61
|
});
|
|
62
|
+
const leftRailbarInfo = $state({
|
|
63
|
+
width: 0,
|
|
64
|
+
takesSpace: false,
|
|
65
|
+
ready: false,
|
|
66
|
+
});
|
|
67
|
+
const rightRailbarInfo = $state({
|
|
68
|
+
width: 0,
|
|
69
|
+
takesSpace: false,
|
|
70
|
+
ready: false,
|
|
71
|
+
});
|
|
72
|
+
const leftDrawerInfo = $state({
|
|
73
|
+
width: 0,
|
|
74
|
+
takesSpace: false,
|
|
75
|
+
ready: false,
|
|
76
|
+
});
|
|
77
|
+
const rightDrawerInfo = $state({
|
|
78
|
+
width: 0,
|
|
79
|
+
takesSpace: false,
|
|
80
|
+
ready: false,
|
|
81
|
+
});
|
|
82
|
+
// #endregion: --- Reactive variables
|
|
65
83
|
|
|
66
|
-
|
|
67
|
-
QLayoutCtxName.railbar.left,
|
|
68
|
-
{
|
|
69
|
-
width: 0,
|
|
70
|
-
takesSpace: false,
|
|
71
|
-
ready: false,
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
const rightRailbarCtx = new QContext<DrawerContext>(
|
|
75
|
-
QLayoutCtxName.railbar.right,
|
|
76
|
-
{
|
|
77
|
-
width: 0,
|
|
78
|
-
takesSpace: false,
|
|
79
|
-
ready: false,
|
|
80
|
-
},
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const leftDrawerCtx = new QContext<DrawerContext>(
|
|
84
|
-
QLayoutCtxName.drawer.left,
|
|
85
|
-
{
|
|
86
|
-
width: 0,
|
|
87
|
-
takesSpace: false,
|
|
88
|
-
ready: false,
|
|
89
|
-
},
|
|
90
|
-
);
|
|
91
|
-
const rightDrawerCtx = new QContext<DrawerContext>(
|
|
92
|
-
QLayoutCtxName.drawer.right,
|
|
93
|
-
{
|
|
94
|
-
width: 360,
|
|
95
|
-
takesSpace: false,
|
|
96
|
-
ready: false,
|
|
97
|
-
},
|
|
98
|
-
);
|
|
99
|
-
|
|
84
|
+
// #region: --- Derived values
|
|
100
85
|
const topOffset = $derived(
|
|
101
|
-
!header ||
|
|
86
|
+
!header || headerInfo.collapsed ? 0 : headerInfo.height,
|
|
102
87
|
);
|
|
103
88
|
const bottomOffset = $derived(
|
|
104
|
-
!footer ||
|
|
89
|
+
!footer || footerInfo.collapsed ? 0 : footerInfo.height,
|
|
105
90
|
);
|
|
106
91
|
const leftOffset = $derived(
|
|
107
|
-
handleDrawerCtx(
|
|
92
|
+
handleDrawerCtx(leftRailbarInfo) + handleDrawerCtx(leftDrawerInfo),
|
|
108
93
|
);
|
|
109
94
|
const rightOffset = $derived(
|
|
110
|
-
handleDrawerCtx(
|
|
95
|
+
handleDrawerCtx(rightRailbarInfo) + handleDrawerCtx(rightDrawerInfo),
|
|
111
96
|
);
|
|
112
97
|
|
|
113
98
|
const contentMargin = $derived(
|
|
@@ -115,39 +100,209 @@
|
|
|
115
100
|
);
|
|
116
101
|
|
|
117
102
|
const isReady = $derived(
|
|
118
|
-
(
|
|
119
|
-
|
|
120
|
-
(
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
(!railbarLeft ||
|
|
125
|
-
leftRailbarCtx.value.ready ||
|
|
126
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-railbar--left"))) &&
|
|
127
|
-
(!railbarRight ||
|
|
128
|
-
rightRailbarCtx.value.ready ||
|
|
129
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-railbar--right"))) &&
|
|
130
|
-
(!drawerLeft ||
|
|
131
|
-
leftDrawerCtx.value.ready ||
|
|
132
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-drawer--left"))) &&
|
|
133
|
-
(!drawerRight ||
|
|
134
|
-
rightDrawerCtx.value.ready ||
|
|
135
|
-
(layoutEl && !layoutEl.querySelector(":scope > .q-drawer--right"))),
|
|
103
|
+
appBarReady("header") &&
|
|
104
|
+
appBarReady("footer") &&
|
|
105
|
+
sideBarReady("railbar", "left") &&
|
|
106
|
+
sideBarReady("railbar", "right") &&
|
|
107
|
+
sideBarReady("drawer", "left") &&
|
|
108
|
+
sideBarReady("drawer", "right"),
|
|
136
109
|
);
|
|
110
|
+
// #endregion: --- Derived values
|
|
111
|
+
|
|
112
|
+
// #region: --- Context
|
|
113
|
+
headerCtx.set({
|
|
114
|
+
get view() {
|
|
115
|
+
return view;
|
|
116
|
+
},
|
|
117
|
+
get height() {
|
|
118
|
+
return headerInfo.height;
|
|
119
|
+
},
|
|
120
|
+
set height(newValue) {
|
|
121
|
+
headerInfo.height = newValue;
|
|
122
|
+
},
|
|
123
|
+
get collapsed() {
|
|
124
|
+
return headerInfo.collapsed;
|
|
125
|
+
},
|
|
126
|
+
set collapsed(newValue) {
|
|
127
|
+
headerInfo.collapsed = newValue;
|
|
128
|
+
},
|
|
129
|
+
get ready() {
|
|
130
|
+
return headerInfo.ready;
|
|
131
|
+
},
|
|
132
|
+
set ready(newValue) {
|
|
133
|
+
headerInfo.ready = newValue;
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
footerCtx.set({
|
|
137
|
+
get view() {
|
|
138
|
+
return view;
|
|
139
|
+
},
|
|
140
|
+
get height() {
|
|
141
|
+
return footerInfo.height;
|
|
142
|
+
},
|
|
143
|
+
set height(newValue) {
|
|
144
|
+
footerInfo.height = newValue;
|
|
145
|
+
},
|
|
146
|
+
get collapsed() {
|
|
147
|
+
return footerInfo.collapsed;
|
|
148
|
+
},
|
|
149
|
+
set collapsed(newValue) {
|
|
150
|
+
footerInfo.collapsed = newValue;
|
|
151
|
+
},
|
|
152
|
+
get ready() {
|
|
153
|
+
return footerInfo.ready;
|
|
154
|
+
},
|
|
155
|
+
set ready(newValue) {
|
|
156
|
+
footerInfo.ready = newValue;
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
leftRailbarCtx.set({
|
|
161
|
+
get view() {
|
|
162
|
+
return view;
|
|
163
|
+
},
|
|
164
|
+
get width() {
|
|
165
|
+
return leftRailbarInfo.width;
|
|
166
|
+
},
|
|
167
|
+
set width(newValue) {
|
|
168
|
+
leftRailbarInfo.width = newValue;
|
|
169
|
+
},
|
|
170
|
+
get takesSpace() {
|
|
171
|
+
return leftRailbarInfo.takesSpace;
|
|
172
|
+
},
|
|
173
|
+
set takesSpace(newValue) {
|
|
174
|
+
leftRailbarInfo.takesSpace = newValue;
|
|
175
|
+
},
|
|
176
|
+
get ready() {
|
|
177
|
+
return leftRailbarInfo.ready;
|
|
178
|
+
},
|
|
179
|
+
set ready(newValue) {
|
|
180
|
+
leftRailbarInfo.ready = newValue;
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
rightRailbarCtx.set({
|
|
184
|
+
get view() {
|
|
185
|
+
return view;
|
|
186
|
+
},
|
|
187
|
+
get width() {
|
|
188
|
+
return rightRailbarInfo.width;
|
|
189
|
+
},
|
|
190
|
+
set width(newValue) {
|
|
191
|
+
rightRailbarInfo.width = newValue;
|
|
192
|
+
},
|
|
193
|
+
get takesSpace() {
|
|
194
|
+
return rightRailbarInfo.takesSpace;
|
|
195
|
+
},
|
|
196
|
+
set takesSpace(newValue) {
|
|
197
|
+
rightRailbarInfo.takesSpace = newValue;
|
|
198
|
+
},
|
|
199
|
+
get ready() {
|
|
200
|
+
return rightRailbarInfo.ready;
|
|
201
|
+
},
|
|
202
|
+
set ready(newValue) {
|
|
203
|
+
rightRailbarInfo.ready = newValue;
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
leftDrawerCtx.set({
|
|
208
|
+
get view() {
|
|
209
|
+
return view;
|
|
210
|
+
},
|
|
211
|
+
get width() {
|
|
212
|
+
return leftDrawerInfo.width;
|
|
213
|
+
},
|
|
214
|
+
set width(newValue) {
|
|
215
|
+
leftDrawerInfo.width = newValue;
|
|
216
|
+
},
|
|
217
|
+
get takesSpace() {
|
|
218
|
+
return leftDrawerInfo.takesSpace;
|
|
219
|
+
},
|
|
220
|
+
set takesSpace(newValue) {
|
|
221
|
+
leftDrawerInfo.takesSpace = newValue;
|
|
222
|
+
},
|
|
223
|
+
get ready() {
|
|
224
|
+
return leftDrawerInfo.ready;
|
|
225
|
+
},
|
|
226
|
+
set ready(newValue) {
|
|
227
|
+
leftDrawerInfo.ready = newValue;
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
rightDrawerCtx.set({
|
|
231
|
+
get view() {
|
|
232
|
+
return view;
|
|
233
|
+
},
|
|
234
|
+
get width() {
|
|
235
|
+
return rightDrawerInfo.width;
|
|
236
|
+
},
|
|
237
|
+
set width(newValue) {
|
|
238
|
+
rightDrawerInfo.width = newValue;
|
|
239
|
+
},
|
|
240
|
+
get takesSpace() {
|
|
241
|
+
return rightDrawerInfo.takesSpace;
|
|
242
|
+
},
|
|
243
|
+
set takesSpace(newValue) {
|
|
244
|
+
rightDrawerInfo.takesSpace = newValue;
|
|
245
|
+
},
|
|
246
|
+
get ready() {
|
|
247
|
+
return rightDrawerInfo.ready;
|
|
248
|
+
},
|
|
249
|
+
set ready(newValue) {
|
|
250
|
+
rightDrawerInfo.ready = newValue;
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
// #endregion: --- Context
|
|
254
|
+
|
|
255
|
+
// #region: --- Lifecycle
|
|
256
|
+
onMount(() => {
|
|
257
|
+
setTimeout(() => {
|
|
258
|
+
if (contentEl) {
|
|
259
|
+
contentEl.style.transition = "margin 0.3s";
|
|
260
|
+
}
|
|
261
|
+
}, 100);
|
|
262
|
+
});
|
|
263
|
+
// #endregion: --- Lifecycle
|
|
264
|
+
|
|
265
|
+
// #region: --- Functions
|
|
266
|
+
function handleDrawerCtx(info: Omit<DrawerContext, "view">) {
|
|
267
|
+
return info.takesSpace ? info.width : 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function appBarReady(barType: "header" | "footer") {
|
|
271
|
+
const hasBar = barType === "header" ? header : footer;
|
|
272
|
+
const barInfo = barType === "header" ? headerInfo : footerInfo;
|
|
273
|
+
const barReady = !hasBar || barInfo.ready;
|
|
274
|
+
|
|
275
|
+
return barReady || (layoutEl && !layoutEl.querySelector(`.q-${barType}`));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function sideBarReady(barType: "railbar" | "drawer", side: "left" | "right") {
|
|
279
|
+
const barReady =
|
|
280
|
+
side === "left"
|
|
281
|
+
? {
|
|
282
|
+
railbar: !railbarLeft || leftRailbarInfo.ready,
|
|
283
|
+
drawer: !drawerLeft || leftDrawerInfo.ready,
|
|
284
|
+
}
|
|
285
|
+
: {
|
|
286
|
+
railbar: !railbarRight || rightRailbarInfo.ready,
|
|
287
|
+
drawer: !drawerRight || rightDrawerInfo.ready,
|
|
288
|
+
};
|
|
137
289
|
|
|
138
|
-
|
|
139
|
-
|
|
290
|
+
return (
|
|
291
|
+
barReady[barType] ||
|
|
292
|
+
(layoutEl && !layoutEl.querySelector(`:scope > .q-${barType}--${side}`))
|
|
293
|
+
);
|
|
140
294
|
}
|
|
295
|
+
// #endregion: --- Functions
|
|
141
296
|
</script>
|
|
142
297
|
|
|
143
298
|
<div
|
|
144
299
|
bind:this={layoutEl}
|
|
145
300
|
{...props}
|
|
146
301
|
class={["q-layout", props.class, isReady && "q-layout--ready"]}
|
|
147
|
-
style:--left-drawer-width={`${drawerLeft ?
|
|
148
|
-
style:--right-drawer-width={`${drawerRight ?
|
|
149
|
-
style:--left-railbar-width={`${railbarLeft ?
|
|
150
|
-
style:--right-railbar-width={`${railbarRight ?
|
|
302
|
+
style:--left-drawer-width={`${drawerLeft ? leftDrawerInfo.width : 0}px`}
|
|
303
|
+
style:--right-drawer-width={`${drawerRight ? rightDrawerInfo.width : 0}px`}
|
|
304
|
+
style:--left-railbar-width={`${railbarLeft ? leftRailbarInfo.width : 0}px`}
|
|
305
|
+
style:--right-railbar-width={`${railbarRight ? rightRailbarInfo.width : 0}px`}
|
|
151
306
|
style:--offset-top={`${topOffset}px`}
|
|
152
307
|
style:--offset-right={`${rightOffset}px`}
|
|
153
308
|
style:--offset-bottom={`${bottomOffset}px`}
|
|
@@ -162,14 +317,14 @@
|
|
|
162
317
|
{@render header?.()}
|
|
163
318
|
{@render footer?.()}
|
|
164
319
|
|
|
165
|
-
<
|
|
320
|
+
<ContextResetter
|
|
166
321
|
keys={[
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
322
|
+
headerCtx.symbol,
|
|
323
|
+
footerCtx.symbol,
|
|
324
|
+
leftRailbarCtx.symbol,
|
|
325
|
+
rightRailbarCtx.symbol,
|
|
326
|
+
leftDrawerCtx.symbol,
|
|
327
|
+
rightDrawerCtx.symbol,
|
|
173
328
|
]}
|
|
174
329
|
>
|
|
175
330
|
<div
|
|
@@ -183,5 +338,5 @@
|
|
|
183
338
|
{@render children?.()}
|
|
184
339
|
{/if}
|
|
185
340
|
</div>
|
|
186
|
-
</
|
|
341
|
+
</ContextResetter>
|
|
187
342
|
</div>
|