@community-release/nx-ui 0.0.18 → 0.0.20

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 CHANGED
@@ -1,7 +1,228 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
1
+ import { defineNuxtModule, createResolver, addTemplate, addPlugin, addComponentsDir, addComponent } from '@nuxt/kit';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
2
4
 
3
- interface ModuleOptions {
4
- }
5
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
5
+ var defaultStyle = {
6
+ "content-width": "1400px",
7
+ // website content width
8
+ // Border radius
9
+ "border-radius-big": "18px",
10
+ "border-radius-default": "8px",
11
+ "border-radius-small": "3px",
12
+ // Inputs height
13
+ "input-height-large": "60px",
14
+ "input-height-big": "52px",
15
+ "input-height-medium": "48px",
16
+ "input-height-default": "42px",
17
+ "input-height-small": "32px",
18
+ "input-height-mini": "24px",
19
+ // Line height
20
+ "text-line-height": 1.4,
21
+ // Colors
22
+ "color-text": "rgba(0,0,0,0.8)",
23
+ "color-header-text": "rgba(0,0,0,1)",
24
+ "color-primary": "blue",
25
+ "color-primary-text": "blue",
26
+ "color-text-on-primary": "#fff",
27
+ "color-secondary": "cyan",
28
+ "color-secondary-text": "cyan",
29
+ "color-text-on-secondary": "#fff",
30
+ "color-gray": "rgba(56,60,68, 0.8)",
31
+ "color-gray-text": "rgba(56,60,68, 1)",
32
+ "color-text-on-gray": "#fff",
33
+ "color-red": "red",
34
+ "color-red-text": "var(--color-red)",
35
+ "color-text-on-red": "#fff",
36
+ "color-error": "var(--color-red)",
37
+ "color-surface": "#ccc",
38
+ "color-surface-text": "#aaa",
39
+ "color-text-on-surface": "var(--color-text)",
40
+ "color-neutral": "#ccc",
41
+ "color-neutral-text": "#aaa",
42
+ "color-text-on-neutral": "var(--color-text)",
43
+ "color-bg": "#fff",
44
+ "color-bg-text": "#fff",
45
+ "color-text-on-bg": "var(--color-text)",
46
+ "color-border": "#e8e8e8",
47
+ "color-border-bolder": "#e0e0e0",
48
+ // Text
49
+ "text-large": "32px",
50
+ "text-big": "24px",
51
+ "text-medium": "18px",
52
+ "text-default": "16px",
53
+ "text-small": "14px",
54
+ "text-mini": "12px",
55
+ // Font
56
+ "font-text": '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";',
57
+ "font-header": "var(--font-text)",
58
+ "font-accent": "var(--font-text)",
59
+ "font-icons": "FontAwesome",
60
+ "font-mono": "Consolas, SF Mono",
61
+ // Font weight
62
+ "font-weight-medium": "600",
63
+ // Padding
64
+ "space-extra-large": "100px",
65
+ "space-large": "50px",
66
+ "space-big": "32px",
67
+ "space-medium": "25px",
68
+ "space-default": "20px",
69
+ "space-small": "15px",
70
+ "space-mini": "10px",
71
+ "space-micro": "5px",
72
+ // Box shadow
73
+ "bs-1": "0 3px 8px rgba(13,72,177, 0.03), 0 6px 16px rgba(13,72,177, 0.03)",
74
+ "bs-2": "0 1px 3px rgba(13,72,177, 0.07), 0 1px 2px rgba(13,72,177, 0.1)",
75
+ "bs-3": "0 0.4px 0.6px rgba(13,72,177, 0.019), 0 1px 1.6px rgba(13,72,177, 0.027), 0 2.1px 3.2px rgba(13,72,177, 0.033), 4.4px 6.6px rgba(13,72,177, 0.041), 0 12px 18px rgba(13,72,177, 0.06)",
76
+ // Animation
77
+ "ani-time": "0.3s",
78
+ "ani-ease": "ease"
79
+ };
6
80
 
