@brickflow/ui 0.0.56 → 0.0.57
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/dist/module.d.mts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -0
- package/dist/runtime/components/Form/index.vue +46 -1
- package/dist/runtime/components/Form/login.demo.vue +12 -1
- package/dist/runtime/components/Input/index.vue +144 -22
- package/dist/runtime/components/Input/label.demo.vue +15 -3
- package/dist/runtime/components/Input/mask.demo.vue +73 -0
- package/dist/runtime/components/Input/variants.demo.vue +16 -0
- package/dist/runtime/components/InputNumber/denominator.demo.vue +1 -1
- package/dist/runtime/components/InputNumber/index.vue +25 -5
- package/dist/runtime/components/TransitionSize/duration.demo.vue +88 -0
- package/dist/runtime/components/TransitionSize/flex.demo.vue +112 -0
- package/dist/runtime/components/TransitionSize/height.demo.vue +88 -0
- package/dist/runtime/components/TransitionSize/index.vue +69 -27
- package/dist/runtime/components/TransitionSize/width.demo.vue +88 -0
- package/dist/runtime/composables/useBrickflow.d.ts +2 -0
- package/dist/runtime/composables/useFieldRules.d.ts +16 -0
- package/dist/runtime/composables/useFieldRules.js +42 -0
- package/dist/runtime/utils/rules.d.ts +34 -0
- package/dist/runtime/utils/rules.js +68 -0
- package/dist/types.d.mts +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useBrickflow } from "../composables/useBrickflow.js";
|
|
2
|
+
export const defaultRuleMessages = {
|
|
3
|
+
email: () => "Enter a valid email",
|
|
4
|
+
length: ({ length: expectedLength }) => `Must be exactly ${expectedLength} characters`,
|
|
5
|
+
maxLength: ({ max }) => `Maximum ${max} characters`,
|
|
6
|
+
minLength: ({ min }) => `Minimum ${min} characters`,
|
|
7
|
+
required: () => "Required field",
|
|
8
|
+
url: () => "Enter a valid URL"
|
|
9
|
+
};
|
|
10
|
+
export const rule = { email, length, maxLength, minLength, regex, required, url };
|
|
11
|
+
function email() {
|
|
12
|
+
const messages = { ...defaultRuleMessages, ...useBrickflow().rules };
|
|
13
|
+
return (value) => {
|
|
14
|
+
if (!value) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const parts = value.split("@");
|
|
18
|
+
const domain = parts[1];
|
|
19
|
+
return parts.length === 2 && Boolean(parts[0]) && Boolean(domain?.includes(".")) && !/\s/.test(value) || messages.email();
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function length(expectedLength) {
|
|
23
|
+
const messages = { ...defaultRuleMessages, ...useBrickflow().rules };
|
|
24
|
+
return (value) => !value || value.length === expectedLength || messages.length({ length: expectedLength });
|
|
25
|
+
}
|
|
26
|
+
function maxLength(max) {
|
|
27
|
+
const messages = { ...defaultRuleMessages, ...useBrickflow().rules };
|
|
28
|
+
return (value) => !value || value.length <= max || messages.maxLength({ max });
|
|
29
|
+
}
|
|
30
|
+
function minLength(min) {
|
|
31
|
+
const messages = { ...defaultRuleMessages, ...useBrickflow().rules };
|
|
32
|
+
return (value) => !value || value.length >= min || messages.minLength({ min });
|
|
33
|
+
}
|
|
34
|
+
function regex(pattern, message) {
|
|
35
|
+
return (value) => {
|
|
36
|
+
pattern.lastIndex = 0;
|
|
37
|
+
return !value || pattern.test(value) || (typeof message === "function" ? message() : message);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function required() {
|
|
41
|
+
const messages = { ...defaultRuleMessages, ...useBrickflow().rules };
|
|
42
|
+
return (value) => {
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
return value.trim().length > 0 || messages.required();
|
|
45
|
+
}
|
|
46
|
+
if (typeof value === "boolean") {
|
|
47
|
+
return value || messages.required();
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(value)) {
|
|
50
|
+
return value.length > 0 || messages.required();
|
|
51
|
+
}
|
|
52
|
+
return value !== null && value !== void 0 || messages.required();
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function url() {
|
|
56
|
+
const messages = { ...defaultRuleMessages, ...useBrickflow().rules };
|
|
57
|
+
return (value) => {
|
|
58
|
+
if (!value) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const parsed = new URL(value);
|
|
63
|
+
return ["http:", "https:"].includes(parsed.protocol) && Boolean(parsed.hostname) || messages.url();
|
|
64
|
+
} catch {
|
|
65
|
+
return messages.url();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
package/dist/types.d.mts
CHANGED
|
@@ -2,6 +2,8 @@ export { type BrickflowConfig } from '../dist/runtime/composables/useBrickflow.j
|
|
|
2
2
|
|
|
3
3
|
export { type BrickflowI18n, type BrickflowRouteLocationParam } from '../dist/runtime/composables/useTranslate.js'
|
|
4
4
|
|
|
5
|
+
export { type Rule, type RuleMessages, type rule } from '../dist/runtime/utils/rules.js'
|
|
6
|
+
|
|
5
7
|
export { default } from './module.mjs'
|
|
6
8
|
|
|
7
9
|
export { type ModuleOptions } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brickflow/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "brickflow UI Nuxt module.",
|
|
6
6
|
"files": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@tailwindcss/vite": "4.3.3",
|
|
36
36
|
"fantasticon": "4.1.0",
|
|
37
37
|
"jiti": "2.7.0",
|
|
38
|
+
"maska": "3.2.2",
|
|
38
39
|
"tailwind-merge": "3.6.0",
|
|
39
40
|
"tailwindcss": "4.3.3"
|
|
40
41
|
},
|