@gem-sdk/system 1.58.0-dev.148 → 2.0.0-dev.1082

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.
@@ -1,34 +1 @@
1
- 'use strict';
2
-
3
- const createAttr = (obj)=>{
4
- if (typeof obj !== 'object' || obj === null) {
5
- console.error('Expected an object as input.');
6
- return;
7
- }
8
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
9
- if (isDevOrStaging) {
10
- for(const key in obj){
11
- const value = obj[key];
12
- // 1. Check if the key starts with "data-gp-"
13
- if (!key.startsWith('data-gp-')) {
14
- console.error(`Invalid attribute key: "${key}". Must start with "data-gp-".`);
15
- }
16
- // 2. Check if the key contains uppercase letters
17
- if (key !== key.toLowerCase()) {
18
- console.error(`Invalid attribute key: "${key}". Must not contain uppercase letters.`);
19
- }
20
- // 3. Check if the value is an object (nested object check)
21
- if (typeof value === 'object' && value !== null) {
22
- console.error(`Invalid nested attribute for key "${key}". Nested objects are not supported.`);
23
- }
24
- // 4. Check if the value is a valid type (string or number)
25
- const isValidType = typeof value === 'string' || typeof value === 'number';
26
- if (!isValidType) {
27
- console.error(`Invalid attribute value for key "${key}": ${value}. Must be a string or number.`);
28
- }
29
- }
30
- }
31
- return obj;
32
- };
33
-
34
- 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,38 +1 @@
1
- 'use strict';
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 isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
21
- if (isDevOrStaging) {
22
- // Validate each class name length
23
- for(const className in obj){
24
- if (className.length > 30) {
25
- console.error(`Class name "${className}" exceeds the maximum length of 30 characters.`);
26
- }
27
- if (className.includes(' ')) {
28
- console.error(`Class name "${className}" should not contain spaces.`);
29
- }
30
- if (className !== className.toLowerCase()) {
31
- console.error(`Class name "${className}" should be in lowercase.`);
32
- }
33
- }
34
- }
35
- return cls(obj);
36
- };
37
-
38
- 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
- 'use strict';
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-Za-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,55 +1 @@
1
- 'use strict';
2
-
3
- const createStateOrContext = (obj)=>{
4
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
5
- const isValid = (value)=>{
6
- // Ensure value is neither undefined, null, empty string, nor false (except 0)
7
- return value !== undefined && value !== null && value !== '' && value !== false;
8
- };
9
- const validateKey = (key)=>{
10
- // Check key length
11
- if (key.length > 20) {
12
- console.error(`Invalid key "${key}": Key length must not exceed 20 characters.`);
13
- return false;
14
- }
15
- // Ensure no special characters or numbers
16
- const validKeyRegex = /^[a-zA-Z]+$/;
17
- if (!validKeyRegex.test(key)) {
18
- console.error(`Invalid key "${key}": Key must contain only alphabetic characters (no numbers or special characters).`);
19
- return false;
20
- }
21
- // Check camelCase format (should start with lowercase)
22
- const camelCaseRegex = /^[a-z][a-zA-Z]*$/;
23
- if (!camelCaseRegex.test(key)) {
24
- console.error(`Invalid key "${key}": Key must be in camelCase format.`);
25
- return false;
26
- }
27
- return true;
28
- };
29
- const validateObject = (data, depth)=>{
30
- if (depth > 3) {
31
- console.error('Invalid structure: Data must not be nested deeper than 3 levels.');
32
- return false;
33
- }
34
- for(const key in data){
35
- const value = data[key];
36
- // Key validation
37
- if (!validateKey(key)) continue;
38
- // Value validation
39
- if (!isValid(value)) {
40
- console.error(`Invalid value for key "${key}": Value must not be undefined, null, blank, or false.`);
41
- continue;
42
- }
43
- // Recursive check if the value is an object
44
- if (typeof value === 'object' && !Array.isArray(value)) {
45
- validateObject(value, depth + 1);
46
- }
47
- }
48
- };
49
- if (isDevOrStaging) {
50
- validateObject(obj, 1);
51
- }
52
- return obj;
53
- };
54
-
55
- 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,42 +1 @@
1
- 'use strict';
2
-
3
- var toCamelCaseKeys = require('./utils/toCamelCaseKeys.js');
4
-
5
- /**
6
- * Properties to ignore with explanations for each
7
- */ const ignoredProperties = {
8
- ignore: 'This property is not supported in the current styling setup.'
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
- for(const key in obj){
14
- const value = obj[key];
15
- // Check if the property is in the ignored list and log the explanation
16
- if (Object.prototype.hasOwnProperty.call(ignoredProperties, key)) {
17
- console.error(`Ignored property detected: "${key}". ${ignoredProperties[key]}`);
18
- }
19
- // Check for uppercase letters, numbers, and special characters (only allow lowercase letters and "-"
20
- const isValidKey = /^[a-z-]+$/.test(key);
21
- if (!isValidKey) {
22
- console.error(`Invalid key "${key}": Keys must be lowercase letters and may only contain "-".`);
23
- }
24
- // Check for nested objects (only support single-level properties)
25
- if (typeof value === 'object' && value !== null) {
26
- console.error(`Invalid nested object for property "${key}". Nested objects are not supported.`);
27
- }
28
- // Check if the value is a valid type
29
- const isValidType = typeof value === 'string' || typeof value === 'number';
30
- if (!isValidType) {
31
- console.error(`Invalid style value for "${key}": ${value}. Must be a string or number.`);
32
- }
33
- }
34
- }
35
- return obj;
36
- };
37
- const createStyleReact = (obj)=>{
38
- return toCamelCaseKeys.toCamelCaseKeys(createStyle(obj));
39
- };
40
-
41
- exports.createStyle = createStyle;
42
- 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,89 +1 @@
1
- 'use strict';
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 : null; // 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
-
85
- exports.For = For;
86
- exports.If = If;
87
- exports.Liquid = Liquid;
88
- exports.LiquidFor = LiquidFor;
89
- exports.LiquidIf = LiquidIf;
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
- 'use strict';
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,27 +1 @@
1
- 'use strict';
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.createAttrReact = createAttrReact;
26
- exports.createClassReact = createClassReact;
27
- 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,32 +1 @@
1
- const createAttr = (obj)=>{
2
- if (typeof obj !== 'object' || obj === null) {
3
- console.error('Expected an object as input.');
4
- return;
5
- }
6
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
7
- if (isDevOrStaging) {
8
- for(const key in obj){
9
- const value = obj[key];
10
- // 1. Check if the key starts with "data-gp-"
11
- if (!key.startsWith('data-gp-')) {
12
- console.error(`Invalid attribute key: "${key}". Must start with "data-gp-".`);
13
- }
14
- // 2. Check if the key contains uppercase letters
15
- if (key !== key.toLowerCase()) {
16
- console.error(`Invalid attribute key: "${key}". Must not contain uppercase letters.`);
17
- }
18
- // 3. Check if the value is an object (nested object check)
19
- if (typeof value === 'object' && value !== null) {
20
- console.error(`Invalid nested attribute for key "${key}". Nested objects are not supported.`);
21
- }
22
- // 4. Check if the value is a valid type (string or number)
23
- const isValidType = typeof value === 'string' || typeof value === 'number';
24
- if (!isValidType) {
25
- console.error(`Invalid attribute value for key "${key}": ${value}. Must be a string or number.`);
26
- }
27
- }
28
- }
29
- return obj;
30
- };
31
-
32
- 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,36 +1 @@
1
- function toVal(mix) {
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 isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
19
- if (isDevOrStaging) {
20
- // Validate each class name length
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
- return cls(obj);
34
- };
35
-
36
- 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
- const createContent = (content)=>{
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-Za-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,53 +1 @@
1
- const createStateOrContext = (obj)=>{
2
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
3
- const isValid = (value)=>{
4
- // Ensure value is neither undefined, null, empty string, nor false (except 0)
5
- return value !== undefined && value !== null && value !== '' && value !== false;
6
- };
7
- const validateKey = (key)=>{
8
- // Check key length
9
- if (key.length > 20) {
10
- console.error(`Invalid key "${key}": Key length must not exceed 20 characters.`);
11
- return false;
12
- }
13
- // Ensure no special characters or numbers
14
- const validKeyRegex = /^[a-zA-Z]+$/;
15
- if (!validKeyRegex.test(key)) {
16
- console.error(`Invalid key "${key}": Key must contain only alphabetic characters (no numbers or special characters).`);
17
- return false;
18
- }
19
- // Check camelCase format (should start with lowercase)
20
- const camelCaseRegex = /^[a-z][a-zA-Z]*$/;
21
- if (!camelCaseRegex.test(key)) {
22
- console.error(`Invalid key "${key}": Key must be in camelCase format.`);
23
- return false;
24
- }
25
- return true;
26
- };
27
- const validateObject = (data, depth)=>{
28
- if (depth > 3) {
29
- console.error('Invalid structure: Data must not be nested deeper than 3 levels.');
30
- return false;
31
- }
32
- for(const key in data){
33
- const value = data[key];
34
- // Key validation
35
- if (!validateKey(key)) continue;
36
- // Value validation
37
- if (!isValid(value)) {
38
- console.error(`Invalid value for key "${key}": Value must not be undefined, null, blank, or false.`);
39
- continue;
40
- }
41
- // Recursive check if the value is an object
42
- if (typeof value === 'object' && !Array.isArray(value)) {
43
- validateObject(value, depth + 1);
44
- }
45
- }
46
- };
47
- if (isDevOrStaging) {
48
- validateObject(obj, 1);
49
- }
50
- return obj;
51
- };
52
-
53
- export { createStateOrContext };
1
+ let createStateOrContext=e=>(process.env.APP_ENV&&"development"!==process.env.APP_ENV&&process.env.APP_ENV,e);export{createStateOrContext};
@@ -1,39 +1 @@
1
- import { toCamelCaseKeys } from './utils/toCamelCaseKeys.js';
2
-
3
- /**
4
- * Properties to ignore with explanations for each
5
- */ const ignoredProperties = {
6
- ignore: 'This property is not supported in the current styling setup.'
7
- };
8
- const createStyle = (obj)=>{
9
- const isDevOrStaging = !process.env.APP_ENV || process.env.APP_ENV === 'development' || process.env.APP_ENV === 'staging';
10
- if (isDevOrStaging) {
11
- for(const key in obj){
12
- const value = obj[key];
13
- // Check if the property is in the ignored list and log the explanation
14
- if (Object.prototype.hasOwnProperty.call(ignoredProperties, key)) {
15
- console.error(`Ignored property detected: "${key}". ${ignoredProperties[key]}`);
16
- }
17
- // Check for uppercase letters, numbers, and special characters (only allow lowercase letters and "-"
18
- const isValidKey = /^[a-z-]+$/.test(key);
19
- if (!isValidKey) {
20
- console.error(`Invalid key "${key}": Keys must be lowercase letters and may only contain "-".`);
21
- }
22
- // Check for nested objects (only support single-level properties)
23
- if (typeof value === 'object' && value !== null) {
24
- console.error(`Invalid nested object for property "${key}". Nested objects are not supported.`);
25
- }
26
- // Check if the value is a valid type
27
- const isValidType = typeof value === 'string' || typeof value === 'number';
28
- if (!isValidType) {
29
- console.error(`Invalid style value for "${key}": ${value}. Must be a string or number.`);
30
- }
31
- }
32
- }
33
- return obj;
34
- };
35
- const createStyleReact = (obj)=>{
36
- return toCamelCaseKeys(createStyle(obj));
37
- };
38
-
39
- 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,83 +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 : null; // 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
-
83
- export { For, If, Liquid, LiquidFor, LiquidIf };
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
- const toCamelCaseKeys = (obj)=>{
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 { createAttr } from './component/createAttr.js';
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 } 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};
@@ -1,16 +1,16 @@
1
1
  declare const createAttr: (obj: {
2
- [key: string]: string | number;
2
+ [key: string]: string | number | boolean;
3
3
  }) => {
4
- [key: string]: string | number;
4
+ [key: string]: string | number | boolean;
5
5
  } | undefined;
6
6
 
7
7
  declare const createStyle: (obj: {
8
- [key: string]: string | number;
8
+ [key: string]: string | number | undefined;
9
9
  }) => {
10
- [key: string]: string | number;
10
+ [key: string]: string | number | undefined;
11
11
  };
12
12
  declare const createStyleReact: (obj: {
13
- [key: string]: string | number;
13
+ [key: string]: string | number | undefined;
14
14
  }) => {
15
15
  [key: string]: any;
16
16
  };
@@ -33,11 +33,13 @@ declare const For: <T>(items: T[], renderFn: (item: T, index: number) => JSX.Ele
33
33
  declare const LiquidFor: (c: string, t: string | CallbackCondition) => string;
34
34
  declare const If: (condition: boolean | null | undefined, trueResult: string | JSX.Element | CallbackCondition, falseResult?: string | JSX.Element | CallbackCondition) => JSX.Element | string | null;
35
35
  declare const LiquidIf: (c: string, t: string | CallbackCondition, f?: string | CallbackCondition) => string;
36
+ declare const Unless: (condition: boolean | null | undefined, trueResult: string | JSX.Element | CallbackCondition, falseResult?: string | JSX.Element | CallbackCondition) => string | JSX.Element | null;
37
+ declare const LiquidUnless: (c: string, t: string | CallbackCondition, f?: string | CallbackCondition) => string;
36
38
 
37
39
  declare const createAttrReact: (obj: {
38
- [key: string]: string | number;
40
+ [key: string]: string | number | boolean;
39
41
  }) => {
40
- [key: string]: string | number;
42
+ [key: string]: string | number | boolean;
41
43
  } | undefined;
42
44
 
43
45
  declare const createContentReact: (content: string) => string;
@@ -46,4 +48,4 @@ declare const createClassReact: (obj: {
46
48
  [key: string]: boolean | undefined;
47
49
  }) => string;
48
50
 
49
- export { For, If, Liquid, LiquidFor, LiquidIf, createAttr, createAttrReact, createClass, createClassReact, createContent, createContentReact, createStateOrContext, createStyle, createStyleReact };
51
+ export { For, If, Liquid, LiquidFor, LiquidIf, LiquidUnless, Unless, createAttr, createAttrReact, createClass, createClassReact, createContent, createContentReact, createStateOrContext, createStyle, createStyleReact };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/system",
3
- "version": "1.58.0-dev.148",
3
+ "version": "2.0.0-dev.1082",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -19,10 +19,10 @@
19
19
  "format": "prettier --write \"./src/**/*.{ts,tsx}\"",
20
20
  "type-check": "yarn tsc --noEmit"
21
21
  },
22
- "dependencies": {
23
- "@gem-sdk/core": "1.58.0-dev.148"
22
+ "dependencies": {},
23
+ "devDependencies": {
24
+ "@gem-sdk/core": "2.0.0-dev.1082"
24
25
  },
25
- "devDependencies": {},
26
26
  "module": "dist/esm/index.js",
27
27
  "types": "dist/types/index.d.ts",
28
28
  "exports": {