@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.
Files changed (92) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/components/action/action.scss +1 -1
  4. package/src/components/action/action.vue +5 -5
  5. package/src/components/app/app.scss +2 -2
  6. package/src/components/app/app.vue +5 -5
  7. package/src/components/avatar/avatar.scss +3 -2
  8. package/src/components/avatar/avatar.vue +6 -6
  9. package/src/components/button/button.scss +13 -13
  10. package/src/components/button/button.vue +7 -7
  11. package/src/components/cable/cable.vue +2 -2
  12. package/src/components/card/card/card.scss +2 -2
  13. package/src/components/card/card/card.vue +5 -5
  14. package/src/components/card/card-body/card-body.scss +2 -2
  15. package/src/components/card/card-body/card-body.vue +2 -2
  16. package/src/components/card/card-footer/card-footer.scss +3 -3
  17. package/src/components/card/card-footer/card-footer.vue +2 -2
  18. package/src/components/card/card-header/card-header.scss +3 -3
  19. package/src/components/card/card-header/card-header.vue +2 -2
  20. package/src/components/checkbox/checkbox.html +1 -1
  21. package/src/components/checkbox/checkbox.scss +18 -13
  22. package/src/components/checkbox/checkbox.vue +7 -7
  23. package/src/components/collapse/collapse.html +1 -1
  24. package/src/components/collapse/collapse.scss +2 -2
  25. package/src/components/collapse/collapse.vue +9 -9
  26. package/src/components/container/container.vue +2 -2
  27. package/src/components/decision-modal/decision-modal.scss +9 -9
  28. package/src/components/decision-modal/decision-modal.vue +8 -8
  29. package/src/components/divider/divider.scss +2 -2
  30. package/src/components/divider/divider.vue +4 -4
  31. package/src/components/dropdown/dropdown.scss +3 -3
  32. package/src/components/dropdown/dropdown.vue +7 -9
  33. package/src/components/field/field.type.ts +2 -2
  34. package/src/components/field/outline/outline.scss +15 -13
  35. package/src/components/field/outline/outline.vue +26 -18
  36. package/src/components/form-group/form-group.vue +2 -2
  37. package/src/components/gesture-indicator/gesture-indicator.scss +1 -1
  38. package/src/components/gesture-indicator/gesture-indicator.vue +4 -4
  39. package/src/components/image/image.vue +12 -5
  40. package/src/components/layout/flex/flex.vue +8 -8
  41. package/src/components/layout/flex-item/flex-item.vue +6 -6
  42. package/src/components/layout/grid/grid.vue +6 -6
  43. package/src/components/layout/grid-item/grid-item.vue +6 -6
  44. package/src/components/modal/modal.scss +1 -1
  45. package/src/components/modal/modal.vue +68 -5
  46. package/src/components/page/page.vue +2 -2
  47. package/src/components/present/present.scss +3 -3
  48. package/src/components/present/present.vue +14 -14
  49. package/src/components/radio/radio/radio.html +1 -1
  50. package/src/components/radio/radio/radio.scss +18 -13
  51. package/src/components/radio/radio/radio.type.ts +1 -1
  52. package/src/components/radio/radio/radio.vue +6 -6
  53. package/src/components/radio/radio-group/radio-group.vue +2 -2
  54. package/src/components/refresher/refresher.html +0 -3
  55. package/src/components/refresher/refresher.scss +1 -25
  56. package/src/components/refresher/refresher.vue +2 -16
  57. package/src/components/route/route-navigator/route-navigator.scss +2 -2
  58. package/src/components/route/route-navigator/route-navigator.vue +10 -13
  59. package/src/components/route/route-wrapper/route-wrapper.composable.ts +5 -15
  60. package/src/components/route/route-wrapper/route-wrapper.type.ts +0 -4
  61. package/src/components/route/route-wrapper/route-wrapper.vue +4 -12
  62. package/src/components/route/route.type.ts +0 -1
  63. package/src/components/segmented-field/segmented-field.html +1 -1
  64. package/src/components/segmented-field/segmented-field.scss +2 -2
  65. package/src/components/segmented-field/segmented-field.vue +8 -8
  66. package/src/components/select/select.html +2 -2
  67. package/src/components/select/select.scss +10 -10
  68. package/src/components/select/select.vue +10 -10
  69. package/src/components/skeleton/skeleton.vue +7 -7
  70. package/src/components/slide-range/slide-range.html +3 -4
  71. package/src/components/slide-range/slide-range.scss +10 -10
  72. package/src/components/slide-range/slide-range.vue +16 -16
  73. package/src/components/switch/switch.html +1 -1
  74. package/src/components/switch/switch.scss +22 -20
  75. package/src/components/switch/switch.type.ts +1 -0
  76. package/src/components/switch/switch.vue +23 -9
  77. package/src/components/tabs/tab/tab.html +1 -1
  78. package/src/components/tabs/tab/tab.scss +13 -0
  79. package/src/components/tabs/tab/tab.vue +4 -2
  80. package/src/components/tabs/tabs/index.ts +1 -0
  81. package/src/components/tabs/tabs/tabs.scss +81 -49
  82. package/src/components/tabs/tabs/tabs.type.ts +5 -1
  83. package/src/components/tabs/tabs/tabs.vue +47 -23
  84. package/src/components/toast/toast/toast.vue +2 -2
  85. package/src/components/toast/toast-content/toast-content.scss +3 -3
  86. package/src/components/toast/toast-content/toast-content.vue +5 -5
  87. package/src/components/toolbar/toolbar.scss +3 -3
  88. package/src/components/toolbar/toolbar.vue +5 -5
  89. package/src/factory.ts +105 -51
  90. package/src/type.ts +2 -1
  91. package/src/utils/style/index.ts +9 -9
  92. 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 CreateToifeOptions } from "./type";
