@gem-sdk/system 1.58.0-dev.141 → 1.58.0-dev.143
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/index.js +0 -6
- package/dist/esm/index.js +0 -1
- package/dist/types/index.d.ts +1 -8
- package/package.json +5 -14
- package/src/component/__tests__/ template.test.tsx +76 -0
- package/src/component/__tests__/createAttr.test.ts +62 -0
- package/src/component/__tests__/createClass.test.ts +68 -0
- package/src/component/__tests__/createContent.test.ts +52 -0
- package/src/component/__tests__/createStateOrContext.test.ts +129 -0
- package/src/component/__tests__/createStyle.test.ts +63 -0
- package/src/component/createAttr.ts +44 -0
- package/src/component/createClass.ts +48 -0
- package/src/component/createContent.ts +20 -0
- package/src/component/createStateOrContext.ts +70 -0
- package/src/component/createStyle.ts +53 -0
- package/src/component/template.ts +119 -0
- package/src/component/types.ts +9 -0
- package/src/component/utils/__tests__/toCamelCaseKeys.test.ts +79 -0
- package/src/component/utils/toCamelCaseKeys.ts +20 -0
- package/src/e2e-tests/README.md +1 -0
- package/src/examples/components/text/DemoText.liquid.ts +49 -0
- package/src/examples/components/text/DemoText.tsx +50 -0
- package/src/examples/components/text/common/__tests__/globalTypoClasses.test.ts +11 -0
- package/src/examples/components/text/common/getAttr.ts +7 -0
- package/src/examples/components/text/common/getStyle.ts +5 -0
- package/src/examples/components/text/common/globalTypoClasses.ts +5 -0
- package/src/examples/components/text/e2e-tests/DemoText.spec.tsx +23 -0
- package/src/examples/components/text/e2e-tests/DemoText.tsx +23 -0
- package/src/index.ts +34 -0
- package/src/validator/README.md +1 -0
- package/dist/cjs/component/template.js +0 -89
- package/dist/esm/component/template.js +0 -83
|
@@ -1,83 +0,0 @@
|
|
|
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 };
|