@gct-paas/core 0.0.1-dev.0 → 0.0.1-dev.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 冠骋信息技术有限公司
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ "use strict";var p=Object.defineProperty;var o=(a,s,t)=>s in a?p(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var i=(a,s,t)=>o(a,typeof s!="symbol"?s+"":s,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h="tag",m="is-";function c(a,s,t,e,n){let r=`${a}-${s}`;return t&&(r+=`-${t}`),e&&(r+=`__${e}`),n&&(r+=`--${n}`),r}class u{constructor(s,t){i(this,"namespace");this.block=s,this.namespace=t||h}b(s=""){return c(this.namespace,this.block,s,"","")}e(s){return s?c(this.namespace,this.block,"",s,""):""}m(s){return s?c(this.namespace,this.block,"","",s):""}be(s,t){return s&&t?c(this.namespace,this.block,s,t,""):""}em(s,t){return s&&t?c(this.namespace,this.block,"",s,t):""}bm(s,t){return s&&t?c(this.namespace,this.block,s,"",t):""}bem(s,t,e){return s&&t&&e?c(this.namespace,this.block,s,t,e):""}is(s,t){return s&&t?`${m}${s}`:""}cssVar(s){const t={};for(const e in s)s[e]&&(t[this.cssVarName(e)]=s[e]);return t}cssVarBlock(s){const t={};for(const e in s)s[e]&&(t[this.cssVarBlockName(e)]=s[e]);return t}cssVarName(s){return`--${this.namespace}-${s}`}cssVarBlockName(s){return`--${this.namespace}-${this.block}-${s}`}}function $(a){return new u(a)}exports.Namespace=u;exports.STYLE_NAMESPACE_TAG=h;exports.useNamespace=$;
@@ -0,0 +1 @@
1
+ var k=Object.defineProperty;var N=(a,c,r)=>c in a?k(a,c,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[c]=r;var p=(a,c,r)=>N(a,typeof c!="symbol"?c+"":c,r);System.register([],function(a,c){"use strict";return{execute:function(){a("useNamespace",$);const r=a("STYLE_NAMESPACE_TAG","tag"),o="is-";function n(i,s,t,e,m){let h=`${i}-${s}`;return t&&(h+=`-${t}`),e&&(h+=`__${e}`),m&&(h+=`--${m}`),h}class u{constructor(s,t){p(this,"namespace");this.block=s,this.namespace=t||r}b(s=""){return n(this.namespace,this.block,s,"","")}e(s){return s?n(this.namespace,this.block,"",s,""):""}m(s){return s?n(this.namespace,this.block,"","",s):""}be(s,t){return s&&t?n(this.namespace,this.block,s,t,""):""}em(s,t){return s&&t?n(this.namespace,this.block,"",s,t):""}bm(s,t){return s&&t?n(this.namespace,this.block,s,"",t):""}bem(s,t,e){return s&&t&&e?n(this.namespace,this.block,s,t,e):""}is(s,t){return s&&t?`${o}${s}`:""}cssVar(s){const t={};for(const e in s)s[e]&&(t[this.cssVarName(e)]=s[e]);return t}cssVarBlock(s){const t={};for(const e in s)s[e]&&(t[this.cssVarBlockName(e)]=s[e]);return t}cssVarName(s){return`--${this.namespace}-${s}`}cssVarBlockName(s){return`--${this.namespace}-${this.block}-${s}`}}a("Namespace",u);function $(i){return new u(i)}}}});
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 默认样式命名空间名称
3
+ */
4
+ export declare const STYLE_NAMESPACE_TAG = "tag";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ const STYLE_NAMESPACE_TAG = "tag";
3
+
4
+ export { STYLE_NAMESPACE_TAG };
@@ -0,0 +1 @@
1
+ export { useNamespace } from './use-namespace/use-namespace';
@@ -0,0 +1,3 @@
1
+ export { useNamespace } from './use-namespace/use-namespace.mjs';
2
+
3
+ "use strict";
@@ -0,0 +1,9 @@
1
+ import { Namespace } from '../../utils';
2
+ /**
3
+ * 获取 bem 操作类
4
+ *
5
+ * @export
6
+ * @param {string} block 当前实命名块
7
+ * @returns {*} {Namespace}
8
+ */
9
+ export declare function useNamespace(block: string): Namespace;
@@ -0,0 +1,9 @@
1
+ import '../../utils/index.mjs';
2
+ import { Namespace } from '../../utils/namespace/namespace.mjs';
3
+
4
+ "use strict";
5
+ function useNamespace(block) {
6
+ return new Namespace(block);
7
+ }
8
+
9
+ export { useNamespace };
package/es/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export declare function run(): void;
1
+ export * from './constants';
2
+ export * from './hooks';
3
+ export * from './utils';
package/es/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- "use strict";
2
- function run() {
3
- console.log("Hello World!");
4
- }
1
+ export { STYLE_NAMESPACE_TAG } from './constants/index.mjs';
2
+ import './hooks/index.mjs';
3
+ import './utils/index.mjs';
4
+ export { useNamespace } from './hooks/use-namespace/use-namespace.mjs';
5
+ export { Namespace } from './utils/namespace/namespace.mjs';
5
6
 
6
- export { run };
7
+ "use strict";
@@ -0,0 +1 @@
1
+ export { Namespace } from './namespace/namespace';
@@ -0,0 +1,3 @@
1
+ export { Namespace } from './namespace/namespace.mjs';
2
+
3
+ "use strict";
@@ -0,0 +1,146 @@
1
+ /**
2
+ * 全局样式处理命名空间
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-09-06 11:09:50
6
+ * @export
7
+ * @class Namespace
8
+ */
9
+ export declare class Namespace {
10
+ protected block: string;
11
+ /**
12
+ * 命名空间
13
+ *
14
+ * @author chitanda
15
+ * @date 2023-11-03 10:11:31
16
+ * @type {string}
17
+ */
18
+ readonly namespace: string;
19
+ /**
20
+ * Creates an instance of Namespace.
21
+ *
22
+ * @author chitanda
23
+ * @date 2022-09-06 12:09:12
24
+ * @param {string} block 当前命名空间的根模块,例如组件的名称
25
+ * @param {string} [namespace] 指定命名空间,未指定使用默认值 gct
26
+ */
27
+ constructor(block: string, namespace?: string);
28
+ /**
29
+ * namespace-block
30
+ * namespace-block-blockSuffix
31
+ *
32
+ * @author chitanda
33
+ * @date 2022-09-06 12:09:08
34
+ * @param {string} [blockSuffix='']
35
+ * @return {*} {string}
36
+ */
37
+ b(blockSuffix?: string): string;
38
+ /**
39
+ * namespace-block__element
40
+ *
41
+ * @author chitanda
42
+ * @date 2022-09-06 12:09:48
43
+ * @param {string} [element]
44
+ * @return {*} {string}
45
+ */
46
+ e(element?: string): string;
47
+ /**
48
+ * namespace-block--modifier
49
+ *
50
+ * @author chitanda
51
+ * @date 2022-09-06 12:09:37
52
+ * @param {string} [modifier]
53
+ * @return {*} {string}
54
+ */
55
+ m(modifier?: string): string;
56
+ /**
57
+ * namespace-block-blockSuffix__element
58
+ *
59
+ * @author chitanda
60
+ * @date 2022-09-06 12:09:52
61
+ * @param {string} [blockSuffix]
62
+ * @param {string} [element]
63
+ * @return {*} {string}
64
+ */
65
+ be(blockSuffix?: string, element?: string): string;
66
+ /**
67
+ * namespace-block__element--modifier
68
+ *
69
+ * @author chitanda
70
+ * @date 2022-09-06 12:09:19
71
+ * @param {string} [element]
72
+ * @param {string} [modifier]
73
+ * @return {*} {string}
74
+ */
75
+ em(element?: string, modifier?: string): string;
76
+ /**
77
+ * namespace-block-blockSuffix--modifier
78
+ *
79
+ * @author chitanda
80
+ * @date 2022-09-06 12:09:59
81
+ * @param {string} [blockSuffix]
82
+ * @param {string} [modifier]
83
+ * @return {*} {string}
84
+ */
85
+ bm(blockSuffix?: string, modifier?: string): string;
86
+ /**
87
+ * namespace-block-blockSuffix__element--modifier
88
+ *
89
+ * @author chitanda
90
+ * @date 2022-09-06 12:09:37
91
+ * @param {string} [blockSuffix]
92
+ * @param {string} [element]
93
+ * @param {string} [modifier]
94
+ * @return {*} {string}
95
+ */
96
+ bem(blockSuffix?: string, element?: string, modifier?: string): string;
97
+ /**
98
+ * 返回状态 class
99
+ *
100
+ * is('loading', false) => '';
101
+ * is('loading', true) => 'is-loading';
102
+ *
103
+ * @author chitanda
104
+ * @date 2022-09-06 12:09:57
105
+ * @param {string} name
106
+ * @param {boolean} [state]
107
+ * @return {*} {string}
108
+ */
109
+ is(name: string, state?: boolean): string;
110
+ /**
111
+ * 生成使用到的 css 变量 style 对象
112
+ *
113
+ * @author chitanda
114
+ * @date 2022-09-06 15:09:41
115
+ * @param {Record<string, string>} object
116
+ * @return {*} {Record<string, string>}
117
+ */
118
+ cssVar(object: Record<string, string>): Record<string, string>;
119
+ /**
120
+ * 生成使用到的 css block 变量 style 对象
121
+ *
122
+ * @author chitanda
123
+ * @date 2022-09-06 15:09:03
124
+ * @param {Record<string, string>} object
125
+ * @return {*} {Record<string, string>}
126
+ */
127
+ cssVarBlock(object: Record<string, string>): Record<string, string>;
128
+ /**
129
+ * 生成 css var 变量名称
130
+ *
131
+ * @author chitanda
132
+ * @date 2022-09-06 15:09:21
133
+ * @param {string} name
134
+ * @return {*} {string}
135
+ */
136
+ cssVarName(name: string): string;
137
+ /**
138
+ * 生成块 css var 变量名称
139
+ *
140
+ * @author chitanda
141
+ * @date 2022-09-06 15:09:35
142
+ * @param {string} name
143
+ * @return {*} {string}
144
+ */
145
+ cssVarBlockName(name: string): string;
146
+ }
@@ -0,0 +1,195 @@
1
+ import { STYLE_NAMESPACE_TAG } from '../../constants/index.mjs';
2
+
3
+ "use strict";
4
+ const statePrefix = "is-";
5
+ function _bem(namespace, block, blockSuffix, element, modifier) {
6
+ let cls = `${namespace}-${block}`;
7
+ if (blockSuffix) {
8
+ cls += `-${blockSuffix}`;
9
+ }
10
+ if (element) {
11
+ cls += `__${element}`;
12
+ }
13
+ if (modifier) {
14
+ cls += `--${modifier}`;
15
+ }
16
+ return cls;
17
+ }
18
+ class Namespace {
19
+ /**
20
+ * Creates an instance of Namespace.
21
+ *
22
+ * @author chitanda
23
+ * @date 2022-09-06 12:09:12
24
+ * @param {string} block 当前命名空间的根模块,例如组件的名称
25
+ * @param {string} [namespace] 指定命名空间,未指定使用默认值 gct
26
+ */
27
+ constructor(block, namespace) {
28
+ this.block = block;
29
+ this.namespace = namespace || STYLE_NAMESPACE_TAG;
30
+ }
31
+ /**
32
+ * 命名空间
33
+ *
34
+ * @author chitanda
35
+ * @date 2023-11-03 10:11:31
36
+ * @type {string}
37
+ */
38
+ namespace;
39
+ /**
40
+ * namespace-block
41
+ * namespace-block-blockSuffix
42
+ *
43
+ * @author chitanda
44
+ * @date 2022-09-06 12:09:08
45
+ * @param {string} [blockSuffix='']
46
+ * @return {*} {string}
47
+ */
48
+ b(blockSuffix = "") {
49
+ return _bem(this.namespace, this.block, blockSuffix, "", "");
50
+ }
51
+ /**
52
+ * namespace-block__element
53
+ *
54
+ * @author chitanda
55
+ * @date 2022-09-06 12:09:48
56
+ * @param {string} [element]
57
+ * @return {*} {string}
58
+ */
59
+ e(element) {
60
+ return element ? _bem(this.namespace, this.block, "", element, "") : "";
61
+ }
62
+ /**
63
+ * namespace-block--modifier
64
+ *
65
+ * @author chitanda
66
+ * @date 2022-09-06 12:09:37
67
+ * @param {string} [modifier]
68
+ * @return {*} {string}
69
+ */
70
+ m(modifier) {
71
+ return modifier ? _bem(this.namespace, this.block, "", "", modifier) : "";
72
+ }
73
+ /**
74
+ * namespace-block-blockSuffix__element
75
+ *
76
+ * @author chitanda
77
+ * @date 2022-09-06 12:09:52
78
+ * @param {string} [blockSuffix]
79
+ * @param {string} [element]
80
+ * @return {*} {string}
81
+ */
82
+ be(blockSuffix, element) {
83
+ return blockSuffix && element ? _bem(this.namespace, this.block, blockSuffix, element, "") : "";
84
+ }
85
+ /**
86
+ * namespace-block__element--modifier
87
+ *
88
+ * @author chitanda
89
+ * @date 2022-09-06 12:09:19
90
+ * @param {string} [element]
91
+ * @param {string} [modifier]
92
+ * @return {*} {string}
93
+ */
94
+ em(element, modifier) {
95
+ return element && modifier ? _bem(this.namespace, this.block, "", element, modifier) : "";
96
+ }
97
+ /**
98
+ * namespace-block-blockSuffix--modifier
99
+ *
100
+ * @author chitanda
101
+ * @date 2022-09-06 12:09:59
102
+ * @param {string} [blockSuffix]
103
+ * @param {string} [modifier]
104
+ * @return {*} {string}
105
+ */
106
+ bm(blockSuffix, modifier) {
107
+ return blockSuffix && modifier ? _bem(this.namespace, this.block, blockSuffix, "", modifier) : "";
108
+ }
109
+ /**
110
+ * namespace-block-blockSuffix__element--modifier
111
+ *
112
+ * @author chitanda
113
+ * @date 2022-09-06 12:09:37
114
+ * @param {string} [blockSuffix]
115
+ * @param {string} [element]
116
+ * @param {string} [modifier]
117
+ * @return {*} {string}
118
+ */
119
+ bem(blockSuffix, element, modifier) {
120
+ return blockSuffix && element && modifier ? _bem(this.namespace, this.block, blockSuffix, element, modifier) : "";
121
+ }
122
+ /**
123
+ * 返回状态 class
124
+ *
125
+ * is('loading', false) => '';
126
+ * is('loading', true) => 'is-loading';
127
+ *
128
+ * @author chitanda
129
+ * @date 2022-09-06 12:09:57
130
+ * @param {string} name
131
+ * @param {boolean} [state]
132
+ * @return {*} {string}
133
+ */
134
+ is(name, state) {
135
+ return name && state ? `${statePrefix}${name}` : "";
136
+ }
137
+ /**
138
+ * 生成使用到的 css 变量 style 对象
139
+ *
140
+ * @author chitanda
141
+ * @date 2022-09-06 15:09:41
142
+ * @param {Record<string, string>} object
143
+ * @return {*} {Record<string, string>}
144
+ */
145
+ cssVar(object) {
146
+ const styles = {};
147
+ for (const key in object) {
148
+ if (object[key]) {
149
+ styles[this.cssVarName(key)] = object[key];
150
+ }
151
+ }
152
+ return styles;
153
+ }
154
+ /**
155
+ * 生成使用到的 css block 变量 style 对象
156
+ *
157
+ * @author chitanda
158
+ * @date 2022-09-06 15:09:03
159
+ * @param {Record<string, string>} object
160
+ * @return {*} {Record<string, string>}
161
+ */
162
+ cssVarBlock(object) {
163
+ const styles = {};
164
+ for (const key in object) {
165
+ if (object[key]) {
166
+ styles[this.cssVarBlockName(key)] = object[key];
167
+ }
168
+ }
169
+ return styles;
170
+ }
171
+ /**
172
+ * 生成 css var 变量名称
173
+ *
174
+ * @author chitanda
175
+ * @date 2022-09-06 15:09:21
176
+ * @param {string} name
177
+ * @return {*} {string}
178
+ */
179
+ cssVarName(name) {
180
+ return `--${this.namespace}-${name}`;
181
+ }
182
+ /**
183
+ * 生成块 css var 变量名称
184
+ *
185
+ * @author chitanda
186
+ * @date 2022-09-06 15:09:35
187
+ * @param {string} name
188
+ * @return {*} {string}
189
+ */
190
+ cssVarBlockName(name) {
191
+ return `--${this.namespace}-${this.block}-${name}`;
192
+ }
193
+ }
194
+
195
+ export { Namespace };
package/package.json CHANGED
@@ -1,23 +1,22 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "0.0.1-dev.0",
3
+ "version": "0.0.1-dev.5",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
- "main": "dist/index.cjs",
6
+ "main": "dist/index.min.cjs",
7
7
  "module": "es/index.mjs",
8
8
  "types": "es/index.d.ts",
9
- "system": "dist/core.system.js",
9
+ "system": "dist/index.system.min.js",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./es/index.d.ts",
13
13
  "import": "./es/index.mjs",
14
- "require": "./dist/index.cjs"
14
+ "require": "./dist/index.min.cjs"
15
15
  }
16
16
  },
17
17
  "files": [
18
18
  "dist",
19
19
  "es",
20
- "lib",
21
20
  "CHANGELOG.md",
22
21
  "README.md"
23
22
  ],
@@ -45,9 +44,10 @@
45
44
  "vue": "^3.5.13"
46
45
  },
47
46
  "devDependencies": {
48
- "@gct-paas/cli": "0.0.1-dev.0"
47
+ "@gct-paas/cli": "0.0.1-dev.5"
49
48
  },
50
49
  "peerDependencies": {
51
- "vue":"^3.x"
52
- }
50
+ "vue": "^3.x"
51
+ },
52
+ "gitHead": "2466aa73804b93fcc773880a05d57eb914bf26fb"
53
53
  }
package/dist/core.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(){console.log("Hello World!")}exports.run=o;
@@ -1 +0,0 @@
1
- System.register([],function(e,o){"use strict";return{execute:function(){e("run",n);function n(){console.log("Hello World!")}}}});