7
- export { type ModuleOptions, _default as default };
81
+ var generateStyle = (options) => {
82
+ let result = ":root {";
83
+ const userStyle = options?.style ? options.style : {};
84
+ for (let key in userStyle) {
85
+ if (key in defaultStyle)
86
+ defaultStyle[key] = userStyle[key];
87
+ else
88
+ console.error(`UI: Unknown css variable defined in ui config "${key}"`);
89
+ }
90
+ for (let key in defaultStyle) {
91
+ result += `--ui-${key}:${defaultStyle[key]};`;
92
+ }
93
+ result += "}";
94
+ return result;
95
+ };
96
+
97
+ var defaultComponentsStyle = {
98
+ accordion: {
99
+ "title-font-size": "var(--ui-text-medium)",
100
+ "text-font-size": "var(--ui-text-default)"
101
+ },
102
+ button: {
103
+ "border-radius": "var(--ui-input-height-large)"
104
+ }
105
+ };
106
+
107
+ var generateComponentsDefaults = (options) => {
108
+ let result = "";
109
+ const components = options?.components ? options.components : {};
110
+ for (let name in defaultComponentsStyle) {
111
+ const style = Object.assign(defaultComponentsStyle[name], components[name] ? components[name] : {});
112
+ for (let prop in style) {
113
+ result += `@ui-${name}-${prop}: ${style[prop]};
114
+ `;
115
+ }
116
+ }
117
+ return result;
118
+ };
119
+
120
+ var readComponentsProps = (resolve, srcDir, options = {}) => {
121
+ const dirComponents = resolve(srcDir, "./runtime/components/");
122
+ const result = {};
123
+ let files = fs.readdirSync(dirComponents, { recursive: true, encoding: "utf-8" });
124
+ files = files.filter((v) => v.indexOf("props.json") !== -1);
125
+ for (let file of files) {
126
+ const componentName = file.split(path.sep)[0];
127
+ const propsJSON = fs.readFileSync(resolve(dirComponents, file), { encoding: "utf-8" });
128
+ const props = JSON.parse(propsJSON);
129
+ result[componentName] = props;
130
+ }
131
+ if (options?.componentsProps) {
132
+ for (let componentName in options.componentsProps) {
133
+ if (!(componentName in result)) {
134
+ console.error(`Reading user defined components props error: component "${componentName}" does not exist`);
135
+ continue;
136
+ }
137
+ const userDefinedProps = options.componentsProps[componentName];
138
+ for (let prop in userDefinedProps) {
139
+ if (!(prop in result[componentName])) {
140
+ console.error(`Reading user defined components props error: prop "${prop}" does not exist in "${componentName}"`);
141
+ continue;
142
+ }
143
+ result[componentName][prop] = userDefinedProps[prop];
144
+ }
145
+ }
146
+ }
147
+ return result;
148
+ };
149
+
150
+ var module = defineNuxtModule({
151
+ meta: {
152
+ name: "ui",
153
+ configKey: "ui"
154
+ },
155
+ // Default configuration options of the Nuxt module
156
+ defaults: {},
157
+ setup(options, nuxt) {
158
+ const { resolve } = createResolver(import.meta.url);
159
+ const srcDir = resolve("./");
160
+ addTemplate({
161
+ filename: "ui.style.mjs",
162
+ getContents: () => "export default " + JSON.stringify(generateStyle(options))
163
+ //write: true
164
+ });
165
+ addTemplate({
166
+ dst: resolve("./runtime/components/styles/components.less"),
167
+ write: true,
168
+ filename: "components.less",
169
+ getContents: () => generateComponentsDefaults(options)
170
+ });
171
+ const componentsProps = readComponentsProps(resolve, srcDir, options);
172
+ for (let componentName in componentsProps) {
173
+ addTemplate({
174
+ filename: `ui.${componentName}.mjs`,
175
+ // @ts-ignore
176
+ getContents: () => "export default " + JSON.stringify(componentsProps[componentName])
177
+ });
178
+ }
179
+ addPlugin({
180
+ src: resolve("./runtime/plugins/variables"),
181
+ mode: "server"
182
+ });
183
+ addPlugin({
184
+ src: resolve("./runtime/plugins/methods"),
185
+ mode: "all"
186
+ });
187
+ addComponentsDir({
188
+ path: resolve("./runtime/components"),
189
+ // watch: true,
190
+ prefix: "ui",
191
+ pathPrefix: false,
192
+ global: false,
193
+ extensions: ["vue"]
194
+ });
195
+ addComponent({
196
+ filePath: resolve("./runtime/components/accordion/item"),
197
+ name: "ui-accordion-item",
198
+ global: false
199
+ });
200
+ addComponent({
201
+ filePath: resolve("./runtime/components/map/zoom"),
202
+ name: "ui-map-zoom",
203
+ global: false
204
+ });
205
+ addComponent({
206
+ filePath: resolve("./runtime/components/map/device-zoom-switch"),
207
+ name: "ui-map-device-zoom-switch",
208
+ global: false
209
+ });
210
+ addComponent({
211
+ filePath: resolve("./runtime/components/map/location/index"),
212
+ name: "ui-map-location",
213
+ global: false
214
+ });
215
+ addComponent({
216
+ filePath: resolve("./runtime/components/map/location/list"),
217
+ name: "ui-map-location-list",
218
+ global: false
219
+ });
220
+ addComponent({
221
+ filePath: resolve("./runtime/components/map/location/nearest"),
222
+ name: "ui-map-location-nearest",
223
+ global: false
224
+ });
225
+ }
226
+ });
227
+
228
+ export { module as default };
package/dist/module.d.ts CHANGED
@@ -1,7 +1,228 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
1
+ import { defineNuxtModule, createResolver, addTemplate, addPlugin, addComponentsDir, addComponent } from '@nuxt/kit';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
2
4
 
