Major overhaul to the theme and now functioning.

This commit is contained in:
david committed 2026-01-05 16:07:30 -05:00
1 parent 5823ca3c39
commit a475dfeab6
5218 files changed
+1643729 -13229

No files matched your search

@@ -0,0 +1,2 @@
export * from './rules.js';
export * from './plugin.js';
@@ -0,0 +1,3 @@
export * from "./rules.js";
export * from "./plugin.js";
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":[],"sources":["../../../src/labs/rules/index.ts"],"sourcesContent":["export * from './rules'\nexport * from './plugin'\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,8 @@
// Types
import type { App } from 'vue';
import type { RulesOptions } from './rules.js';
import type { LocaleInstance } from '../../composables/locale.js';
export interface RulesPlugin {
install: (app: App) => void;
}
export declare function createRulesPlugin(rules: RulesOptions, locale: LocaleInstance): RulesPlugin;
@@ -0,0 +1,10 @@
// Composables
import { createRules, RulesSymbol } from "./rules.js"; // Types
export function createRulesPlugin(rules, locale) {
return {
install(app) {
app.provide(RulesSymbol, createRules(rules, locale));
}
};
}
//# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
{"version":3,"file":"plugin.js","names":["createRules","RulesSymbol","createRulesPlugin","rules","locale","install","app","provide"],"sources":["../../../src/labs/rules/plugin.ts"],"sourcesContent":["// Composables\nimport { createRules, RulesSymbol } from './rules'\n\n// Types\nimport type { App } from 'vue'\nimport type { RulesOptions } from './rules'\nimport type { LocaleInstance } from '@/composables/locale'\n\nexport interface RulesPlugin {\n install: (app: App) => void\n}\n\nexport function createRulesPlugin (rules: RulesOptions, locale: LocaleInstance): RulesPlugin {\n return {\n install (app: App) {\n app.provide(RulesSymbol, createRules(rules, locale))\n },\n }\n}\n"],"mappings":"AAAA;AAAA,SACSA,WAAW,EAAEC,WAAW,sBAEjC;AASA,OAAO,SAASC,iBAAiBA,CAAEC,KAAmB,EAAEC,MAAsB,EAAe;EAC3F,OAAO;IACLC,OAAOA,CAAEC,GAAQ,EAAE;MACjBA,GAAG,CAACC,OAAO,CAACN,WAAW,EAAED,WAAW,CAACG,KAAK,EAAEC,MAAM,CAAC,CAAC;IACtD;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,38 @@
// Types
import type { InjectionKey, Ref } from 'vue';
import type { LocaleInstance } from '../../composables/locale.js';
import type { ValidationProps, ValidationRule } from '../../composables/validation.js';
export type ValidationRuleBuilderWithoutOptions = (err?: string) => ValidationRule;
export type ValidationRuleBuilderWithOptions<T> = (options: T, err?: string) => ValidationRule;
export type ValidationRuleBuilder = ValidationRuleBuilderWithoutOptions | ValidationRuleBuilderWithOptions<any>;
export interface RuleAliases {
[name: string]: ValidationRuleBuilder;
required: ValidationRuleBuilderWithoutOptions;
email: ValidationRuleBuilderWithoutOptions;
number: ValidationRuleBuilderWithoutOptions;
integer: ValidationRuleBuilderWithoutOptions;
capital: ValidationRuleBuilderWithoutOptions;
maxLength: ValidationRuleBuilderWithOptions<number>;
minLength: ValidationRuleBuilderWithOptions<number>;
strictLength: ValidationRuleBuilderWithOptions<number>;
exclude: ValidationRuleBuilderWithOptions<string[]>;
notEmpty: ValidationRuleBuilderWithoutOptions;
pattern: ValidationRuleBuilderWithOptions<RegExp>;
}
export type RulesOptions = {
aliases?: Partial<RuleAliases>;
};
type ValidationRuleParams = [any, string?];
export type ValidationAlias = string | [string, ...ValidationRuleParams];
export type RulesInstance = {
resolve: (fn: () => ValidationProps['rules']) => Readonly<Ref<any[]>>;
aliases: RuleAliases;
};
export declare function createRules(options: RulesOptions | undefined, locale: LocaleInstance): {
resolve: (fn: () => readonly (string | boolean | PromiseLike<import("../../composables/validation.js").ValidationResult> | ((value: any) => import("../../composables/validation.js").ValidationResult) | ((value: any) => PromiseLike<import("../../composables/validation.js").ValidationResult>) | [string, any, (string | undefined)?])[]) => import("vue").ComputedRef<([string, any, (string | undefined)?] | ValidationRule)[]>;
aliases: RuleAliases;
};
export declare const RulesSymbol: InjectionKey<RulesInstance>;
export declare function useRules(): RuleAliases;
export declare function useRules(fn: () => ValidationProps['rules']): Readonly<Ref<ValidationProps['rules']>> | Readonly<Ref<ValidationRule[]>>;
@@ -0,0 +1,91 @@
// Utilities
import { computed, inject, toRef } from 'vue';
// Types
export function createRules(options, locale) {
const {
t
} = locale;
const aliases = {
required: err => {
return v => {
// If the modifier .number is used, the 0 will be a number and it's a falsy value so we need to check for it
return v === 0 || !!v || t(err || '$vuetify.rules.required');
};
},
email: err => {
return v => !v || typeof v === 'string' && /^.+@\S+\.\S+$/.test(v) || t(err || '$vuetify.rules.email');
},
number: err => {
return v => !v || !isNaN(Number(v)) || t(err || '$vuetify.rules.number');
},
integer: err => {
return v => /^[\d]*$/.test(v) || t(err || '$vuetify.rules.integer');
},
capital: err => {
return v => /^[A-Z]*$/.test(v) || t(err || '$vuetify.rules.capital');
},
maxLength: (len, err) => {
return v => !v || v.length <= len || t(err || '$vuetify.rules.maxLength', len);
},
minLength: (len, err) => {
return v => !v || v.length >= len || t(err || '$vuetify.rules.minLength', len);
},
strictLength: (len, err) => {
return v => !v || v.length === len || t(err || '$vuetify.rules.strictLength', len);
},
exclude: (forbiddenCharacters, err) => {
return v => {
let error = true;
for (const character of forbiddenCharacters) {
if (v.includes(character)) error = err || t('$vuetify.rules.exclude', character);
}
return error;
};
},
notEmpty: err => {
return v => v && v.length > 0 || t(err || '$vuetify.rules.notEmpty');
},
pattern: (pattern, err) => {
return v => !v || pattern.test(v) || t(err || '$vuetify.rules.pattern');
},
...options?.aliases
};
function resolve(fn) {
return computed(() => fn().map(rule => {
let ruleName = null;
let ruleParams = [undefined];
if (Array.isArray(rule)) {
ruleName = rule[0];
ruleParams = rule.slice(1);
} else if (typeof rule === 'string') {
ruleName = rule;
}
if (ruleName !== null) {
if (ruleName.startsWith('$')) {
ruleName = ruleName.slice(1);
}
return aliases[ruleName]?.(...ruleParams);
} else {
return rule;
}
}));
}
return {
resolve,
aliases
};
}
export const RulesSymbol = Symbol.for('vuetify:rules');
export function useRules(fn) {
const rules = inject(RulesSymbol, null);
if (!fn) {
if (!rules) {
throw new Error('Could not find Vuetify rules injection');
}
return rules.aliases;
}
return rules?.resolve(fn) ?? toRef(fn);
}
//# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
{"version":3,"file":"rules.js","names":["computed","inject","toRef","createRules","options","locale","t","aliases","required","err","v","email","test","number","isNaN","Number","integer","capital","maxLength","len","length","minLength","strictLength","exclude","forbiddenCharacters","error","character","includes","notEmpty","pattern","resolve","fn","map","rule","ruleName","ruleParams","undefined","Array","isArray","slice","startsWith","RulesSymbol","Symbol","for","useRules","rules","Error"],"sources":["../../../src/labs/rules/rules.ts"],"sourcesContent":["// Utilities\nimport { computed, inject, toRef } from 'vue'\n\n// Types\nimport type { InjectionKey, Ref } from 'vue'\nimport type { LocaleInstance } from '@/composables/locale'\nimport type { ValidationProps, ValidationRule } from '@/composables/validation'\n\nexport type ValidationRuleBuilderWithoutOptions = (err?: string) => ValidationRule\nexport type ValidationRuleBuilderWithOptions<T> = (options: T, err?: string) => ValidationRule\nexport type ValidationRuleBuilder =\n | ValidationRuleBuilderWithoutOptions\n | ValidationRuleBuilderWithOptions<any>\n\nexport interface RuleAliases {\n [name: string]: ValidationRuleBuilder\n required: ValidationRuleBuilderWithoutOptions\n email: ValidationRuleBuilderWithoutOptions\n number: ValidationRuleBuilderWithoutOptions\n integer: ValidationRuleBuilderWithoutOptions\n capital: ValidationRuleBuilderWithoutOptions\n maxLength: ValidationRuleBuilderWithOptions<number>\n minLength: ValidationRuleBuilderWithOptions<number>\n strictLength: ValidationRuleBuilderWithOptions<number>\n exclude: ValidationRuleBuilderWithOptions<string[]>\n notEmpty: ValidationRuleBuilderWithoutOptions\n pattern: ValidationRuleBuilderWithOptions<RegExp>\n}\n\nexport type RulesOptions = {\n aliases?: Partial<RuleAliases>\n}\n\ntype ValidationRuleParams = [any, string?]\nexport type ValidationAlias = string | [string, ...ValidationRuleParams]\n\nexport type RulesInstance = {\n resolve: (fn: () => ValidationProps['rules']) => Readonly<Ref<any[]>>\n aliases: RuleAliases\n}\n\nexport function createRules (options: RulesOptions | undefined, locale: LocaleInstance) {\n const { t } = locale\n\n const aliases: RuleAliases = {\n required: (err?: string) => {\n return (v: any) => {\n // If the modifier .number is used, the 0 will be a number and it's a falsy value so we need to check for it\n return v === 0 || !!v || t(err || '$vuetify.rules.required')\n }\n },\n email: (err?: string) => {\n return (v: any) => (!v || (typeof v === 'string' && /^.+@\\S+\\.\\S+$/.test(v))) || t(err || '$vuetify.rules.email')\n },\n number: (err?: string) => {\n return (v: string) => !v || !isNaN(Number(v)) || t(err || '$vuetify.rules.number')\n },\n integer: (err?: string) => {\n return (v: string) => (/^[\\d]*$/.test(v)) || t(err || '$vuetify.rules.integer')\n },\n capital: (err?: string) => {\n return (v: string) => (/^[A-Z]*$/.test(v)) || t(err || '$vuetify.rules.capital')\n },\n maxLength: (len: number, err?: string) => {\n return (v: any) => (!v || v.length <= len) || t(err || '$vuetify.rules.maxLength', len)\n },\n minLength: (len: number, err?: string) => {\n return (v: any) => (!v || v.length >= len) || t(err || '$vuetify.rules.minLength', len)\n },\n strictLength: (len: number, err?: string) => {\n return (v: any) => (!v || v.length === len) || t(err || '$vuetify.rules.strictLength', len)\n },\n exclude: (forbiddenCharacters: string[], err?: string) => {\n return (v: string) => {\n let error: string | true = true\n for (const character of forbiddenCharacters) {\n if (v.includes(character)) error = err || t('$vuetify.rules.exclude', character)\n }\n return error\n }\n },\n notEmpty: (err?: string) => {\n return (v: any) => (v && v.length > 0) || t(err || '$vuetify.rules.notEmpty')\n },\n pattern: (pattern: RegExp, err?: string) => {\n return (v: any) => (!v || pattern.test(v) || t(err || '$vuetify.rules.pattern'))\n },\n\n ...options?.aliases,\n }\n\n function resolve (fn: () => ValidationProps['rules']) {\n return computed(() => fn().map(rule => {\n let ruleName: string | null = null\n let ruleParams: ValidationRuleParams = [undefined]\n if (Array.isArray(rule)) {\n ruleName = rule[0]\n ruleParams = rule.slice(1) as ValidationRuleParams\n } else if (typeof rule === 'string') {\n ruleName = rule\n }\n\n if (ruleName !== null) {\n if (ruleName.startsWith('$')) {\n ruleName = ruleName.slice(1)\n }\n\n return aliases[ruleName]?.(...ruleParams)\n } else {\n return rule\n }\n }))\n }\n\n return {\n resolve,\n aliases,\n }\n}\n\nexport const RulesSymbol: InjectionKey<RulesInstance> = Symbol.for('vuetify:rules')\n\nexport function useRules (): RuleAliases\neLine truncated