vueless 0.0.667 → 0.0.669
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/bin/commands/index.js +5 -0
- package/bin/commands/init.js +39 -0
- package/bin/constants.js +48 -0
- package/bin/index.js +24 -0
- package/package.json +5 -2
- package/ui.form-date-picker/UDatePicker.vue +3 -4
- package/ui.form-date-picker/storybook/stories.ts +3 -3
- package/ui.form-date-picker/types.ts +1 -1
- package/utils/node/dynamicProps.js +8 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
import { cwd } from "node:process";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { writeFile } from "node:fs/promises";
|
|
6
|
+
import { styleText } from "node:util";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_VUELESS_CONFIG_NAME,
|
|
10
|
+
DEFAULT_VUELESS_CONFIG_CONTNET,
|
|
11
|
+
TYPESCRIPT_EXT,
|
|
12
|
+
JAVASCRIPT_EXT,
|
|
13
|
+
} from "../constants.js";
|
|
14
|
+
|
|
15
|
+
const destPath = path.join(cwd(), DEFAULT_VUELESS_CONFIG_NAME);
|
|
16
|
+
|
|
17
|
+
const vuelessInitOptions = ["--ts", "--js"];
|
|
18
|
+
|
|
19
|
+
export async function vuelssInit(options) {
|
|
20
|
+
const isValidOptions = options.every((option) => vuelessInitOptions.includes(option));
|
|
21
|
+
|
|
22
|
+
if (options.length && !isValidOptions) {
|
|
23
|
+
throw new Error("Ivalid options were provided");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const fileExt = options.includes("--ts") ? TYPESCRIPT_EXT : JAVASCRIPT_EXT;
|
|
27
|
+
const formattedDestPath = path.format({ ...path.parse(destPath), base: "", ext: fileExt });
|
|
28
|
+
|
|
29
|
+
console.log(formattedDestPath);
|
|
30
|
+
|
|
31
|
+
await writeFile(formattedDestPath, DEFAULT_VUELESS_CONFIG_CONTNET, "utf-8");
|
|
32
|
+
|
|
33
|
+
const successMessage = styleText(
|
|
34
|
+
"green",
|
|
35
|
+
`Success: ${formattedDestPath.split(path.sep).at(-1)} was created in ${cwd()} directory`,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
console.log(successMessage);
|
|
39
|
+
}
|
package/bin/constants.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const DEFAULT_VUELESS_CONFIG_NAME = "vueless.config.js";
|
|
2
|
+
export const DEFAULT_EXIT_CODE = 0;
|
|
3
|
+
export const FAILURE_CODE = 1;
|
|
4
|
+
export const TYPESCRIPT_EXT = ".ts";
|
|
5
|
+
export const JAVASCRIPT_EXT = ".js";
|
|
6
|
+
export const DEFAULT_VUELESS_CONFIG_CONTNET = `
|
|
7
|
+
export default {
|
|
8
|
+
/**
|
|
9
|
+
* Global settings.
|
|
10
|
+
*/
|
|
11
|
+
strategy: "merge",
|
|
12
|
+
brand: "grayscale",
|
|
13
|
+
gray: "cool",
|
|
14
|
+
darkMode: "auto",
|
|
15
|
+
ring: 4,
|
|
16
|
+
ringOffset: 0,
|
|
17
|
+
ringOffsetColorLight: "#ffffff", // white
|
|
18
|
+
ringOffsetColorDark: "#111827", // gray-900
|
|
19
|
+
rounding: 8,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Directive settings.
|
|
23
|
+
*/
|
|
24
|
+
directive: {},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Component settings.
|
|
28
|
+
*/
|
|
29
|
+
component: /*tw*/ {},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Tailwind CSS theme config.
|
|
33
|
+
* https://tailwindcss.com/docs/theme
|
|
34
|
+
*/
|
|
35
|
+
tailwindTheme: {
|
|
36
|
+
extend: {
|
|
37
|
+
colors: {},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Custom classes TailwindMerge settings.
|
|
43
|
+
* All lists of rules available here:
|
|
44
|
+
* https://github.com/dcastil/tailwind-merge/blob/v2.3.0/src/lib/default-config.ts
|
|
45
|
+
*/
|
|
46
|
+
tailwindMerge: {},
|
|
47
|
+
};
|
|
48
|
+
`;
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
|
|
5
|
+
import { commands } from "./commands/index.js";
|
|
6
|
+
|
|
7
|
+
import { DEFAULT_EXIT_CODE, FAILURE_CODE } from "./constants.js";
|
|
8
|
+
|
|
9
|
+
const [command, ...options] = process.argv.slice(2);
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
if (!command || command === "undefiend") {
|
|
13
|
+
process.exit(DEFAULT_EXIT_CODE);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (command in commands) {
|
|
17
|
+
commands[command](options);
|
|
18
|
+
} else {
|
|
19
|
+
throw new Error(`There is no such command: ${command}`);
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error(error.message);
|
|
23
|
+
process.exit(error.code || FAILURE_CODE);
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.669",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
|
|
6
6
|
"keywords": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"build": "npm run pre:start && storybook build --docs",
|
|
34
34
|
"preview": "vite preview --host --outDir=storybook-static",
|
|
35
35
|
"ts:check": "vue-tsc --build --force",
|
|
36
|
-
"release:prepare": "npm run pre:start && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE README.md dist/",
|
|
36
|
+
"release:prepare": "npm run pre:start && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE README.md dist/ && cp -r bin dist/bin",
|
|
37
37
|
"release:beta": "release-it --ci --npm.publish --preRelease=beta --increment=prerelease",
|
|
38
38
|
"release:patch": "release-it patch --ci --npm.publish",
|
|
39
39
|
"release:minor": "release-it minor --ci --npm.publish --git.tag --github.release",
|
|
@@ -42,6 +42,9 @@
|
|
|
42
42
|
"lint:fix": "eslint --fix src/ .storybook/",
|
|
43
43
|
"lint:ci": "eslint --no-fix --max-warnings=0"
|
|
44
44
|
},
|
|
45
|
+
"bin": {
|
|
46
|
+
"vueless": "./bin/index.js"
|
|
47
|
+
},
|
|
45
48
|
"dependencies": {
|
|
46
49
|
"@tailwindcss/forms": "^0.5.9",
|
|
47
50
|
"cva": "^1.0.0-beta.1",
|
|
@@ -23,16 +23,15 @@ import { COMPONENT_NAME } from "./constants.ts";
|
|
|
23
23
|
import { vClickOutside } from "../directives";
|
|
24
24
|
|
|
25
25
|
import type { ComputedRef } from "vue";
|
|
26
|
-
import type {
|
|
26
|
+
import type { Props, Config, Locale } from "./types.ts";
|
|
27
27
|
import type { ComponentExposed } from "../types.ts";
|
|
28
28
|
import type { Config as UCalendarConfig } from "../ui.form-calendar/types.ts";
|
|
29
29
|
import type { DateLocale } from "../ui.form-calendar/utilFormatting.ts";
|
|
30
30
|
|
|
31
31
|
defineOptions({ inheritAttrs: false });
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...getDefaults<Props, Config>(defaultConfig, COMPONENT_NAME),
|
|
33
|
+
const props = withDefaults(defineProps<Props<TModelValue>>(), {
|
|
34
|
+
...getDefaults<Props<TModelValue>, Config>(defaultConfig, COMPONENT_NAME),
|
|
36
35
|
modelValue: undefined,
|
|
37
36
|
minDate: undefined,
|
|
38
37
|
maxDate: undefined,
|
|
@@ -12,13 +12,13 @@ import URow from "../../ui.container-row/URow.vue";
|
|
|
12
12
|
|
|
13
13
|
import { COMPONENT_NAME } from "../constants.ts";
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type { Props } from "../types.ts";
|
|
16
16
|
|
|
17
|
-
interface DefaultUDatePickerArgs extends
|
|
17
|
+
interface DefaultUDatePickerArgs extends Props<unknown> {
|
|
18
18
|
slotTemplate?: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
interface EnumUDatePickerArgs extends
|
|
21
|
+
interface EnumUDatePickerArgs extends Props<unknown> {
|
|
22
22
|
slotTemplate?: string;
|
|
23
23
|
enum: "size";
|
|
24
24
|
}
|
|
@@ -5,7 +5,7 @@ import type { ComponentConfig } from "../types.ts";
|
|
|
5
5
|
export type Locale = typeof defaultConfig.i18n;
|
|
6
6
|
export type Config = typeof defaultConfig;
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface Props<TModelValue> {
|
|
9
9
|
/**
|
|
10
10
|
* Calendar value (JavaScript Date object or string formatted in given `dateFormat` or object when `range` enabled).
|
|
11
11
|
*/
|
|
@@ -11,7 +11,7 @@ const CLOSING_BRACKET = "}";
|
|
|
11
11
|
const IGNORE_PROP = "@ignore";
|
|
12
12
|
const CUSTOM_PROP = "@custom";
|
|
13
13
|
|
|
14
|
-
const PROPS_INTERFACE_REG_EXP = /export\s+interface\s+Props
|
|
14
|
+
const PROPS_INTERFACE_REG_EXP = /export\s+interface\s+Props(?:<\w+>)?\s*{([^}]*)}/s;
|
|
15
15
|
const UNION_SYMBOLS_REG_EXP = /[?|:"|;]/g;
|
|
16
16
|
const WORD_IN_QUOTE_REG_EXP = /"([^"]+)"/g;
|
|
17
17
|
|
|
@@ -129,6 +129,11 @@ async function modifyComponentTypes(filePath, props) {
|
|
|
129
129
|
const defaultOptionalMark = lines[propIndex]?.includes(OPTIONAL_MARK) ? OPTIONAL_MARK : "";
|
|
130
130
|
const optionalMark = required === undefined ? defaultOptionalMark : userOptionalMark;
|
|
131
131
|
|
|
132
|
+
const isExtendOnly = lines
|
|
133
|
+
.slice(propIndex - 2, propIndex)
|
|
134
|
+
.join("")
|
|
135
|
+
.includes("@extendOnly");
|
|
136
|
+
|
|
132
137
|
const propDescription = description?.replaceAll(/[\n\s]+/g, " ").trim() || "–"; // removes new lines and double spaces.
|
|
133
138
|
const propType = unionType.length ? unionType : type;
|
|
134
139
|
|
|
@@ -142,14 +147,14 @@ async function modifyComponentTypes(filePath, props) {
|
|
|
142
147
|
|
|
143
148
|
/* Check if the prop type already exists. */
|
|
144
149
|
if (~propIndex) {
|
|
145
|
-
if (unionType.length && isAssignableValue) {
|
|
150
|
+
if (unionType.length && (isAssignableValue || !isExtendOnly)) {
|
|
146
151
|
// Remove multiline union types;
|
|
147
152
|
lines.splice(propIndex + 1, propEndIndex);
|
|
148
153
|
|
|
149
154
|
lines.splice(propIndex, 1, ` ${name}${defaultOptionalMark}: ${propType};`);
|
|
150
155
|
}
|
|
151
156
|
|
|
152
|
-
if (unionType.length && !isAssignableValue) {
|
|
157
|
+
if (unionType.length && isExtendOnly && !isAssignableValue) {
|
|
153
158
|
// eslint-disable-next-line no-console
|
|
154
159
|
console.warn(`${unionType} is not assignable to type ${defaultUnionType}.`);
|
|
155
160
|
}
|