3
- interface ModuleOptions {
4
- }
5
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
5
+ var defaultStyle = {
6
+ "content-width": "1400px",
7
+ // website content width
8
+ // Border radius
9
+ "border-radius-big": "18px",
10
+ "border-radius-default": "8px",
11
+ "border-radius-small": "3px",
12
+ // Inputs height
13
+ "input-height-large": "60px",
14
+ "input-height-big": "52px",
15
+ "input-height-medium": "48px",
16
+ "input-height-default": "42px",
17
+ "input-height-small": "32px",
18
+ "input-height-mini": "24px",
19
+ // Line height
20
+ "text-line-height": 1.4,
21
+ // Colors
22
+ "color-text": "rgba(0,0,0,0.8)",
23
+ "color-header-text": "rgba(0,0,0,1)",
24
+ "color-primary": "blue",
25
+ "color-primary-text": "blue",
26
+ "color-text-on-primary": "#fff",
27
+ "color-secondary": "cyan",
28
+ "color-secondary-text": "cyan",
29
+ "color-text-on-secondary": "#fff",
30
+ "color-gray": "rgba(56,60,68, 0.8)",
31
+ "color-gray-text": "rgba(56,60,68, 1)",
32
+ "color-text-on-gray": "#fff",
33
+ "color-red": "red",
34
+ "color-red-text": "var(--color-red)",
35
+ "color-text-on-red": "#fff",
36
+ "color-error": "var(--color-red)",
37
+ "color-surface": "#ccc",
38
+ "color-surface-text": "#aaa",
39
+ "color-text-on-surface": "var(--color-text)",
40
+ "color-neutral": "#ccc",
41
+ "color-neutral-text": "#aaa",
42
+ "color-text-on-neutral": "var(--color-text)",
43
+ "color-bg": "#fff",
44
+ "color-bg-text": "#fff",
45
+ "color-text-on-bg": "var(--color-text)",
46
+ "color-border": "#e8e8e8",
47
+ "color-border-bolder": "#e0e0e0",
48
+ // Text
49
+ "text-large": "32px",
50
+ "text-big": "24px",
51
+ "text-medium": "18px",
52
+ "text-default": "16px",
53
+ "text-small": "14px",
54
+ "text-mini": "12px",
55
+ // Font
56
+ "font-text": '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";',
57
+ "font-header": "var(--font-text)",
58
+ "font-accent": "var(--font-text)",
59
+ "font-icons": "FontAwesome",
60
+ "font-mono": "Consolas, SF Mono",
61
+ // Font weight
62
+ "font-weight-medium": "600",
63
+ // Padding
64
+ "space-extra-large": "100px",
65
+ "space-large": "50px",
66
+ "space-big": "32px",
67
+ "space-medium": "25px",
68
+ "space-default": "20px",
69
+ "space-small": "15px",
70
+ "space-mini": "10px",
71
+ "space-micro": "5px",
72
+ // Box shadow
73
+ "bs-1": "0 3px 8px rgba(13,72,177, 0.03), 0 6px 16px rgba(13,72,177, 0.03)",
74
+ "bs-2": "0 1px 3px rgba(13,72,177, 0.07), 0 1px 2px rgba(13,72,177, 0.1)",
75
+ "bs-3": "0 0.4px 0.6px rgba(13,72,177, 0.019), 0 1px 1.6px rgba(13,72,177, 0.027), 0 2.1px 3.2px rgba(13,72,177, 0.033), 4.4px 6.6px rgba(13,72,177, 0.041), 0 12px 18px rgba(13,72,177, 0.06)",
76
+ // Animation
77
+ "ani-time": "0.3s",
78
+ "ani-ease": "ease"
79
+ };
6
80
 
