@gem-sdk/system 2.0.0-staging.711 → 3.0.0
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/cjs/component/createAttr.js +1 -12
- package/dist/cjs/component/createClass.js +1 -37
- package/dist/cjs/component/createContent.js +1 -19
- package/dist/cjs/component/createStateOrContext.js +1 -8
- package/dist/cjs/component/createStyle.js +1 -25
- package/dist/cjs/component/template.js +1 -93
- package/dist/cjs/component/utils/toCamelCaseKeys.js +1 -15
- package/dist/cjs/index.js +1 -29
- package/dist/esm/component/createAttr.js +1 -10
- package/dist/esm/component/createClass.js +1 -35
- package/dist/esm/component/createContent.js +1 -17
- package/dist/esm/component/createStateOrContext.js +1 -6
- package/dist/esm/component/createStyle.js +1 -22
- package/dist/esm/component/template.js +1 -85
- package/dist/esm/component/utils/toCamelCaseKeys.js +1 -13
- package/dist/esm/index.js +1 -12
- package/package.json +2 -2
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const createAttr = (obj)=>{
|
|
4
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
5
|
-
console.error('Expected an object as input.');
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
!process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
9
|
-
return obj;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.createAttr = createAttr;
|
|
1
|
+
"use strict";const createAttr=e=>{if("object"!=typeof e||null===e){console.error("Expected an object as input.");return}return process.env.APP_ENV&&"development"!==process.env.APP_ENV&&process.env.APP_ENV,e};exports.createAttr=createAttr;
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function toVal(mix) {
|
|
4
|
-
if (typeof mix === 'string') {
|
|
5
|
-
return mix;
|
|
6
|
-
} else if (typeof mix === 'object' && mix !== null) {
|
|
7
|
-
return Object.keys(mix).filter((key)=>mix[key]).join(' ');
|
|
8
|
-
} else {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function cls(...classes) {
|
|
13
|
-
return classes.map(toVal).filter(Boolean).join(' ');
|
|
14
|
-
}
|
|
15
|
-
const createClass = (obj)=>{
|
|
16
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
17
|
-
console.error('Expected an object as input.');
|
|
18
|
-
return '';
|
|
19
|
-
}
|
|
20
|
-
// const validateClass = (obj: any) => {
|
|
21
|
-
// for (const className in obj) {
|
|
22
|
-
// if (className.length > 30) {
|
|
23
|
-
// console.error(`Class name "${className}" exceeds the maximum length of 30 characters.`);
|
|
24
|
-
// }
|
|
25
|
-
// if (className.includes(' ')) {
|
|
26
|
-
// console.error(`Class name "${className}" should not contain spaces.`);
|
|
27
|
-
// }
|
|
28
|
-
// if (className !== className.toLowerCase()) {
|
|
29
|
-
// console.error(`Class name "${className}" should be in lowercase.`);
|
|
30
|
-
// }
|
|
31
|
-
// }
|
|
32
|
-
// };
|
|
33
|
-
!process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
34
|
-
return cls(obj);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
exports.createClass = createClass;
|
|
1
|
+
"use strict";function toVal(e){return"string"==typeof e?e:"object"==typeof e&&null!==e&&Object.keys(e).filter(t=>e[t]).join(" ")}function cls(...e){return e.map(toVal).filter(Boolean).join(" ")}const createClass=e=>"object"!=typeof e||null===e?(console.error("Expected an object as input."),""):(process.env.APP_ENV&&"development"!==process.env.APP_ENV&&process.env.APP_ENV,cls(e));exports.createClass=createClass;
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const createContent = (content)=>{
|
|
4
|
-
// Check if content is a string
|
|
5
|
-
if (typeof content !== 'string') {
|
|
6
|
-
console.error('Invalid content type: Content must be a string.');
|
|
7
|
-
return '';
|
|
8
|
-
}
|
|
9
|
-
// Regex to match {{}} pattern with only letters inside, e.g., {{Hello}}
|
|
10
|
-
const invalidPattern = /\{\{(?:[A-Z]+|[a-z]+)\}\}/g;
|
|
11
|
-
// Check if content contains any invalid patterns
|
|
12
|
-
if (invalidPattern.test(content)) {
|
|
13
|
-
console.error('Invalid content format: "{{}}" placeholders must not contain only letters, e.g., "{{Hello}}".');
|
|
14
|
-
return '';
|
|
15
|
-
}
|
|
16
|
-
return content;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.createContent = createContent;
|
|
1
|
+
"use strict";const createContent=t=>{if("string"!=typeof t)return console.error("Invalid content type: Content must be a string."),"";let e=/\{\{(?:[A-Z]+|[a-z]+)\}\}/g;return e.test(t)?(console.error('Invalid content format: "{{}}" placeholders must not contain only letters, e.g., "{{Hello}}".'),""):t};exports.createContent=createContent;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const createStateOrContext = (obj)=>{
|
|
4
|
-
!process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
5
|
-
return obj;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
exports.createStateOrContext = createStateOrContext;
|
|
1
|
+
"use strict";const createStateOrContext=e=>(process.env.APP_ENV&&"development"!==process.env.APP_ENV&&process.env.APP_ENV,e);exports.createStateOrContext=createStateOrContext;
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var toCamelCaseKeys = require('./utils/toCamelCaseKeys.js');
|
|
4
|
-
|
|
5
|
-
const clearUndefineValue = (obj)=>{
|
|
6
|
-
for(const key in obj){
|
|
7
|
-
if (obj[key] === undefined || obj[key] === null || obj[key] === '') {
|
|
8
|
-
delete obj[key];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const createStyle = (obj)=>{
|
|
13
|
-
const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
14
|
-
if (isDevOrStaging) {
|
|
15
|
-
clearUndefineValue(obj);
|
|
16
|
-
// validateStyle(obj);
|
|
17
|
-
}
|
|
18
|
-
return obj;
|
|
19
|
-
};
|
|
20
|
-
const createStyleReact = (obj)=>{
|
|
21
|
-
return toCamelCaseKeys.toCamelCaseKeys(createStyle(obj));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.createStyle = createStyle;
|
|
25
|
-
exports.createStyleReact = createStyleReact;
|
|
1
|
+
"use strict";var toCamelCaseKeys=require("./utils/toCamelCaseKeys.js");const clearUndefineValue=e=>{for(let t in e)(void 0===e[t]||null===e[t]||""===e[t])&&delete e[t]},createStyle=e=>{let t=!process.env.APP_ENV||"development"===process.env.APP_ENV||"staging"===process.env.APP_ENV;return t&&clearUndefineValue(e),e},createStyleReact=e=>toCamelCaseKeys.toCamelCaseKeys(createStyle(e));exports.createStyle=createStyle,exports.createStyleReact=createStyleReact;
|
|
@@ -1,93 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
|
|
5
|
-
Liquid in liquid.ts
|
|
6
|
-
<div>
|
|
7
|
-
Liquid(`
|
|
8
|
-
{%-if productSelectedVariant == empty or productSelectedVariant == null -%}
|
|
9
|
-
{%- assign productSelectedVariant = product.selected_or_first_available_variant -%}
|
|
10
|
-
{%- endif -%}
|
|
11
|
-
{%-if variant == empty or variant == null -%}
|
|
12
|
-
{%- assign variant = product.selected_or_first_available_variant -%}
|
|
13
|
-
{%- endif -%}
|
|
14
|
-
`)
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
IF in tsx & liquid.ts
|
|
18
|
-
<div {...attrs}>
|
|
19
|
-
{
|
|
20
|
-
If(product.id != "", (
|
|
21
|
-
<label className={classes} style={styles}>
|
|
22
|
-
{content}
|
|
23
|
-
</label>
|
|
24
|
-
), (
|
|
25
|
-
<label className={classes} style={styles}>
|
|
26
|
-
{content}
|
|
27
|
-
</label>
|
|
28
|
-
))
|
|
29
|
-
}
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
LiquidIF in liquid.ts
|
|
33
|
-
<div {...attrs}>
|
|
34
|
-
{
|
|
35
|
-
LiquidIf("product.quanity > 0", `
|
|
36
|
-
<label className={classes} style={styles}>
|
|
37
|
-
{content}
|
|
38
|
-
</label>
|
|
39
|
-
`, `
|
|
40
|
-
<label className={classes} style={styles}>
|
|
41
|
-
{content}
|
|
42
|
-
</label>
|
|
43
|
-
`)
|
|
44
|
-
}
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
For in tsx & liquid.ts
|
|
48
|
-
{
|
|
49
|
-
For(numbers, (item, index) => (
|
|
50
|
-
<div key={index}>
|
|
51
|
-
{index + 1}: Số {item}
|
|
52
|
-
</div>
|
|
53
|
-
))
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
LiquidFor in tsx & liquid.ts
|
|
57
|
-
{
|
|
58
|
-
LiquidFor('(item, index) in items', `
|
|
59
|
-
<div key="{{ forloop.index }}">
|
|
60
|
-
{{ forloop.index + 1}}: Số {{item}}
|
|
61
|
-
</div>
|
|
62
|
-
`)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
*/ const Liquid = (code)=>{
|
|
66
|
-
return code;
|
|
67
|
-
};
|
|
68
|
-
const For = (items, renderFn)=>{
|
|
69
|
-
return items.map((item, index)=>renderFn(item, index));
|
|
70
|
-
};
|
|
71
|
-
const LiquidFor = (c, t)=>{
|
|
72
|
-
return `{% for ${c} %}${typeof t === 'string' ? t : t()}{% endfor %}`;
|
|
73
|
-
};
|
|
74
|
-
const If = (condition, trueResult, falseResult)=>{
|
|
75
|
-
if (condition) {
|
|
76
|
-
// Trả về kết quả đúng nếu điều kiện là true
|
|
77
|
-
return typeof trueResult === 'function' ? trueResult() : trueResult;
|
|
78
|
-
} else {
|
|
79
|
-
// Trả về kết quả sai nếu điều kiện là false
|
|
80
|
-
return falseResult ? typeof falseResult === 'function' ? falseResult() : falseResult : ''; // Nếu không có falseResult, trả về null
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const LiquidIf = (c, t, f)=>`{% if ${c} %}${typeof t === 'string' ? t : t()}${f ? `{% else %}${typeof f === 'string' ? f : f?.()}` : ''}{% endif %}`;
|
|
84
|
-
const Unless = (condition, trueResult, falseResult)=>If(!condition, trueResult, falseResult);
|
|
85
|
-
const LiquidUnless = (c, t, f)=>`{% unless ${c} %}${typeof t === 'string' ? t : t()}${f ? `{% else %}${typeof f === 'string' ? f : f?.()}` : ''}{% endunless %}`;
|
|
86
|
-
|
|
87
|
-
exports.For = For;
|
|
88
|
-
exports.If = If;
|
|
89
|
-
exports.Liquid = Liquid;
|
|
90
|
-
exports.LiquidFor = LiquidFor;
|
|
91
|
-
exports.LiquidIf = LiquidIf;
|
|
92
|
-
exports.LiquidUnless = LiquidUnless;
|
|
93
|
-
exports.Unless = Unless;
|
|
1
|
+
"use strict";const Liquid=i=>i,For=(i,s)=>i.map((i,e)=>s(i,e)),LiquidFor=(i,s)=>`{% for ${i} %}${"string"==typeof s?s:s()}{% endfor %}`,If=(i,s,e)=>i?"function"==typeof s?s():s:e?"function"==typeof e?e():e:"",LiquidIf=(i,s,e)=>`{% if ${i} %}${"string"==typeof s?s:s()}${e?`{% else %}${"string"==typeof e?e:e?.()}`:""}{% endif %}`,Unless=(i,s,e)=>If(!i,s,e),LiquidUnless=(i,s,e)=>`{% unless ${i} %}${"string"==typeof s?s:s()}${e?`{% else %}${"string"==typeof e?e:e?.()}`:""}{% endunless %}`;exports.For=For,exports.If=If,exports.Liquid=Liquid,exports.LiquidFor=LiquidFor,exports.LiquidIf=LiquidIf,exports.LiquidUnless=LiquidUnless,exports.Unless=Unless;
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const toCamelCaseKeys = (obj)=>{
|
|
4
|
-
const newObj = {};
|
|
5
|
-
for(const key in obj){
|
|
6
|
-
const value = obj[key];
|
|
7
|
-
// If the key starts with "--", keep it as is
|
|
8
|
-
const newKey = key.startsWith('--') ? key : key.replace(/-([a-z])/g, (_, char)=>char.toUpperCase());
|
|
9
|
-
// Recursively apply to nested objects
|
|
10
|
-
newObj[newKey] = typeof value === 'object' && value !== null && !Array.isArray(value) ? toCamelCaseKeys(value) : value;
|
|
11
|
-
}
|
|
12
|
-
return newObj;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
exports.toCamelCaseKeys = toCamelCaseKeys;
|
|
1
|
+
"use strict";const toCamelCaseKeys=e=>{let t={};for(let s in e){let a=e[s],r=s.startsWith("--")?s:s.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());t[r]="object"!=typeof a||null===a||Array.isArray(a)?a:toCamelCaseKeys(a)}return t};exports.toCamelCaseKeys=toCamelCaseKeys;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var createAttr = require('./component/createAttr.js');
|
|
4
|
-
var createStyle = require('./component/createStyle.js');
|
|
5
|
-
var createContent = require('./component/createContent.js');
|
|
6
|
-
var createClass = require('./component/createClass.js');
|
|
7
|
-
var createStateOrContext = require('./component/createStateOrContext.js');
|
|
8
|
-
var template = require('./component/template.js');
|
|
9
|
-
|
|
10
|
-
const createAttrReact = createAttr.createAttr;
|
|
11
|
-
const createContentReact = createContent.createContent;
|
|
12
|
-
const createClassReact = createClass.createClass;
|
|
13
|
-
|
|
14
|
-
exports.createAttr = createAttr.createAttr;
|
|
15
|
-
exports.createStyle = createStyle.createStyle;
|
|
16
|
-
exports.createStyleReact = createStyle.createStyleReact;
|
|
17
|
-
exports.createContent = createContent.createContent;
|
|
18
|
-
exports.createClass = createClass.createClass;
|
|
19
|
-
exports.createStateOrContext = createStateOrContext.createStateOrContext;
|
|
20
|
-
exports.For = template.For;
|
|
21
|
-
exports.If = template.If;
|
|
22
|
-
exports.Liquid = template.Liquid;
|
|
23
|
-
exports.LiquidFor = template.LiquidFor;
|
|
24
|
-
exports.LiquidIf = template.LiquidIf;
|
|
25
|
-
exports.LiquidUnless = template.LiquidUnless;
|
|
26
|
-
exports.Unless = template.Unless;
|
|
27
|
-
exports.createAttrReact = createAttrReact;
|
|
28
|
-
exports.createClassReact = createClassReact;
|
|
29
|
-
exports.createContentReact = createContentReact;
|
|
1
|
+
"use strict";var createAttr=require("./component/createAttr.js"),createStyle=require("./component/createStyle.js"),createContent=require("./component/createContent.js"),createClass=require("./component/createClass.js"),createStateOrContext=require("./component/createStateOrContext.js"),template=require("./component/template.js");const createAttrReact=createAttr.createAttr,createContentReact=createContent.createContent,createClassReact=createClass.createClass;exports.createAttr=createAttr.createAttr,exports.createStyle=createStyle.createStyle,exports.createStyleReact=createStyle.createStyleReact,exports.createContent=createContent.createContent,exports.createClass=createClass.createClass,exports.createStateOrContext=createStateOrContext.createStateOrContext,exports.For=template.For,exports.If=template.If,exports.Liquid=template.Liquid,exports.LiquidFor=template.LiquidFor,exports.LiquidIf=template.LiquidIf,exports.LiquidUnless=template.LiquidUnless,exports.Unless=template.Unless,exports.createAttrReact=createAttrReact,exports.createClassReact=createClassReact,exports.createContentReact=createContentReact;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
3
|
-
console.error('Expected an object as input.');
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
!process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
7
|
-
return obj;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { createAttr };
|
|
1
|
+
let createAttr=e=>{if("object"!=typeof e||null===e){console.error("Expected an object as input.");return}return process.env.APP_ENV&&"development"!==process.env.APP_ENV&&process.env.APP_ENV,e};export{createAttr};
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
function toVal(
|
|
2
|
-
if (typeof mix === 'string') {
|
|
3
|
-
return mix;
|
|
4
|
-
} else if (typeof mix === 'object' && mix !== null) {
|
|
5
|
-
return Object.keys(mix).filter((key)=>mix[key]).join(' ');
|
|
6
|
-
} else {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function cls(...classes) {
|
|
11
|
-
return classes.map(toVal).filter(Boolean).join(' ');
|
|
12
|
-
}
|
|
13
|
-
const createClass = (obj)=>{
|
|
14
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
15
|
-
console.error('Expected an object as input.');
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
// const validateClass = (obj: any) => {
|
|
19
|
-
// for (const className in obj) {
|
|
20
|
-
// if (className.length > 30) {
|
|
21
|
-
// console.error(`Class name "${className}" exceeds the maximum length of 30 characters.`);
|
|
22
|
-
// }
|
|
23
|
-
// if (className.includes(' ')) {
|
|
24
|
-
// console.error(`Class name "${className}" should not contain spaces.`);
|
|
25
|
-
// }
|
|
26
|
-
// if (className !== className.toLowerCase()) {
|
|
27
|
-
// console.error(`Class name "${className}" should be in lowercase.`);
|
|
28
|
-
// }
|
|
29
|
-
// }
|
|
30
|
-
// };
|
|
31
|
-
!process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
32
|
-
return cls(obj);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { createClass };
|
|
1
|
+
function toVal(e){return"string"==typeof e?e:"object"==typeof e&&null!==e&&Object.keys(e).filter(t=>e[t]).join(" ")}function cls(...e){return e.map(toVal).filter(Boolean).join(" ")}let createClass=e=>"object"!=typeof e||null===e?(console.error("Expected an object as input."),""):(process.env.APP_ENV&&"development"!==process.env.APP_ENV&&process.env.APP_ENV,cls(e));export{createClass};
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// Check if content is a string
|
|
3
|
-
if (typeof content !== 'string') {
|
|
4
|
-
console.error('Invalid content type: Content must be a string.');
|
|
5
|
-
return '';
|
|
6
|
-
}
|
|
7
|
-
// Regex to match {{}} pattern with only letters inside, e.g., {{Hello}}
|
|
8
|
-
const invalidPattern = /\{\{(?:[A-Z]+|[a-z]+)\}\}/g;
|
|
9
|
-
// Check if content contains any invalid patterns
|
|
10
|
-
if (invalidPattern.test(content)) {
|
|
11
|
-
console.error('Invalid content format: "{{}}" placeholders must not contain only letters, e.g., "{{Hello}}".');
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
return content;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { createContent };
|
|
1
|
+
let createContent=t=>{if("string"!=typeof t)return console.error("Invalid content type: Content must be a string."),"";let e=/\{\{(?:[A-Z]+|[a-z]+)\}\}/g;return e.test(t)?(console.error('Invalid content format: "{{}}" placeholders must not contain only letters, e.g., "{{Hello}}".'),""):t};export{createContent};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
!process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
3
|
-
return obj;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export { createStateOrContext };
|
|
1
|
+
let createStateOrContext=e=>(process.env.APP_ENV&&"development"!==process.env.APP_ENV&&process.env.APP_ENV,e);export{createStateOrContext};
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const clearUndefineValue = (obj)=>{
|
|
4
|
-
for(const key in obj){
|
|
5
|
-
if (obj[key] === undefined || obj[key] === null || obj[key] === '') {
|
|
6
|
-
delete obj[key];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const createStyle = (obj)=>{
|
|
11
|
-
const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
|
|
12
|
-
if (isDevOrStaging) {
|
|
13
|
-
clearUndefineValue(obj);
|
|
14
|
-
// validateStyle(obj);
|
|
15
|
-
}
|
|
16
|
-
return obj;
|
|
17
|
-
};
|
|
18
|
-
const createStyleReact = (obj)=>{
|
|
19
|
-
return toCamelCaseKeys(createStyle(obj));
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { createStyle, createStyleReact };
|
|
1
|
+
import{toCamelCaseKeys as e}from"./utils/toCamelCaseKeys.js";let clearUndefineValue=e=>{for(let t in e)(void 0===e[t]||null===e[t]||""===e[t])&&delete e[t]},createStyle=e=>{let t=!process.env.APP_ENV||"development"===process.env.APP_ENV||"staging"===process.env.APP_ENV;return t&&clearUndefineValue(e),e},createStyleReact=t=>e(createStyle(t));export{createStyle,createStyleReact};
|
|
@@ -1,85 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Liquid in liquid.ts
|
|
4
|
-
<div>
|
|
5
|
-
Liquid(`
|
|
6
|
-
{%-if productSelectedVariant == empty or productSelectedVariant == null -%}
|
|
7
|
-
{%- assign productSelectedVariant = product.selected_or_first_available_variant -%}
|
|
8
|
-
{%- endif -%}
|
|
9
|
-
{%-if variant == empty or variant == null -%}
|
|
10
|
-
{%- assign variant = product.selected_or_first_available_variant -%}
|
|
11
|
-
{%- endif -%}
|
|
12
|
-
`)
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
IF in tsx & liquid.ts
|
|
16
|
-
<div {...attrs}>
|
|
17
|
-
{
|
|
18
|
-
If(product.id != "", (
|
|
19
|
-
<label className={classes} style={styles}>
|
|
20
|
-
{content}
|
|
21
|
-
</label>
|
|
22
|
-
), (
|
|
23
|
-
<label className={classes} style={styles}>
|
|
24
|
-
{content}
|
|
25
|
-
</label>
|
|
26
|
-
))
|
|
27
|
-
}
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
LiquidIF in liquid.ts
|
|
31
|
-
<div {...attrs}>
|
|
32
|
-
{
|
|
33
|
-
LiquidIf("product.quanity > 0", `
|
|
34
|
-
<label className={classes} style={styles}>
|
|
35
|
-
{content}
|
|
36
|
-
</label>
|
|
37
|
-
`, `
|
|
38
|
-
<label className={classes} style={styles}>
|
|
39
|
-
{content}
|
|
40
|
-
</label>
|
|
41
|
-
`)
|
|
42
|
-
}
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
For in tsx & liquid.ts
|
|
46
|
-
{
|
|
47
|
-
For(numbers, (item, index) => (
|
|
48
|
-
<div key={index}>
|
|
49
|
-
{index + 1}: Số {item}
|
|
50
|
-
</div>
|
|
51
|
-
))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
LiquidFor in tsx & liquid.ts
|
|
55
|
-
{
|
|
56
|
-
LiquidFor('(item, index) in items', `
|
|
57
|
-
<div key="{{ forloop.index }}">
|
|
58
|
-
{{ forloop.index + 1}}: Số {{item}}
|
|
59
|
-
</div>
|
|
60
|
-
`)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
*/ const Liquid = (code)=>{
|
|
64
|
-
return code;
|
|
65
|
-
};
|
|
66
|
-
const For = (items, renderFn)=>{
|
|
67
|
-
return items.map((item, index)=>renderFn(item, index));
|
|
68
|
-
};
|
|
69
|
-
const LiquidFor = (c, t)=>{
|
|
70
|
-
return `{% for ${c} %}${typeof t === 'string' ? t : t()}{% endfor %}`;
|
|
71
|
-
};
|
|
72
|
-
const If = (condition, trueResult, falseResult)=>{
|
|
73
|
-
if (condition) {
|
|
74
|
-
// Trả về kết quả đúng nếu điều kiện là true
|
|
75
|
-
return typeof trueResult === 'function' ? trueResult() : trueResult;
|
|
76
|
-
} else {
|
|
77
|
-
// Trả về kết quả sai nếu điều kiện là false
|
|
78
|
-
return falseResult ? typeof falseResult === 'function' ? falseResult() : falseResult : ''; // Nếu không có falseResult, trả về null
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const LiquidIf = (c, t, f)=>`{% if ${c} %}${typeof t === 'string' ? t : t()}${f ? `{% else %}${typeof f === 'string' ? f : f?.()}` : ''}{% endif %}`;
|
|
82
|
-
const Unless = (condition, trueResult, falseResult)=>If(!condition, trueResult, falseResult);
|
|
83
|
-
const LiquidUnless = (c, t, f)=>`{% unless ${c} %}${typeof t === 'string' ? t : t()}${f ? `{% else %}${typeof f === 'string' ? f : f?.()}` : ''}{% endunless %}`;
|
|
84
|
-
|
|
85
|
-
export { For, If, Liquid, LiquidFor, LiquidIf, LiquidUnless, Unless };
|
|
1
|
+
let Liquid=i=>i,For=(i,e)=>i.map((i,s)=>e(i,s)),LiquidFor=(i,e)=>`{% for ${i} %}${"string"==typeof e?e:e()}{% endfor %}`,If=(i,e,s)=>i?"function"==typeof e?e():e:s?"function"==typeof s?s():s:"",LiquidIf=(i,e,s)=>`{% if ${i} %}${"string"==typeof e?e:e()}${s?`{% else %}${"string"==typeof s?s:s?.()}`:""}{% endif %}`,Unless=(i,e,s)=>If(!i,e,s),LiquidUnless=(i,e,s)=>`{% unless ${i} %}${"string"==typeof e?e:e()}${s?`{% else %}${"string"==typeof s?s:s?.()}`:""}{% endunless %}`;export{For,If,Liquid,LiquidFor,LiquidIf,LiquidUnless,Unless};
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const newObj = {};
|
|
3
|
-
for(const key in obj){
|
|
4
|
-
const value = obj[key];
|
|
5
|
-
// If the key starts with "--", keep it as is
|
|
6
|
-
const newKey = key.startsWith('--') ? key : key.replace(/-([a-z])/g, (_, char)=>char.toUpperCase());
|
|
7
|
-
// Recursively apply to nested objects
|
|
8
|
-
newObj[newKey] = typeof value === 'object' && value !== null && !Array.isArray(value) ? toCamelCaseKeys(value) : value;
|
|
9
|
-
}
|
|
10
|
-
return newObj;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { toCamelCaseKeys };
|
|
1
|
+
let toCamelCaseKeys=e=>{let t={};for(let a in e){let r=e[a],l=a.startsWith("--")?a:a.replace(/-([a-z])/g,(e,t)=>t.toUpperCase());t[l]="object"!=typeof r||null===r||Array.isArray(r)?r:toCamelCaseKeys(r)}return t};export{toCamelCaseKeys};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { createStyle, createStyleReact } from './component/createStyle.js';
|
|
3
|
-
import { createContent } from './component/createContent.js';
|
|
4
|
-
import { createClass } from './component/createClass.js';
|
|
5
|
-
export { createStateOrContext } from './component/createStateOrContext.js';
|
|
6
|
-
export { For, If, Liquid, LiquidFor, LiquidIf, LiquidUnless, Unless } from './component/template.js';
|
|
7
|
-
|
|
8
|
-
const createAttrReact = createAttr;
|
|
9
|
-
const createContentReact = createContent;
|
|
10
|
-
const createClassReact = createClass;
|
|
11
|
-
|
|
12
|
-
export { createAttr, createAttrReact, createClass, createClassReact, createContent, createContentReact };
|
|
1
|
+
import{createAttr as e}from"./component/createAttr.js";export{createStyle,createStyleReact}from"./component/createStyle.js";import{createContent as t}from"./component/createContent.js";import{createClass as r}from"./component/createClass.js";export{createStateOrContext}from"./component/createStateOrContext.js";export{For,If,Liquid,LiquidFor,LiquidIf,LiquidUnless,Unless}from"./component/template.js";let createAttrReact=e,createContentReact=t,createClassReact=r;export{e as createAttr,createAttrReact,r as createClass,createClassReact,t as createContent,createContentReact};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/system",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@gem-sdk/core": "
|
|
24
|
+
"@gem-sdk/core": "3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"module": "dist/esm/index.js",
|
|
27
27
|
"types": "dist/types/index.d.ts",
|