@toife/vue 3.1.4 → 3.1.5
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 +1 -1
- package/package.json +1 -1
- package/src/components/action/action.scss +1 -1
- package/src/components/action/action.vue +5 -5
- package/src/components/app/app.scss +2 -2
- package/src/components/app/app.vue +5 -5
- package/src/components/avatar/avatar.scss +3 -2
- package/src/components/avatar/avatar.vue +6 -6
- package/src/components/button/button.scss +13 -13
- package/src/components/button/button.vue +7 -7
- package/src/components/cable/cable.vue +2 -2
- package/src/components/card/card/card.scss +2 -2
- package/src/components/card/card/card.vue +5 -5
- package/src/components/card/card-body/card-body.scss +2 -2
- package/src/components/card/card-body/card-body.vue +2 -2
- package/src/components/card/card-footer/card-footer.scss +3 -3
- package/src/components/card/card-footer/card-footer.vue +2 -2
- package/src/components/card/card-header/card-header.scss +3 -3
- package/src/components/card/card-header/card-header.vue +2 -2
- package/src/components/checkbox/checkbox.html +1 -1
- package/src/components/checkbox/checkbox.scss +18 -13
- package/src/components/checkbox/checkbox.vue +7 -7
- package/src/components/collapse/collapse.html +1 -1
- package/src/components/collapse/collapse.scss +2 -2
- package/src/components/collapse/collapse.vue +9 -9
- package/src/components/container/container.vue +2 -2
- package/src/components/decision-modal/decision-modal.scss +9 -9
- package/src/components/decision-modal/decision-modal.vue +8 -8
- package/src/components/divider/divider.scss +2 -2
- package/src/components/divider/divider.vue +4 -4
- package/src/components/dropdown/dropdown.scss +3 -3
- package/src/components/dropdown/dropdown.vue +7 -9
- package/src/components/field/field.type.ts +2 -2
- package/src/components/field/outline/outline.scss +15 -13
- package/src/components/field/outline/outline.vue +26 -18
- package/src/components/form-group/form-group.vue +2 -2
- package/src/components/gesture-indicator/gesture-indicator.scss +1 -1
- package/src/components/gesture-indicator/gesture-indicator.vue +4 -4
- package/src/components/image/image.vue +12 -5
- package/src/components/layout/flex/flex.vue +8 -8
- package/src/components/layout/flex-item/flex-item.vue +6 -6
- package/src/components/layout/grid/grid.vue +6 -6
- package/src/components/layout/grid-item/grid-item.vue +6 -6
- package/src/components/modal/modal.scss +1 -1
- package/src/components/modal/modal.vue +68 -5
- package/src/components/page/page.vue +2 -2
- package/src/components/present/present.scss +3 -3
- package/src/components/present/present.vue +14 -14
- package/src/components/radio/radio/radio.html +1 -1
- package/src/components/radio/radio/radio.scss +18 -13
- package/src/components/radio/radio/radio.type.ts +1 -1
- package/src/components/radio/radio/radio.vue +6 -6
- package/src/components/radio/radio-group/radio-group.vue +2 -2
- package/src/components/refresher/refresher.html +0 -3
- package/src/components/refresher/refresher.scss +1 -25
- package/src/components/refresher/refresher.vue +2 -16
- package/src/components/route/route-navigator/route-navigator.scss +2 -2
- package/src/components/route/route-navigator/route-navigator.vue +10 -13
- package/src/components/route/route-wrapper/route-wrapper.composable.ts +5 -15
- package/src/components/route/route-wrapper/route-wrapper.type.ts +0 -4
- package/src/components/route/route-wrapper/route-wrapper.vue +4 -12
- package/src/components/route/route.type.ts +0 -1
- package/src/components/segmented-field/segmented-field.html +1 -1
- package/src/components/segmented-field/segmented-field.scss +2 -2
- package/src/components/segmented-field/segmented-field.vue +8 -8
- package/src/components/select/select.html +2 -2
- package/src/components/select/select.scss +10 -10
- package/src/components/select/select.vue +10 -10
- package/src/components/skeleton/skeleton.vue +7 -7
- package/src/components/slide-range/slide-range.html +3 -4
- package/src/components/slide-range/slide-range.scss +10 -10
- package/src/components/slide-range/slide-range.vue +16 -16
- package/src/components/switch/switch.html +1 -1
- package/src/components/switch/switch.scss +22 -20
- package/src/components/switch/switch.type.ts +1 -0
- package/src/components/switch/switch.vue +23 -9
- package/src/components/tabs/tab/tab.html +1 -1
- package/src/components/tabs/tab/tab.scss +13 -0
- package/src/components/tabs/tab/tab.vue +4 -2
- package/src/components/tabs/tabs/index.ts +1 -0
- package/src/components/tabs/tabs/tabs.scss +81 -49
- package/src/components/tabs/tabs/tabs.type.ts +5 -1
- package/src/components/tabs/tabs/tabs.vue +47 -23
- package/src/components/toast/toast/toast.vue +2 -2
- package/src/components/toast/toast-content/toast-content.scss +3 -3
- package/src/components/toast/toast-content/toast-content.vue +5 -5
- package/src/components/toolbar/toolbar.scss +3 -3
- package/src/components/toolbar/toolbar.vue +5 -5
- package/src/factory.ts +105 -51
- package/src/type.ts +2 -1
- package/src/utils/style/index.ts +9 -9
- package/src/utils/style.md +9 -9
package/src/factory.ts
CHANGED
|
@@ -43,56 +43,110 @@ import {
|
|
|
43
43
|
ToastContent,
|
|
44
44
|
Toolbar,
|
|
45
45
|
} from "./components";
|
|
46
|
-
import { type
|
|
47
|
-
import type
|
|
46
|
+
import { type SubscribeOptions } from "./type";
|
|
47
|
+
import { DefineComponent, ref, type App as VueApp } from "vue";
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
49
|
+
const apps = ref<Record<string, any>>({});
|
|
50
|
+
const defaultAppName = "toife";
|
|
51
|
+
|
|
52
|
+
class Toife {
|
|
53
|
+
/**
|
|
54
|
+
* Subscribe options
|
|
55
|
+
*/
|
|
56
|
+
public options: SubscribeOptions;
|
|
57
|
+
public app: VueApp;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Constructor
|
|
61
|
+
*/
|
|
62
|
+
constructor(app: VueApp, options?: SubscribeOptions) {
|
|
63
|
+
this.options = options || {
|
|
64
|
+
name: defaultAppName,
|
|
65
|
+
prefix: "t-",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
this.app = app;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Subscribe components
|
|
73
|
+
*/
|
|
74
|
+
subscribeComponents() {
|
|
75
|
+
const prefix = this.options.prefix;
|
|
76
|
+
this.app.component(prefix + "app", App);
|
|
77
|
+
this.app.component(prefix + "action", Action);
|
|
78
|
+
this.app.component(prefix + "avatar", Avatar);
|
|
79
|
+
this.app.component(prefix + "button", Button);
|
|
80
|
+
this.app.component(prefix + "cable", Cable);
|
|
81
|
+
this.app.component(prefix + "card", Card);
|
|
82
|
+
this.app.component(prefix + "card-body", CardBody);
|
|
83
|
+
this.app.component(prefix + "card-header", CardHeader);
|
|
84
|
+
this.app.component(prefix + "card-footer", CardFooter);
|
|
85
|
+
this.app.component(prefix + "checkbox", Checkbox);
|
|
86
|
+
this.app.component(prefix + "radio", Radio);
|
|
87
|
+
this.app.component(prefix + "radio-group", RadioGroup);
|
|
88
|
+
this.app.component(prefix + "collapse", Collapse);
|
|
89
|
+
this.app.component(prefix + "container", Container);
|
|
90
|
+
this.app.component(prefix + "decision-modal", DecisionModal);
|
|
91
|
+
this.app.component(prefix + "divider", Divider);
|
|
92
|
+
this.app.component(prefix + "dropdown", Dropdown);
|
|
93
|
+
this.app.component(prefix + "field", Field);
|
|
94
|
+
this.app.component(prefix + "flex", Flex);
|
|
95
|
+
this.app.component(prefix + "flex-item", FlexItem);
|
|
96
|
+
this.app.component(prefix + "form-group", FormGroup);
|
|
97
|
+
this.app.component(prefix + "gesture-indicator", GestureIndicator);
|
|
98
|
+
this.app.component(prefix + "grid", Grid);
|
|
99
|
+
this.app.component(prefix + "grid-item", GridItem);
|
|
100
|
+
this.app.component(prefix + "image", Image);
|
|
101
|
+
this.app.component(prefix + "modal", Modal);
|
|
102
|
+
this.app.component(prefix + "page", Page);
|
|
103
|
+
this.app.component(prefix + "present", Present);
|
|
104
|
+
this.app.component(prefix + "refresher", Refresher);
|
|
105
|
+
this.app.component(prefix + "route-navigator", RouteNavigator);
|
|
106
|
+
this.app.component(prefix + "route-wrapper", RouteWrapper);
|
|
107
|
+
this.app.component(prefix + "route-provider", RouteProvider);
|
|
108
|
+
this.app.component(prefix + "route-outlet", RouteOutlet);
|
|
109
|
+
this.app.component(prefix + "segmented-field", SegmentedField);
|
|
110
|
+
this.app.component(prefix + "select", Select);
|
|
111
|
+
this.app.component(prefix + "slide-range", SlideRange);
|
|
112
|
+
this.app.component(prefix + "skeleton", Skeleton);
|
|
113
|
+
this.app.component(prefix + "switch", Switch);
|
|
114
|
+
this.app.component(prefix + "tab", Tab);
|
|
115
|
+
this.app.component(prefix + "tabs", Tabs);
|
|
116
|
+
this.app.component(prefix + "toast", Toast);
|
|
117
|
+
this.app.component(prefix + "toast-content", ToastContent);
|
|
118
|
+
this.app.component(prefix + "toolbar", Toolbar);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Subscribe a component
|
|
123
|
+
*/
|
|
124
|
+
subscribe(name: string, component: DefineComponent<{}, {}, any>) {
|
|
125
|
+
if (!this.app.component(this.options.prefix + name)) {
|
|
126
|
+
this.app.component(this.options.prefix + name, component);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Subscribe components
|
|
133
|
+
*/
|
|
134
|
+
export const createToife = (app: VueApp, options?: SubscribeOptions) => {
|
|
135
|
+
const instance = new Toife(app, options);
|
|
136
|
+
apps.value[instance.options.name] = instance;
|
|
137
|
+
return instance;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get component name
|
|
142
|
+
*/
|
|
143
|
+
export const useApp = (name: string = defaultAppName) => {
|
|
144
|
+
return apps.value[name] || null;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get all apps
|
|
149
|
+
*/
|
|
150
|
+
export const getApps = () => {
|
|
151
|
+
return apps.value;
|
|
98
152
|
};
|
package/src/type.ts
CHANGED
package/src/utils/style/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ let separator: string | null = null;
|
|
|
4
4
|
/**
|
|
5
5
|
* Get the separator from the document element
|
|
6
6
|
*/
|
|
7
|
-
export const
|
|
7
|
+
export const getCssSeparator = () => {
|
|
8
8
|
if (!separator)
|
|
9
9
|
separator = getComputedStyle(document.documentElement).getPropertyValue("--separator").trim();
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ export const getSeparator = () => {
|
|
|
14
14
|
/**
|
|
15
15
|
* Get the prefix from the document element
|
|
16
16
|
*/
|
|
17
|
-
export const
|
|
17
|
+
export const getCssPrefix = () => {
|
|
18
18
|
if (!prefix)
|
|
19
19
|
prefix = getComputedStyle(document.documentElement).getPropertyValue("--prefix").trim();
|
|
20
20
|
|
|
@@ -24,9 +24,9 @@ export const getPrefix = () => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Generate the prefixed name
|
|
26
26
|
*/
|
|
27
|
-
export const
|
|
28
|
-
const p =
|
|
29
|
-
const s =
|
|
27
|
+
export const cssPrefix = (name: string | string[]) => {
|
|
28
|
+
const p = getCssPrefix();
|
|
29
|
+
const s = getCssSeparator();
|
|
30
30
|
let names = [];
|
|
31
31
|
|
|
32
32
|
if (typeof name === "string") {
|
|
@@ -45,13 +45,13 @@ export const withPrefix = (name: string | string[]) => {
|
|
|
45
45
|
/**
|
|
46
46
|
* Generate the property name
|
|
47
47
|
*/
|
|
48
|
-
export const
|
|
49
|
-
return `--${
|
|
48
|
+
export const cssProperty = (name: string | string[]) => {
|
|
49
|
+
return `--${cssPrefix(name)}`;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Generate the name with var() syntax
|
|
54
54
|
*/
|
|
55
|
-
export const
|
|
56
|
-
return `var(${
|
|
55
|
+
export const cssVariable = (name: string | string[]) => {
|
|
56
|
+
return `var(${cssProperty(name)})`;
|
|
57
57
|
};
|
package/src/utils/style.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Utils: `style`
|
|
2
2
|
|
|
3
|
-
> Import: `import { utils } from "@toife/vue"` then `utils.
|
|
3
|
+
> Import: `import { utils } from "@toife/vue"` then `utils.cssPrefix`, … (or import from `src/utils` in the monorepo).
|
|
4
4
|
|
|
5
5
|
**Source:** `src/utils/style/index.ts`
|
|
6
6
|
|
|
@@ -10,21 +10,21 @@ Reads `--prefix` and `--separator` from `document.documentElement` (cached), the
|
|
|
10
10
|
|
|
11
11
|
## API
|
|
12
12
|
|
|
13
|
-
### `
|
|
13
|
+
### `getCssPrefix(): string`
|
|
14
14
|
|
|
15
15
|
Trimmed `--prefix` on `:root` (singleton cache).
|
|
16
16
|
|
|
17
|
-
### `
|
|
17
|
+
### `getCssSeparator(): string`
|
|
18
18
|
|
|
19
19
|
Trimmed `--separator` (often `-` or `_`) used to join name parts.
|
|
20
20
|
|
|
21
|
-
### `
|
|
21
|
+
### `cssPrefix(name: string | string[]): string`
|
|
22
22
|
|
|
23
23
|
If prefix exists: `[prefix, ...parts].join(separator)`. `name` can be a string or parts array (e.g. `['layer','surface']`).
|
|
24
24
|
|
|
25
|
-
### `
|
|
25
|
+
### `cssProperty(name: string | string[]): string`
|
|
26
26
|
|
|
27
|
-
Returns the CSS custom property name **without** `var()`: `"--" +
|
|
27
|
+
Returns the CSS custom property name **without** `var()`: `"--" + cssPrefix(name)`.
|
|
28
28
|
|
|
29
29
|
### `variable(name: string | string[]): string`
|
|
30
30
|
|
|
@@ -35,8 +35,8 @@ Returns `var(--<prefixed…>)`.
|
|
|
35
35
|
```ts
|
|
36
36
|
import { utils } from "@toife/vue";
|
|
37
37
|
|
|
38
|
-
utils.
|
|
39
|
-
utils.
|
|
38
|
+
utils.cssPrefix("button");
|
|
39
|
+
utils.cssProperty(["field", "line"]);
|
|
40
40
|
utils.variable(["field", "line"]);
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -46,4 +46,4 @@ Requires `document` and `getComputedStyle` — client-only after `:root` defines
|
|
|
46
46
|
|
|
47
47
|
## See also
|
|
48
48
|
|
|
49
|
-
- Components using `
|
|
49
|
+
- Components using `cssPrefix` for BEM classes
|