7
- export { type ModuleOptions, _default as default };
81
+ var generateStyle = (options) => {
82
+ let result = ":root {";
83
+ const userStyle = options?.style ? options.style : {};
84
+ for (let key in userStyle) {
85
+ if (key in defaultStyle)
86
+ defaultStyle[key] = userStyle[key];
87
+ else
88
+ console.error(`UI: Unknown css variable defined in ui config "${key}"`);
89
+ }
90
+ for (let key in defaultStyle) {
91
+ result += `--ui-${key}:${defaultStyle[key]};`;
92
+ }
93
+ result += "}";
94
+ return result;
95
+ };
96
+
97
+ var defaultComponentsStyle = {
98
+ accordion: {
99
+ "title-font-size": "var(--ui-text-medium)",
100
+ "text-font-size": "var(--ui-text-default)"
101
+ },
102
+ button: {
103
+ "border-radius": "var(--ui-input-height-large)"
104
+ }
105
+ };
106
+
107
+ var generateComponentsDefaults = (options) => {
108
+ let result = "";
109
+ const components = options?.components ? options.components : {};
110
+ for (let name in defaultComponentsStyle) {
111
+ const style = Object.assign(defaultComponentsStyle[name], components[name] ? components[name] : {});
112
+ for (let prop in style) {
113
+ result += `@ui-${name}-${prop}: ${style[prop]};
114
+ `;
115
+ }
116
+ }
117
+ return result;
118
+ };
119
+
120
+ var readComponentsProps = (resolve, srcDir, options = {}) => {
121
+ const dirComponents = resolve(srcDir, "./runtime/components/");
122
+ const result = {};
123
+ let files = fs.readdirSync(dirComponents, { recursive: true, encoding: "utf-8" });
124
+ files = files.filter((v) => v.indexOf("props.json") !== -1);
125
+ for (let file of files) {
126
+ const componentName = file.split(path.sep)[0];
127
+ const propsJSON = fs.readFileSync(resolve(dirComponents, file), { encoding: "utf-8" });
128
+ const props = JSON.parse(propsJSON);
129
+ result[componentName] = props;
130
+ }
131
+ if (options?.componentsProps) {
132
+ for (let componentName in options.componentsProps) {
133
+ if (!(componentName in result)) {
134
+ console.error(`Reading user defined components props error: component "${componentName}" does not exist`);
135
+ continue;
136
+ }
137
+ const userDefinedProps = options.componentsProps[componentName];
138
+ for (let prop in userDefinedProps) {
139
+ if (!(prop in result[componentName])) {
140
+ console.error(`Reading user defined components props error: prop "${prop}" does not exist in "${componentName}"`);
141
+ continue;
142
+ }
143
+ result[componentName][prop] = userDefinedProps[prop];
144
+ }
145
+ }
146
+ }
147
+ return result;
148
+ };
149
+
150
+ var module = defineNuxtModule({
151
+ meta: {
152
+ name: "ui",
153
+ configKey: "ui"
154
+ },
155
+ // Default configuration options of the Nuxt module
156
+ defaults: {},
157
+ setup(options, nuxt) {
158
+ const { resolve } = createResolver(import.meta.url);
159
+ const srcDir = resolve("./");
160
+ addTemplate({
161
+ filename: "ui.style.mjs",
162
+ getContents: () => "export default " + JSON.stringify(generateStyle(options))
163
+ //write: true
164
+ });
165
+ addTemplate({
166
+ dst: resolve("./runtime/components/styles/components.less"),
167
+ write: true,
168
+ filename: "components.less",
169
+ getContents: () => generateComponentsDefaults(options)
170
+ });
171
+ const componentsProps = readComponentsProps(resolve, srcDir, options);
172
+ for (let componentName in componentsProps) {
173
+ addTemplate({
174
+ filename: `ui.${componentName}.mjs`,
175
+ // @ts-ignore
176
+ getContents: () => "export default " + JSON.stringify(componentsProps[componentName])
177
+ });
178
+ }
179
+ addPlugin({
180
+ src: resolve("./runtime/plugins/variables"),
181
+ mode: "server"
182
+ });
183
+ addPlugin({
184
+ src: resolve("./runtime/plugins/methods"),
185
+ mode: "all"
186
+ });
187
+ addComponentsDir({
188
+ path: resolve("./runtime/components"),
189
+ // watch: true,
190
+ prefix: "ui",
191
+ pathPrefix: false,
192
+ global: false,
193
+ extensions: ["vue"]
194
+ });
195
+ addComponent({
196
+ filePath: resolve("./runtime/components/accordion/item"),
197
+ name: "ui-accordion-item",
198
+ global: false
199
+ });
200
+ addComponent({
201
+ filePath: resolve("./runtime/components/map/zoom"),
202
+ name: "ui-map-zoom",
203
+ global: false
204
+ });
205
+ addComponent({
206
+ filePath: resolve("./runtime/components/map/device-zoom-switch"),
207
+ name: "ui-map-device-zoom-switch",
208
+ global: false
209
+ });
210
+ addComponent({
211
+ filePath: resolve("./runtime/components/map/location/index"),
212
+ name: "ui-map-location",
213
+ global: false
214
+ });
215
+ addComponent({
216
+ filePath: resolve("./runtime/components/map/location/list"),
217
+ name: "ui-map-location-list",
218
+ global: false
219
+ });
220
+ addComponent({
221
+ filePath: resolve("./runtime/components/map/location/nearest"),
222
+ name: "ui-map-location-nearest",
223
+ global: false
224
+ });
225
+ }
226
+ });
227
+
228
+ export { module as default };
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "ui",
3
3
  "configKey": "ui",