47
- import type { App as VueApp } from "vue";
46
+ import { type SubscribeOptions } from "./type";
47
+ import { DefineComponent, ref, type App as VueApp } from "vue";
48
48
 
49
- export const createToife = (options?: CreateToifeOptions) => {
50
- return {
51
- install: (app: VueApp) => {
52
- const prefix = options?.prefix || "t-";
53
- app.component(prefix + "app", App);
54
- app.component(prefix + "action", Action);
55
- app.component(prefix + "avatar", Avatar);
56
- app.component(prefix + "button", Button);
57
- app.component(prefix + "cable", Cable);
58
- app.component(prefix + "card", Card);
59
- app.component(prefix + "card-body", CardBody);
60
- app.component(prefix + "card-header", CardHeader);
61
- app.component(prefix + "card-footer", CardFooter);
62
- app.component(prefix + "checkbox", Checkbox);
63
- app.component(prefix + "radio", Radio);
64
- app.component(prefix + "radio-group", RadioGroup);
65
- app.component(prefix + "collapse", Collapse);
66
- app.component(prefix + "container", Container);
67
- app.component(prefix + "decision-modal", DecisionModal);
68
- app.component(prefix + "divider", Divider);
69
- app.component(prefix + "dropdown", Dropdown);
70
- app.component(prefix + "field", Field);
71
- app.component(prefix + "flex", Flex);
72
- app.component(prefix + "flex-item", FlexItem);
73
- app.component(prefix + "form-group", FormGroup);
74
- app.component(prefix + "gesture-indicator", GestureIndicator);
75
- app.component(prefix + "grid", Grid);
76
- app.component(prefix + "grid-item", GridItem);
77
- app.component(prefix + "image", Image);
78
- app.component(prefix + "modal", Modal);
79
- app.component(prefix + "page", Page);
80
- app.component(prefix + "present", Present);
81
- app.component(prefix + "refresher", Refresher);
82
- app.component(prefix + "route-navigator", RouteNavigator);
83
- app.component(prefix + "route-wrapper", RouteWrapper);
84
- app.component(prefix + "route-provider", RouteProvider);
85
- app.component(prefix + "route-outlet", RouteOutlet);
86
- app.component(prefix + "segmented-field", SegmentedField);
87
- app.component(prefix + "select", Select);
88
- app.component(prefix + "slide-range", SlideRange);
89
- app.component(prefix + "skeleton", Skeleton);
90
- app.component(prefix + "switch", Switch);
91
- app.component(prefix + "tab", Tab);
92
- app.component(prefix + "tabs", Tabs);
93
- app.component(prefix + "toast", Toast);
94
- app.component(prefix + "toast-content", ToastContent);
95
- app.component(prefix + "toolbar", Toolbar);
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
@@ -1,3 +1,4 @@
1
- export type CreateToifeOptions = {
1
+ export type SubscribeOptions = {
2
2
  prefix?: string;
3
+ name: string;
3
4
  };
@@ -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 getSeparator = () => {
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 getPrefix = () => {
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 withPrefix = (name: string | string[]) => {
28
- const p = getPrefix();
29
- const s = getSeparator();
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 property = (name: string | string[]) => {
49
- return `--${withPrefix(name)}`;
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 variable = (name: string | string[]) => {
56
- return `var(${property(name)})`;
55
+ export const cssVariable = (name: string | string[]) => {
56
+ return `var(${cssProperty(name)})`;
57
57
  };
@@ -1,6 +1,6 @@
1
1
  # Utils: `style`
2
2
 
3
- > Import: `import { utils } from "@toife/vue"` then `utils.withPrefix`, … (or import from `src/utils` in the monorepo).
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
- ### `getPrefix(): string`
13
+ ### `getCssPrefix(): string`
14
14
 
15
15
  Trimmed `--prefix` on `:root` (singleton cache).
16
16
 
17
- ### `getSeparator(): string`
17
+ ### `getCssSeparator(): string`
18
18
 
19
19
  Trimmed `--separator` (often `-` or `_`) used to join name parts.
20
20
 
21
- ### `withPrefix(name: string | string[]): string`
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
- ### `property(name: string | string[]): string`
25
+ ### `cssProperty(name: string | string[]): string`
26
26
 
27
- Returns the CSS custom property name **without** `var()`: `"--" + withPrefix(name)`.
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.withPrefix("button");
39
- utils.property(["field", "line"]);
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 `withPrefix` for BEM classes
49
+ - Components using `cssPrefix` for BEM classes