4
- "version": "0.0.18"
4
+ "version": "0.0.20"
5
5
  }
package/dist/module.mjs CHANGED
@@ -120,7 +120,7 @@ const generateComponentsDefaults = (options) => {
120
120
  const readComponentsProps = (resolve, srcDir, options = {}) => {
121
121
  const dirComponents = resolve(srcDir, "./runtime/components/");
122
122
  const result = {};
123
- let files = fs.readdirSync(dirComponents, { recursive: true });
123
+ let files = fs.readdirSync(dirComponents, { recursive: true, encoding: "utf-8" });
124
124
  files = files.filter((v) => v.indexOf("props.json") !== -1);
125
125
  for (let file of files) {
126
126
  const componentName = file.split(path.sep)[0];
@@ -169,7 +169,6 @@ const module = defineNuxtModule({
169
169
  getContents: () => generateComponentsDefaults(options)
170
170
  });
171
171
  const componentsProps = readComponentsProps(resolve, srcDir, options);
172
- console.log("nx-ui componentsProps", componentsProps);
173
172
  for (let componentName in componentsProps) {
174
173
  addTemplate({
175
174
  filename: `ui.${componentName}.mjs`,
@@ -193,6 +192,11 @@ const module = defineNuxtModule({
193
192
  global: false,
194
193
  extensions: ["vue"]
195
194
  });
195
+ addComponent({
196
+ filePath: resolve("./runtime/components/accordion/item"),
197
+ name: "ui-accordion-item",
198
+ global: false
199
+ });
196
200
  addComponent({
197
201
  filePath: resolve("./runtime/components/map/zoom"),
198
202
  name: "ui-map-zoom",
@@ -0,0 +1,73 @@
1
+ <template>
2
+ <section class="component-ui-accordion">
3
+ <ui-accordion-item v-if="list.length" v-for="item of list" :title="item.title">
4
+ {{ item.text }}
5
+ </ui-accordion-item>
6
+ <slot></slot>
7
+ </section>
8
+ </template>
9
+
10
+ <script setup>
11
+ // Imports
12
+ import { ref, computed, provide } from 'vue';
13
+ import comProps from '#build/ui.accordion.mjs';
14
+
15
+ // Data
16
+ const props = defineProps({
17
+ /** Icon for light theme or light & dark theme*/
18
+ icon: {
19
+ type: String,
20
+ default: comProps.icon
21
+ },
22
+ /** Icon for dark theme */
23
+ iconDark: {
24
+ type: String,
25
+ default: comProps.iconDark
26
+ },
27
+ /**
28
+ * Accordion elements list, AccordionListItem = {title: '', text: ''}
29
+ * @values AccordionListItem[]
30
+ */
31
+ list: {
32
+ type: Array,
33
+ default: () => []
34
+ },
35
+ /**
36
+ * Slide that is active(open) by default, null = all closed
37
+ * @values 1, 2, 3, 1000, null
38
+ */
39
+ active: {
40
+ type: [Number, null],
41
+ default: 0
42
+ }
43
+ });
44
+
45
+ const activeItem = ref(props.active);
46
+ const itemCounter = ref(0);
47
+
48
+ const iconLightComputed = computed(() => {
49
+ return props.icon !== '' ? `url(${props.icon})` : 'none';
50
+ });
51
+
52
+ const iconDarkComputed = computed(() => {
53
+ return props.iconDark !== '' ? `url(${props.iconDark})` : iconLightComputed.value;
54
+ });
55
+
56
+ provide('accordionData', {
57
+ itemCounter,
58
+ activeItem,
59
+ haveIcon: !!props.icon
60
+ });
61
+ </script>
62
+
63
+ <style lang="less">
64
+ // Themes settings
65
+ .theme-light .component-ui-accordion .icon,
66
+ .theme-lowvision .component-ui-accordion .icon {
67
+ background-image: v-bind(iconLightComputed);
68
+ }
69
+
70
+ .theme-dark .component-ui-accordion .icon {
71
+ background-image: v-bind(iconDarkComputed);
72
+ }
73
+ </style>