@lifesg/react-design-system 3.5.0-canary.4 → 3.5.0-canary.6
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/cjs/data-table/data-table.js +1 -1
- package/cjs/data-table/data-table.js.map +1 -1
- package/cjs/data-table/data-table.styles.js +14 -12
- package/cjs/data-table/data-table.styles.js.map +1 -1
- package/cjs/error-display/error-display-data.js +1 -1
- package/cjs/error-display/error-display-data.js.map +1 -1
- package/cjs/navbar/navbar-items.js +1 -1
- package/cjs/navbar/navbar-items.js.map +1 -1
- package/cjs/navbar/navbar-items.styles.js +11 -7
- package/cjs/navbar/navbar-items.styles.js.map +1 -1
- package/cjs/toggle/toggle.js +1 -1
- package/cjs/toggle/toggle.js.map +1 -1
- package/cjs/toggle/toggle.styles.js +42 -20
- package/cjs/toggle/toggle.styles.js.map +1 -1
- package/codemods/data.ts +1 -33
- package/codemods/index.ts +55 -140
- package/data-table/data-table.d.ts +1 -1
- package/data-table/data-table.js +1 -1
- package/data-table/data-table.js.map +1 -1
- package/data-table/data-table.styles.d.ts +1 -0
- package/data-table/data-table.styles.js +22 -20
- package/data-table/data-table.styles.js.map +1 -1
- package/data-table/types.d.ts +9 -0
- package/error-display/error-display-data.js +1 -1
- package/error-display/error-display-data.js.map +1 -1
- package/navbar/navbar-items.js +1 -1
- package/navbar/navbar-items.js.map +1 -1
- package/navbar/navbar-items.styles.d.ts +20 -4
- package/navbar/navbar-items.styles.js +13 -9
- package/navbar/navbar-items.styles.js.map +1 -1
- package/package.json +1 -1
- package/toggle/toggle.js +1 -1
- package/toggle/toggle.js.map +1 -1
- package/toggle/toggle.styles.d.ts +1 -0
- package/toggle/toggle.styles.js +65 -43
- package/toggle/toggle.styles.js.map +1 -1
|
@@ -27,15 +27,24 @@
|
|
|
27
27
|
// apply container border and header background color
|
|
28
28
|
${o=>"no-border"===o.$styleType?o.$error?o.$disabled?e.css`
|
|
29
29
|
border-color: ${d.Colour["border-error"]};
|
|
30
|
-
`:e.css`
|
|
31
|
-
border-color:
|
|
30
|
+
`:o.$selected?e.css`
|
|
31
|
+
border-color: transparent;
|
|
32
|
+
background: ${d.Colour["bg-error"]};
|
|
32
33
|
|
|
33
34
|
&:has(${g}:hover) {
|
|
34
35
|
@media (pointer: fine) {
|
|
35
|
-
background: ${d.Colour["bg-hover
|
|
36
|
+
background: ${d.Colour["bg-error-hover"]};
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
`:
|
|
39
|
+
`:e.css`
|
|
40
|
+
border-color: ${d.Colour["border-error"]};
|
|
41
|
+
|
|
42
|
+
&:has(${g}:hover) {
|
|
43
|
+
@media (pointer: fine) {
|
|
44
|
+
background: ${d.Colour["bg-hover-subtle"]};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`:o.$disabled?o.$selected?e.css`
|
|
39
48
|
border: none;
|
|
40
49
|
background: ${d.Colour["bg-selected-disabled"]};
|
|
41
50
|
`:e.css`
|
|
@@ -67,15 +76,24 @@
|
|
|
67
76
|
}
|
|
68
77
|
`:o.$error?o.$disabled?e.css`
|
|
69
78
|
border-color: ${d.Colour["border-error"]};
|
|
70
|
-
`:e.css`
|
|
79
|
+
`:o.$selected?e.css`
|
|
71
80
|
border-color: ${d.Colour["border-error"]};
|
|
81
|
+
background: ${d.Colour["bg-error"]};
|
|
72
82
|
|
|
73
83
|
&:has(${g}:hover) {
|
|
74
84
|
@media (pointer: fine) {
|
|
75
|
-
background: ${d.Colour["bg-hover
|
|
85
|
+
background: ${d.Colour["bg-error-hover"]};
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
|
-
`:
|
|
88
|
+
`:e.css`
|
|
89
|
+
border-color: ${d.Colour["border-error"]};
|
|
90
|
+
|
|
91
|
+
&:has(${g}:hover) {
|
|
92
|
+
@media (pointer: fine) {
|
|
93
|
+
background: ${d.Colour["bg-hover-subtle"]};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`:o.$disabled?o.$selected?e.css`
|
|
79
97
|
border-color: ${d.Colour["border-selected-disabled"]};
|
|
80
98
|
background: ${d.Colour["bg-selected-disabled"]};
|
|
81
99
|
`:e.css`
|
|
@@ -130,12 +148,14 @@
|
|
|
130
148
|
overflow: hidden;
|
|
131
149
|
|
|
132
150
|
// apply header container text color
|
|
133
|
-
${o=>o.$
|
|
151
|
+
${o=>o.$selected?o.$disabled?e.css`
|
|
134
152
|
color: ${d.Colour["text-selected-disabled"]};
|
|
153
|
+
`:o.$error?e.css`
|
|
154
|
+
color: ${d.Colour["text-error"]};
|
|
135
155
|
`:e.css`
|
|
136
|
-
color: ${d.Colour["text-disabled"]};
|
|
137
|
-
`:o.$selected?e.css`
|
|
138
156
|
color: ${d.Colour["text-selected"]};
|
|
157
|
+
`:o.$disabled?e.css`
|
|
158
|
+
color: ${d.Colour["text-disabled"]};
|
|
139
159
|
`:e.css`
|
|
140
160
|
color: ${d.Colour.text};
|
|
141
161
|
`}
|
|
@@ -168,13 +188,13 @@
|
|
|
168
188
|
display: flex;
|
|
169
189
|
align-items: flex-start;
|
|
170
190
|
justify-content: space-between;
|
|
171
|
-
`,
|
|
191
|
+
`,h=s.default.div`
|
|
172
192
|
display: flex;
|
|
173
193
|
height: 100%;
|
|
174
194
|
width: 100%;
|
|
175
195
|
position: relative;
|
|
176
196
|
padding: ${e=>e.$addPadding?"0.6875rem 0rem 0.6875rem 1rem":"0.6875rem 1rem"};
|
|
177
|
-
`,
|
|
197
|
+
`,m=s.default.button`
|
|
178
198
|
color: ${e=>e.$disabled?d.Colour["text-disabled"]:d.Colour["text-error"]};
|
|
179
199
|
white-space: nowrap;
|
|
180
200
|
${d.Font["body-md-semibold"]}
|
|
@@ -184,7 +204,7 @@
|
|
|
184
204
|
background: none;
|
|
185
205
|
|
|
186
206
|
cursor: ${e=>e.$disabled?"not-allowed":"pointer"};
|
|
187
|
-
`,
|
|
207
|
+
`,C=s.default.button`
|
|
188
208
|
color: ${e=>e.disabled?d.Colour["text-disabled"]:d.Colour["text-primary"]};
|
|
189
209
|
${d.Font["body-baseline-semibold"]}
|
|
190
210
|
display: flex;
|
|
@@ -202,7 +222,7 @@
|
|
|
202
222
|
height: 1em;
|
|
203
223
|
margin-left: 0.5rem;
|
|
204
224
|
}
|
|
205
|
-
`,
|
|
225
|
+
`,x=s.default.div`
|
|
206
226
|
width: 100%;
|
|
207
227
|
color: ${e=>e.$disabled?d.Colour["text-disabled"]:d.Colour["text-error"]};
|
|
208
228
|
border: none;
|
|
@@ -224,21 +244,23 @@
|
|
|
224
244
|
`:o.$selected?e.css`
|
|
225
245
|
color: ${d.Colour["text-selected"]};
|
|
226
246
|
`:e.css`
|
|
227
|
-
|
|
228
|
-
|
|
247
|
+
color: ${d.Colour.text};
|
|
248
|
+
`}
|
|
229
249
|
`,y=s.default(i.Typography.BodyMD)`
|
|
230
250
|
color: ${e=>e.$disabled?d.Colour["text-disabled"]:d.Colour["text-error"]};
|
|
231
251
|
`,w=s.default(l.TextList.Ul)`
|
|
232
252
|
color: ${e=>e.$disabled?d.Colour["text-disabled"]:d.Colour["text-error"]};
|
|
233
253
|
`,k=s.default(t.ToggleIcon)`
|
|
234
|
-
${o=>o.$
|
|
254
|
+
${o=>o.$selected?o.$disabled?e.css`
|
|
235
255
|
color: ${d.Colour["icon-selected-disabled"]};
|
|
256
|
+
`:o.$error?e.css`
|
|
257
|
+
color: ${d.Colour["icon-error-strong"]};
|
|
236
258
|
`:e.css`
|
|
237
|
-
color: ${d.Colour["icon-disabled-subtle"]};
|
|
238
|
-
`:o.$selected?e.css`
|
|
239
259
|
color: ${d.Colour["icon-selected"]};
|
|
260
|
+
`:o.$disabled?e.css`
|
|
261
|
+
color: ${d.Colour["icon-disabled-subtle"]};
|
|
240
262
|
`:e.css`
|
|
241
263
|
color: ${d.Colour["icon-subtle"]};
|
|
242
264
|
`};
|
|
243
|
-
`;exports.AlertContainer=f,exports.Children=v,exports.Container=a,exports.ErrorContainer=
|
|
265
|
+
`;exports.AlertContainer=f,exports.Children=v,exports.Container=a,exports.ErrorContainer=x,exports.ErrorList=w,exports.ErrorText=y,exports.ExpandButton=C,exports.HeaderContainer=g,exports.IndicatorLabelContainer=h,exports.Input=c,exports.InputContainer=u,exports.Label=$,exports.RemoveButton=m,exports.StyledToggleIcon=k,exports.SubLabel=p,exports.TextContainer=b;
|
|
244
266
|
//# sourceMappingURL=toggle.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.styles.js","sources":["../../../src/toggle/toggle.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Alert } from \"../alert\";\nimport { applyHtmlContentStyle } from \"../shared/html-content/html-content\";\nimport { ToggleIcon } from \"../shared/toggle-icon/toggle-icon\";\nimport { TextList } from \"../text-list\";\nimport { Colour, Font, MediaQuery, Radius } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { ToggleStyleType } from \"./types\";\n\n// =============================================================================\n// STYLE INTERFACES, transient props are denoted with $\n// See more https://styled-components.com/docs/api#transient-props\n// =============================================================================\ninterface StyleProps {\n $selected?: boolean;\n $disabled?: boolean;\n $indicator?: boolean;\n}\n\ninterface ContainerStyleProps extends StyleProps {\n $styleType?: ToggleStyleType;\n $error?: boolean;\n $useContentWidth?: boolean;\n}\n\ninterface IndicatorLabelContainerStyleProps {\n $addPadding?: boolean;\n}\n\ninterface LabelStyleProps {\n $maxLines?: { desktop?: number; mobile?: number; tablet?: number };\n}\n\ninterface ExpandButtonStyleProps extends StyleProps {\n $paddingTopRequired?: boolean;\n}\n\ninterface ChildrenStyleProps extends StyleProps {\n $isFinalItem?: boolean;\n}\n\ninterface InteractiveStyleProps {\n $disabledVisual?: boolean;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\n\nexport const Container = styled.div<ContainerStyleProps>`\n position: relative;\n display: inline-flex;\n min-width: 10.375rem;\n border-radius: ${Radius[\"sm\"]};\n border-width: 1px;\n border-style: solid;\n overflow: hidden;\n flex-direction: column;\n height: fit-content;\n background: ${Colour.bg};\n\n &:has(input:focus-visible) {\n outline: 2px solid ${Colour[\"focus-ring\"]};\n outline-offset: 0;\n }\n\n ${(props) => {\n if (!props.$indicator) {\n return css`\n justify-content: center;\n `;\n }\n }}\n\n // Container min width to fit content\n ${(props) => {\n if (props.$useContentWidth) {\n return css`\n min-width: unset;\n `;\n }\n }}\n\n // apply container border and header background color\n ${(props) => {\n switch (props.$styleType) {\n case \"no-border\": {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border: none;\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border: none;\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n default: {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected-disabled\"]};\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-disabled\"]};\n background: ${Colour[\"bg-disabled\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected\"]};\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour.border};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n }}\n`;\n\nexport const Input = styled.input<InteractiveStyleProps>`\n position: absolute;\n height: 100%;\n width: 100%;\n cursor: ${(props) => (props.$disabledVisual ? \"not-allowed\" : \"pointer\")};\n top: 0;\n left: 0;\n opacity: 0;\n\n /* Hide appearance but keep it focusable using keyboard interactions */\n appearance: none;\n background: transparent;\n border: none;\n`;\n\nexport const InputContainer = styled.div`\n display: flex;\n`;\n\nexport const TextContainer = styled.div<StyleProps>`\n display: flex;\n flex-direction: column;\n overflow-wrap: anywhere;\n width: 100%;\n overflow: hidden;\n\n // apply header container text color\n ${(props) => {\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected-disabled\"]};\n `;\n } else {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n }\n\n return css`\n color: ${Colour.text};\n `;\n }}\n`;\n\nexport const Label = styled.label<LabelStyleProps & { $selected?: boolean }>`\n ${(props) =>\n props.$selected\n ? Font[\"body-baseline-semibold\"]\n : Font[\"body-baseline-regular\"]};\n overflow: hidden;\n display: -webkit-box;\n text-overflow: ellipsis;\n -webkit-box-orient: vertical;\n overflow-wrap: break-word;\n -webkit-line-clamp: ${(props) => props.$maxLines?.desktop ?? \"none\"};\n ${MediaQuery.MaxWidth.lg} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.tablet ?? \"none\"};\n }\n ${MediaQuery.MaxWidth.sm} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.mobile ?? \"none\"};\n }\n`;\n\nexport const SubLabel = styled.div`\n ${Font[\"body-md-regular\"]}\n margin-top: 0.5rem;\n\n z-index: 1; // forces sublabel to render above the input\n pointer-events: none; // to allow click events to be passed to the input\n\n strong,\n b {\n ${Font[\"body-md-semibold\"]}\n }\n`;\n\nexport const HeaderContainer = styled.div<ContainerStyleProps>`\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n`;\n\nexport const IndicatorLabelContainer = styled.div<IndicatorLabelContainerStyleProps>`\n display: flex;\n height: 100%;\n width: 100%;\n position: relative;\n padding: ${(props) =>\n props.$addPadding ? \"0.6875rem 0rem 0.6875rem 1rem\" : \"0.6875rem 1rem\"};\n`;\n\nexport const RemoveButton = styled.button<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n white-space: nowrap;\n ${Font[\"body-md-semibold\"]}\n height: fit-content;\n padding: 0.6875rem 1rem 0.6875rem 0.5rem;\n border: none;\n background: none;\n\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n`;\n\nexport const ExpandButton = styled.button<ExpandButtonStyleProps>`\n color: ${(props) =>\n props.disabled ? Colour[\"text-disabled\"] : Colour[\"text-primary\"]};\n ${Font[\"body-baseline-semibold\"]}\n display: flex;\n align-items: center;\n justify-content: flex-end;\n border: none;\n background-color: ${Colour.bg};\n cursor: ${(props) => (props.disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0 1rem 0.6875rem 1rem;\n padding-top: ${(props) =>\n props.$paddingTopRequired ? \"0.6875rem\" : \"0rem\"};\n width: 100%;\n\n svg {\n width: 1em;\n height: 1em;\n margin-left: 0.5rem;\n }\n`;\n\nexport const ErrorContainer = styled.div<StyleProps>`\n width: 100%;\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n border: none;\n background: ${Colour.bg};\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0.6875rem 1rem 0.5rem 1rem;\n`;\n\nexport const AlertContainer = styled(Alert)`\n width: 100%;\n user-select: none;\n`;\n\nexport const Children = styled.div<ChildrenStyleProps>`\n padding: 0 1rem;\n padding-top: 0.6875rem;\n padding-bottom: ${(props) => (props.$isFinalItem ? \"0.6875rem\" : \"0.5rem\")};\n background-color: ${Colour.bg};\n ${applyHtmlContentStyle({ textSize: \"body-md\" })}\n\n ${(props) => {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n } else if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n } else {\n return css`\n color: ${Colour.text};\n `;\n }\n }}\n`;\n\nexport const ErrorText = styled(Typography.BodyMD)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const ErrorList = styled(TextList.Ul)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const StyledToggleIcon = styled(ToggleIcon)<StyleProps>`\n ${(props) => {\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n color: ${Colour[\"icon-selected-disabled\"]};\n `;\n } else {\n return css`\n color: ${Colour[\"icon-disabled-subtle\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n color: ${Colour[\"icon-selected\"]};\n `;\n }\n return css`\n color: ${Colour[\"icon-subtle\"]};\n `;\n }};\n`;\n"],"names":["Container","styled","div","Radius","Colour","bg","props","$indicator","css","$useContentWidth","$styleType","$error","$disabled","HeaderContainer","$selected","TextContainer","StyledToggleIcon","border","Input","input","$disabledVisual","InputContainer","text","Label","label","Font","_a","_b","$maxLines","desktop","MediaQuery","MaxWidth","lg","tablet","sm","mobile","SubLabel","IndicatorLabelContainer","$addPadding","RemoveButton","button","ExpandButton","disabled","$paddingTopRequired","ErrorContainer","AlertContainer","Alert","Children","$isFinalItem","applyHtmlContentStyle","textSize","ErrorText","Typography","BodyMD","ErrorList","TextList","Ul","ToggleIcon"],"mappings":"mXAiDO,MAAMA,EAAYC,EAAAA,QAAOC,GAAwB;;;;qBAInCC,EAAAA,OAAW;;;;;;kBAMdC,EAAAA,OAAOC;;;6BAGID,EAAAA,OAAO;;;;MAI7BE,IACC,IAAKA,EAAMC,WACP,OAAOC,KAAG;;aAGd;;;MAIDF,IACC,GAAIA,EAAMG,iBACN,OAAOD,KAAG;;aAGd;;;MAIDF,GAEU,cADDA,EAAMI,WAEFJ,EAAMK,OACFL,EAAMM,UACCJ,KAAG;4CACUJ,EAAAA,OAAO;0BAGpBI,KAAG;4CACUJ,EAAAA,OAAO;;oCAEfS;;kDAEcT,EAAAA,OAAO;;;0BAOrCE,EAAMM,UACFN,EAAMQ,UACCN,KAAG;;0CAEQJ,EAAAA,OAAO;0BAGlBI,KAAG;;0BAMdF,EAAMQ,UACCN,KAAG;;sCAEQJ,EAAAA,OAAO;;gCAEbS;;8CAEcT,EAAAA,OAAO;;oCAEjBW;6CACSX,EAAAA,OAAO;;;oCAGhBY;6CACSZ,EAAAA,OAAO;;;;sBAO7BI,KAAG;;;4BAGEK;;0CAEcT,EAAAA,OAAO;;;kBAO7BE,EAAMK,OACFL,EAAMM,UACCJ,KAAG;4CACUJ,EAAAA,OAAO;0BAGpBI,KAAG;4CACUJ,EAAAA,OAAO;;oCAEfS;;kDAEcT,EAAAA,OAAO;;;0BAOrCE,EAAMM,UACFN,EAAMQ,UACCN,KAAG;4CACUJ,EAAAA,OAAO;0CACTA,EAAAA,OAAO;0BAGlBI,KAAG;4CACUJ,EAAAA,OAAO;0CACTA,EAAAA,OAAO;0BAK7BE,EAAMQ,UACCN,KAAG;wCACUJ,EAAAA,OAAO;sCACTA,EAAA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BAAmBA,SAAO;EAG9CY,EAAmBf,EAAAA,QAAOwD,EAAAA,WAAuB;MACvDnD,GACKA,EAAMM,UACFN,EAAMQ,UACCN,KAAG;6BACGJ,EAAAA,OAAO;kBAGbI,KAAG;6BACGJ,EAAAA,OAAO;kBAKxBE,EAAMQ,UACCN,KAAG;yBACGJ,EAAAA,OAAO;cAGjBI,KAAG;qBACGJ,EAAAA,OAAO;;"}
|
|
1
|
+
{"version":3,"file":"toggle.styles.js","sources":["../../../src/toggle/toggle.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Alert } from \"../alert\";\nimport { applyHtmlContentStyle } from \"../shared/html-content/html-content\";\nimport { ToggleIcon } from \"../shared/toggle-icon/toggle-icon\";\nimport { TextList } from \"../text-list\";\nimport { Colour, Font, MediaQuery, Radius } from \"../theme\";\nimport { Typography } from \"../typography\";\nimport { ToggleStyleType } from \"./types\";\n\n// =============================================================================\n// STYLE INTERFACES, transient props are denoted with $\n// See more https://styled-components.com/docs/api#transient-props\n// =============================================================================\ninterface StyleProps {\n $error?: boolean;\n $selected?: boolean;\n $disabled?: boolean;\n $indicator?: boolean;\n}\n\ninterface ContainerStyleProps extends StyleProps {\n $styleType?: ToggleStyleType;\n $error?: boolean;\n $useContentWidth?: boolean;\n}\n\ninterface IndicatorLabelContainerStyleProps {\n $addPadding?: boolean;\n}\n\ninterface LabelStyleProps {\n $maxLines?: { desktop?: number; mobile?: number; tablet?: number };\n}\n\ninterface ExpandButtonStyleProps extends StyleProps {\n $paddingTopRequired?: boolean;\n}\n\ninterface ChildrenStyleProps extends StyleProps {\n $isFinalItem?: boolean;\n}\n\ninterface InteractiveStyleProps {\n $disabledVisual?: boolean;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\n\nexport const Container = styled.div<ContainerStyleProps>`\n position: relative;\n display: inline-flex;\n min-width: 10.375rem;\n border-radius: ${Radius[\"sm\"]};\n border-width: 1px;\n border-style: solid;\n overflow: hidden;\n flex-direction: column;\n height: fit-content;\n background: ${Colour.bg};\n\n &:has(input:focus-visible) {\n outline: 2px solid ${Colour[\"focus-ring\"]};\n outline-offset: 0;\n }\n\n ${(props) => {\n if (!props.$indicator) {\n return css`\n justify-content: center;\n `;\n }\n }}\n\n // Container min width to fit content\n ${(props) => {\n if (props.$useContentWidth) {\n return css`\n min-width: unset;\n `;\n }\n }}\n\n // apply container border and header background color\n ${(props) => {\n switch (props.$styleType) {\n case \"no-border\": {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n }\n\n if (props.$selected) {\n return css`\n border-color: transparent;\n background: ${Colour[\"bg-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-error-hover\"]};\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border: none;\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border: none;\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border: none;\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n default: {\n if (props.$error) {\n if (props.$disabled) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n `;\n }\n\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-error\"]};\n background: ${Colour[\"bg-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-error-hover\"]};\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour[\"border-error\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n\n if (props.$disabled) {\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected-disabled\"]};\n background: ${Colour[\"bg-selected-disabled\"]};\n `;\n } else {\n return css`\n border-color: ${Colour[\"border-disabled\"]};\n background: ${Colour[\"bg-disabled\"]};\n `;\n }\n }\n\n if (props.$selected) {\n return css`\n border-color: ${Colour[\"border-selected\"]};\n background: ${Colour[\"bg-selected\"]};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-selected-hover\"]};\n\n & ${TextContainer} {\n color: ${Colour[\"text-selected-hover\"]};\n }\n\n & ${StyledToggleIcon} {\n color: ${Colour[\"icon-selected-hover\"]};\n }\n }\n }\n `;\n }\n\n return css`\n border-color: ${Colour.border};\n\n &:has(${HeaderContainer}:hover) {\n @media (pointer: fine) {\n background: ${Colour[\"bg-hover-subtle\"]};\n }\n }\n `;\n }\n }\n }}\n`;\n\nexport const Input = styled.input<InteractiveStyleProps>`\n position: absolute;\n height: 100%;\n width: 100%;\n cursor: ${(props) => (props.$disabledVisual ? \"not-allowed\" : \"pointer\")};\n top: 0;\n left: 0;\n opacity: 0;\n\n /* Hide appearance but keep it focusable using keyboard interactions */\n appearance: none;\n background: transparent;\n border: none;\n`;\n\nexport const InputContainer = styled.div`\n display: flex;\n`;\n\nexport const TextContainer = styled.div<StyleProps>`\n display: flex;\n flex-direction: column;\n overflow-wrap: anywhere;\n width: 100%;\n overflow: hidden;\n\n // apply header container text color\n ${(props) => {\n if (props.$selected) {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-selected-disabled\"]};\n `;\n }\n\n if (props.$error) {\n return css`\n color: ${Colour[\"text-error\"]};\n `;\n }\n\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n }\n\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n\n return css`\n color: ${Colour.text};\n `;\n }}\n`;\n\nexport const Label = styled.label<LabelStyleProps & { $selected?: boolean }>`\n ${(props) =>\n props.$selected\n ? Font[\"body-baseline-semibold\"]\n : Font[\"body-baseline-regular\"]};\n overflow: hidden;\n display: -webkit-box;\n text-overflow: ellipsis;\n -webkit-box-orient: vertical;\n overflow-wrap: break-word;\n -webkit-line-clamp: ${(props) => props.$maxLines?.desktop ?? \"none\"};\n ${MediaQuery.MaxWidth.lg} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.tablet ?? \"none\"};\n }\n ${MediaQuery.MaxWidth.sm} {\n -webkit-line-clamp: ${(props) => props.$maxLines?.mobile ?? \"none\"};\n }\n`;\n\nexport const SubLabel = styled.div`\n ${Font[\"body-md-regular\"]}\n margin-top: 0.5rem;\n\n z-index: 1; // forces sublabel to render above the input\n pointer-events: none; // to allow click events to be passed to the input\n\n strong,\n b {\n ${Font[\"body-md-semibold\"]}\n }\n`;\n\nexport const HeaderContainer = styled.div<ContainerStyleProps>`\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n`;\n\nexport const IndicatorLabelContainer = styled.div<IndicatorLabelContainerStyleProps>`\n display: flex;\n height: 100%;\n width: 100%;\n position: relative;\n padding: ${(props) =>\n props.$addPadding ? \"0.6875rem 0rem 0.6875rem 1rem\" : \"0.6875rem 1rem\"};\n`;\n\nexport const RemoveButton = styled.button<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n white-space: nowrap;\n ${Font[\"body-md-semibold\"]}\n height: fit-content;\n padding: 0.6875rem 1rem 0.6875rem 0.5rem;\n border: none;\n background: none;\n\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n`;\n\nexport const ExpandButton = styled.button<ExpandButtonStyleProps>`\n color: ${(props) =>\n props.disabled ? Colour[\"text-disabled\"] : Colour[\"text-primary\"]};\n ${Font[\"body-baseline-semibold\"]}\n display: flex;\n align-items: center;\n justify-content: flex-end;\n border: none;\n background-color: ${Colour.bg};\n cursor: ${(props) => (props.disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0 1rem 0.6875rem 1rem;\n padding-top: ${(props) =>\n props.$paddingTopRequired ? \"0.6875rem\" : \"0rem\"};\n width: 100%;\n\n svg {\n width: 1em;\n height: 1em;\n margin-left: 0.5rem;\n }\n`;\n\nexport const ErrorContainer = styled.div<StyleProps>`\n width: 100%;\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n border: none;\n background: ${Colour.bg};\n cursor: ${(props) => (props.$disabled ? \"not-allowed\" : \"pointer\")};\n padding: 0.6875rem 1rem 0.5rem 1rem;\n`;\n\nexport const AlertContainer = styled(Alert)`\n width: 100%;\n user-select: none;\n`;\n\nexport const Children = styled.div<ChildrenStyleProps>`\n padding: 0 1rem;\n padding-top: 0.6875rem;\n padding-bottom: ${(props) => (props.$isFinalItem ? \"0.6875rem\" : \"0.5rem\")};\n background-color: ${Colour.bg};\n ${applyHtmlContentStyle({ textSize: \"body-md\" })}\n\n ${(props) => {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n\n if (props.$selected) {\n return css`\n color: ${Colour[\"text-selected\"]};\n `;\n }\n\n return css`\n color: ${Colour.text};\n `;\n }}\n`;\n\nexport const ErrorText = styled(Typography.BodyMD)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const ErrorList = styled(TextList.Ul)<StyleProps>`\n color: ${(props) =>\n props.$disabled ? Colour[\"text-disabled\"] : Colour[\"text-error\"]};\n`;\n\nexport const StyledToggleIcon = styled(ToggleIcon)<StyleProps>`\n ${(props) => {\n if (props.$selected) {\n if (props.$disabled)\n return css`\n color: ${Colour[\"icon-selected-disabled\"]};\n `;\n\n if (props.$error)\n return css`\n color: ${Colour[\"icon-error-strong\"]};\n `;\n\n return css`\n color: ${Colour[\"icon-selected\"]};\n `;\n }\n\n if (props.$disabled)\n return css`\n color: ${Colour[\"icon-disabled-subtle\"]};\n `;\n\n return css`\n color: ${Colour[\"icon-subtle\"]};\n `;\n }};\n`;\n"],"names":["Container","styled","div","Radius","Colour","bg","props","$indicator","css","$useContentWidth","$styleType","$error","$disabled","$selected","HeaderContainer","TextContainer","StyledToggleIcon","border","Input","input","$disabledVisual","InputContainer","text","Label","label","Font","_a","_b","$maxLines","desktop","MediaQuery","MaxWidth","lg","tablet","sm","mobile","SubLabel","IndicatorLabelContainer","$addPadding","RemoveButton","button","ExpandButton","disabled","$paddingTopRequired","ErrorContainer","AlertContainer","Alert","Children","$isFinalItem","applyHtmlContentStyle","textSize","ErrorText","Typography","BodyMD","ErrorList","TextList","Ul","ToggleIcon"],"mappings":"mXAkDO,MAAMA,EAAYC,EAAAA,QAAOC,GAAwB;;;;qBAInCC,EAAAA,OAAW;;;;;;kBAMdC,EAAAA,OAAOC;;;6BAGID,EAAAA,OAAO;;;;MAI7BE,IACC,IAAKA,EAAMC,WACP,OAAOC,KAAG;;aAGd;;;MAIDF,IACC,GAAIA,EAAMG,iBACN,OAAOD,KAAG;;aAGd;;;MAIDF,GAEU,cADDA,EAAMI,WAEFJ,EAAMK,OACFL,EAAMM,UACCJ,KAAG;4CACUJ,EAAAA,OAAO;0BAI3BE,EAAMO,UACCL,KAAG;;0CAEQJ,EAAAA,OAAO;;oCAEbU;;kDAEcV,EAAAA,OAAO;;;0BAM9BI,KAAG;wCACUJ,EAAAA,OAAO;;gCAEfU;;8CAEcV,EAAAA,OAAO;;;sBAMjCE,EAAMM,UACFN,EAAMO,UACCL,KAAG;;0CAEQJ,EAAAA,OAAO;0BAGlBI,KAAG;;0BAMdF,EAAMO,UACCL,KAAG;;sCAEQJ,EAAAA,OAAO;;gCAEbU;;8CAEcV,EA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D",
|
|
11
|
-
H6: "BodySM",
|
|
12
|
-
DBody: "HeadingSM",
|
|
13
|
-
Body: "BodyBL",
|
|
14
|
-
BodySmall: "BodyMD",
|
|
15
|
-
XSmall: "BodyXS",
|
|
16
|
-
"Hyperlink.Default": "LinkBL",
|
|
17
|
-
"Hyperlink.Small": "LinkMD",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const textStyleFontMap = {
|
|
1
|
+
export const sizePropMapping = {
|
|
21
2
|
D1: "heading-xxl",
|
|
22
3
|
D2: "heading-xl",
|
|
23
4
|
D3: "heading-md",
|
|
@@ -33,16 +14,3 @@ export const textStyleFontMap = {
|
|
|
33
14
|
BodySmall: "body-md",
|
|
34
15
|
XSmall: "body-xs",
|
|
35
16
|
};
|
|
36
|
-
|
|
37
|
-
export const weightMap = {
|
|
38
|
-
regular: "regular",
|
|
39
|
-
semibold: "semibold",
|
|
40
|
-
bold: "bold",
|
|
41
|
-
light: "light",
|
|
42
|
-
black: "bold",
|
|
43
|
-
400: "regular",
|
|
44
|
-
600: "semibold",
|
|
45
|
-
700: "bold",
|
|
46
|
-
300: "light",
|
|
47
|
-
900: "bold",
|
|
48
|
-
};
|
package/codemods/index.ts
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
API,
|
|
3
|
-
ASTPath,
|
|
4
|
-
FileInfo,
|
|
5
|
-
JSCodeshift,
|
|
6
|
-
MemberExpression,
|
|
7
|
-
} from "jscodeshift";
|
|
1
|
+
import { API, FileInfo, JSCodeshift } from "jscodeshift";
|
|
8
2
|
import { CodemodUtils } from "../codemod-utils";
|
|
9
|
-
import {
|
|
3
|
+
import { sizePropMapping } from "./data";
|
|
10
4
|
|
|
11
5
|
// ======= Constants ======= //
|
|
12
6
|
|
|
13
7
|
const IMPORT_PATHS = {
|
|
14
|
-
|
|
8
|
+
TEXT_LIST: "@lifesg/react-design-system/text-list",
|
|
9
|
+
V2_TEXT_LIST: "@lifesg/react-design-system/v2_text-list",
|
|
15
10
|
DESIGN_SYSTEM: "@lifesg/react-design-system",
|
|
16
|
-
TYPOGRAPHY: "@lifesg/react-design-system/typography",
|
|
17
|
-
THEME: "@lifesg/react-design-system/theme",
|
|
18
11
|
};
|
|
19
12
|
|
|
20
13
|
const IMPORT_SPECIFIERS = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
TYPOGRAPHY: "Typography",
|
|
24
|
-
FONT: "Font",
|
|
14
|
+
TEXT_LIST: "TextList",
|
|
15
|
+
V2_TEXT_LIST: "V2_TextList",
|
|
25
16
|
};
|
|
26
17
|
|
|
27
18
|
const JSX_IDENTIFIERS = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const IDENTIFIERS = {
|
|
33
|
-
V2_GET_TEXT_STYLE: "getTextStyle",
|
|
19
|
+
TEXT_LIST: "TextList",
|
|
20
|
+
V2_TEXT_LIST: "V2_TextList",
|
|
34
21
|
};
|
|
35
22
|
|
|
36
23
|
// ======= Transformer Function ======= //
|
|
@@ -39,156 +26,84 @@ export default function transformer(file: FileInfo, api: API) {
|
|
|
39
26
|
const j: JSCodeshift = api.jscodeshift;
|
|
40
27
|
const source = j(file.source);
|
|
41
28
|
|
|
42
|
-
const
|
|
43
|
-
source,
|
|
44
|
-
api,
|
|
45
|
-
[IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
|
|
46
|
-
IMPORT_SPECIFIERS.V2_TEXT
|
|
47
|
-
);
|
|
48
|
-
const importsTextStyleHelper = CodemodUtils.hasImport(
|
|
29
|
+
const isV2TextListImport = CodemodUtils.hasImport(
|
|
49
30
|
source,
|
|
50
31
|
api,
|
|
51
|
-
[IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.
|
|
52
|
-
IMPORT_SPECIFIERS.
|
|
32
|
+
[IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT_LIST],
|
|
33
|
+
IMPORT_SPECIFIERS.V2_TEXT_LIST
|
|
53
34
|
);
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
path: ASTPath<MemberExpression>,
|
|
57
|
-
newComponentValue: string
|
|
58
|
-
) => {
|
|
59
|
-
path.replace(
|
|
60
|
-
j.memberExpression(
|
|
61
|
-
j.identifier(JSX_IDENTIFIERS.TYPOGRAPHY),
|
|
62
|
-
j.identifier(newComponentValue)
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
if (importsText) {
|
|
36
|
+
if (isV2TextListImport) {
|
|
68
37
|
CodemodUtils.addImport(
|
|
69
38
|
source,
|
|
70
39
|
api,
|
|
71
|
-
IMPORT_PATHS.
|
|
72
|
-
IMPORT_SPECIFIERS.
|
|
40
|
+
IMPORT_PATHS.TEXT_LIST,
|
|
41
|
+
IMPORT_SPECIFIERS.TEXT_LIST
|
|
73
42
|
);
|
|
74
43
|
|
|
75
44
|
CodemodUtils.removeImport(
|
|
76
45
|
source,
|
|
77
46
|
api,
|
|
78
|
-
[IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.
|
|
79
|
-
IMPORT_SPECIFIERS.
|
|
47
|
+
[IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT_LIST],
|
|
48
|
+
IMPORT_SPECIFIERS.V2_TEXT_LIST
|
|
80
49
|
);
|
|
81
50
|
|
|
82
51
|
source
|
|
83
|
-
.find(j.Identifier, { name: JSX_IDENTIFIERS.
|
|
52
|
+
.find(j.Identifier, { name: JSX_IDENTIFIERS.V2_TEXT_LIST })
|
|
84
53
|
.forEach((path) => {
|
|
85
|
-
|
|
86
|
-
path.node.name = JSX_IDENTIFIERS.TYPOGRAPHY;
|
|
54
|
+
path.node.name = JSX_IDENTIFIERS.TEXT_LIST;
|
|
87
55
|
});
|
|
88
56
|
|
|
89
|
-
// Map to respective V3 Typography component usage
|
|
90
57
|
source.find(j.MemberExpression).forEach((path) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const property = currentPath.property;
|
|
97
|
-
const object = currentPath.object;
|
|
98
|
-
|
|
99
|
-
if (j.Identifier.check(property)) {
|
|
100
|
-
propertyNameParts.unshift(property.name);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (j.MemberExpression.check(object)) {
|
|
104
|
-
currentPath = object;
|
|
105
|
-
} else if (j.Identifier.check(object)) {
|
|
106
|
-
if (object.name === JSX_IDENTIFIERS.TYPOGRAPHY) {
|
|
107
|
-
startsWithTypography = true;
|
|
108
|
-
}
|
|
109
|
-
break;
|
|
110
|
-
} else {
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
58
|
+
if (
|
|
59
|
+
j.Identifier.check(path.node.object) &&
|
|
60
|
+
path.node.object.name === JSX_IDENTIFIERS.V2_TEXT_LIST
|
|
61
|
+
) {
|
|
62
|
+
path.node.object.name = JSX_IDENTIFIERS.TEXT_LIST;
|
|
113
63
|
}
|
|
64
|
+
});
|
|
114
65
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
replaceWithTypography(path, newTypographyValue);
|
|
122
|
-
}
|
|
66
|
+
source.find(j.JSXMemberExpression).forEach((path) => {
|
|
67
|
+
if (
|
|
68
|
+
j.JSXIdentifier.check(path.node.object) &&
|
|
69
|
+
path.node.object.name === JSX_IDENTIFIERS.V2_TEXT_LIST
|
|
70
|
+
) {
|
|
71
|
+
path.node.object.name = JSX_IDENTIFIERS.TEXT_LIST;
|
|
123
72
|
}
|
|
124
73
|
});
|
|
125
|
-
}
|
|
126
74
|
|
|
127
|
-
|
|
128
|
-
|
|
75
|
+
source.find(j.JSXOpeningElement).forEach((path) => {
|
|
76
|
+
const openingElement = path.node;
|
|
77
|
+
let isTextListElement = false;
|
|
129
78
|
|
|
130
|
-
source.find(j.CallExpression).forEach((path) => {
|
|
131
79
|
if (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
path.node.callee.object.name !==
|
|
136
|
-
IMPORT_SPECIFIERS.V2_TEXT_STYLE_HELPER ||
|
|
137
|
-
!j.Identifier.check(path.node.callee.property) ||
|
|
138
|
-
path.node.callee.property.name !== IDENTIFIERS.V2_GET_TEXT_STYLE
|
|
80
|
+
j.JSXMemberExpression.check(openingElement.name) &&
|
|
81
|
+
j.JSXIdentifier.check(openingElement.name.object) &&
|
|
82
|
+
openingElement.name.object.name === JSX_IDENTIFIERS.TEXT_LIST
|
|
139
83
|
) {
|
|
140
|
-
|
|
84
|
+
isTextListElement = true;
|
|
141
85
|
}
|
|
142
86
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
87
|
+
if (isTextListElement) {
|
|
88
|
+
const attributes = openingElement.attributes;
|
|
89
|
+
|
|
90
|
+
attributes?.forEach((attribute) => {
|
|
91
|
+
if (
|
|
92
|
+
j.JSXAttribute.check(attribute) &&
|
|
93
|
+
attribute.name.name === "size" &&
|
|
94
|
+
j.StringLiteral.check(attribute.value)
|
|
95
|
+
) {
|
|
96
|
+
const sizeValue = attribute.value
|
|
97
|
+
.value as keyof typeof sizePropMapping;
|
|
98
|
+
if (sizePropMapping[sizeValue]) {
|
|
99
|
+
attribute.value = j.literal(
|
|
100
|
+
sizePropMapping[sizeValue]
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
152
105
|
}
|
|
153
|
-
|
|
154
|
-
const mappedType =
|
|
155
|
-
textStyleFontMap[style as keyof typeof textStyleFontMap];
|
|
156
|
-
const mappedWeight = weightMap[weight as keyof typeof weightMap];
|
|
157
|
-
|
|
158
|
-
j(path).replaceWith(() => {
|
|
159
|
-
return j.memberExpression(
|
|
160
|
-
j.identifier("Font"),
|
|
161
|
-
j.literal(`${mappedType}-${mappedWeight}`)
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
usesTextStyleHelper = true;
|
|
166
106
|
});
|
|
167
|
-
|
|
168
|
-
if (usesTextStyleHelper) {
|
|
169
|
-
CodemodUtils.addImport(
|
|
170
|
-
source,
|
|
171
|
-
api,
|
|
172
|
-
IMPORT_PATHS.THEME,
|
|
173
|
-
IMPORT_SPECIFIERS.FONT
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
!CodemodUtils.hasReferences(
|
|
179
|
-
source,
|
|
180
|
-
api,
|
|
181
|
-
[IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
|
|
182
|
-
IMPORT_SPECIFIERS.V2_TEXT_STYLE_HELPER
|
|
183
|
-
)
|
|
184
|
-
) {
|
|
185
|
-
CodemodUtils.removeImport(
|
|
186
|
-
source,
|
|
187
|
-
api,
|
|
188
|
-
[IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
|
|
189
|
-
IMPORT_SPECIFIERS.V2_TEXT_STYLE_HELPER
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
107
|
}
|
|
193
108
|
|
|
194
109
|
return source.toSource();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DataTableProps } from "./types";
|
|
2
|
-
export declare const DataTable: ({ id, headers, rows, className, sortIndicators, alternatingRows, loadState, enableMultiSelect, selectedIds, disabledIds, enableActionBar, enableSelectAll, enableStickyHeader, emptyView, actionBarContent, renderCustomEmptyView, onHeaderClick, onSelect, onSelectAll, onClearSelectionClick, ...otherProps }: DataTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DataTable: ({ id, headers, rows, className, sortIndicators, alternatingRows, loadState, enableMultiSelect, selectedIds, disabledIds, enableActionBar, enableActionBarWithoutSelection, enableSelectAll, enableStickyHeader, emptyView, actionBarContent, renderCustomEmptyView, onHeaderClick, onSelect, onSelectAll, onClearSelectionClick, ...otherProps }: DataTableProps) => import("react/jsx-runtime").JSX.Element;
|
package/data-table/data-table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as t,jsx as i,Fragment as n}from"react/jsx-runtime";import{ArrowUpIcon as l,ArrowDownIcon as r}from"@lifesg/react-icons";import{useRef as o,useState as d,useEffect as a}from"react";import{useResizeDetector as s}from"../external/react-resize-detector/build/index.esm.js";import"../animations/loading-spinner/loading-spinner.js";import"../animations/loading-dots/loading-dots.js";import{LoadingDotsSpinner as c}from"../animations/loading-dots-spinner/loading-dots-spinner.js";import"styled-components";import{Checkbox as h}from"../checkbox/checkbox.js";import{ErrorDisplay as p}from"../error-display/error-display.js";import"../error-display/helper.js";import{VisuallyHidden as u,concatIds as m}from"../shared/accessibility/index.js";import{Typography as g}from"../typography/typography.js";import"../util/calendar-helper.js";import"../util/date-helper.js";import"../util/date-input-helper.js";import{useId as b}from"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{useEvent as f}from"../util/use-event.js";import{useEventListener as y}from"../util/use-event-listener.js";import{useThrottle as w}from"../util/use-throttle.js";import{TableWrapper as $,TableContainer as k,Table as
|
|
1
|
+
import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as t,jsx as i,Fragment as n}from"react/jsx-runtime";import{ArrowUpIcon as l,ArrowDownIcon as r}from"@lifesg/react-icons";import{useRef as o,useState as d,useEffect as a}from"react";import{useResizeDetector as s}from"../external/react-resize-detector/build/index.esm.js";import"../animations/loading-spinner/loading-spinner.js";import"../animations/loading-dots/loading-dots.js";import{LoadingDotsSpinner as c}from"../animations/loading-dots-spinner/loading-dots-spinner.js";import"styled-components";import{Checkbox as h}from"../checkbox/checkbox.js";import{ErrorDisplay as p}from"../error-display/error-display.js";import"../error-display/helper.js";import{VisuallyHidden as u,concatIds as m}from"../shared/accessibility/index.js";import{Typography as g}from"../typography/typography.js";import"../util/calendar-helper.js";import"../util/date-helper.js";import"../util/date-input-helper.js";import{useId as b}from"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{useEvent as f}from"../util/use-event.js";import{useEventListener as y}from"../util/use-event-listener.js";import{useThrottle as w}from"../util/use-throttle.js";import{TableWrapper as $,TableContainer as k,Table as S,TableBody as v,TableHead as C,HeaderRow as j,BodyRow as H,EmptyViewCell as x,LoaderWrapper as B,ActionBarWrapper as R,ActionBar as A,TextButton as I,ActionBarGap as N,ActionBarSpacer as K,HeaderCell as M,CheckBoxWrapper as V,HeaderCellWrapper as W,ErrorDisplayTitle as L,BodyCell as z,BodyCellContent as D}from"./data-table.styles.js";const E=E=>{var{id:_,headers:O,rows:P,className:T,sortIndicators:q,alternatingRows:F,loadState:G="success",enableMultiSelect:J,selectedIds:Q,disabledIds:U,enableActionBar:X,enableActionBarWithoutSelection:Y,enableSelectAll:Z,enableStickyHeader:ee,emptyView:te,actionBarContent:ie,renderCustomEmptyView:ne,onHeaderClick:le,onSelect:re,onSelectAll:oe,onClearSelectionClick:de}=E,ae=e(E,["id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableActionBarWithoutSelection","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick"]);const se=o(null),ce=o(null),he=o(null),pe=o(null),ue=b(),me=O.filter((e=>"string"!=typeof e&&!!e.keyColumn)),[ge,be]=d("inline"),[fe,ye]=d(!1),[we,$e]=d(!1),ke=f((()=>{Me()}));a((()=>{ke()}),[ke]);const Se=w((()=>Me()),100);s({targetRef:pe,onResize:()=>Se()}),y("scroll",Se),y("scroll",Se,pe.current);const ve=()=>!!(P&&P.length&&Q)&&Q.length===P.length,Ce=e=>!!(null==Q?void 0:Q.includes(e)),je=e=>!!F&&e%2==1,He=e=>!!(null==U?void 0:U.includes(e)),xe=e=>{if(ae["data-testid"])return`${ae["data-testid"]}-${e}`},Be=()=>O.length+(J?1:0),Re=e=>null==q?void 0:q[e],Ae=e=>{const t=Re(e);if(t)return"asc"===t?"ascending":"descending"},Ie=e=>` by ${"asc"===Re(e)?"descending":"ascending"} order`,Ne=(e,t)=>`${ue}-row-${e}-${t}-key-column`,Ke=e=>{const t=me.map((t=>Ne(e,t.fieldKey)));return m(...t)},Me=()=>{if(!pe.current||!ce.current||!he.current)return;const e=pe.current.getBoundingClientRect(),t=ce.current.getBoundingClientRect();let i="inline";const n=pe.current.scrollHeight>pe.current.clientHeight;if(e.top>window.innerHeight||e.bottom<0?i="inline":n?e.top>0&&e.top<window.innerHeight&&e.bottom>0&&e.bottom<window.innerHeight||e.top<0&&e.bottom>0&&e.bottom<window.innerHeight?i="sticky":e.bottom>window.innerHeight&&Math.max(e.top,t.bottom)+t.height<window.innerHeight&&(i="fixed"):e.bottom>window.innerHeight&&t.bottom+t.height<window.innerHeight&&(i="fixed"),ye(n),be(i),"fixed"===i)$e(!0);else if("sticky"===i){const e=pe.current.scrollTop+pe.current.clientHeight<pe.current.scrollHeight;$e(e)}else $e(!1)},Ve=e=>{const{fieldKey:n,label:l,clickable:r=!1,style:o}="string"==typeof e?{fieldKey:e,label:e,style:void 0}:e,d=!!Re(n),a=(e=>`${ue}-header-${e}`)(n);return t(M,{"data-testid":xe(`header-${n}`),$clickable:r,scope:"col","aria-sort":Ae(n),style:o,$isCheckbox:!1,onClick:()=>(e=>{null==le||le(e)})(n),children:[t(W,{id:a,children:["string"==typeof l?i(g.BodyBL,{weight:"bold",children:l}):l,We(n)]}),(r||d)&&i(u,{children:t("button",{onClick:e=>((e,t)=>{e.stopPropagation(),null==le||le(t)})(e,n),children:[d&&"Sort ",i("span",{"aria-labelledby":a}),d&&Ie(n)]})})]},n)},We=e=>{const t=null==q?void 0:q[e];return t?"asc"===t?i(l,{"aria-hidden":!0,"data-testid":xe(`header-${e}-arrowup`)}):i(r,{"aria-hidden":!0,"data-testid":xe(`header-${e}-arrowdown`)}):i(n,{})},Le=()=>i(M,{"data-testid":xe("header-selection"),$clickable:!1,$isCheckbox:!0,scope:"col",children:t(V,{children:[i(u,{children:"Row selection"}),Z&&i(h,{checked:ve(),indeterminate:!!Q&&0!==Q.length&&!ve(),disabled:!P||!P.length,"aria-label":"Select all rows",onClick:()=>{oe&&oe(ve())}})]})}),ze=(e,t)=>{const n="string"!=typeof e?e.style:void 0,l="string"==typeof e?e:e.fieldKey,r=t.id.toString(),o=t[l],d=`${r}-${l}`;return i(z,{"data-testid":xe(`row-${d}`),id:Ne(r,l),style:n,$isCheckbox:!1,children:"string"==typeof o||"number"==typeof o?i(D,{children:o}):"function"==typeof o?o(t,{isSelected:Ce(r)}):o},d)},De=e=>{const t=e.id.toString();return i(z,{"data-testid":xe(`row-${t}-selection`),$isCheckbox:!0,children:i(V,{children:i(h,{checked:Ce(t),"aria-labelledby":Ke(t),onClick:()=>{re&&re(t,!Ce(t))},disabled:He(t),focusableWhenDisabled:He(t)})})})},Ee=()=>i(p,Object.assign({type:"no-item-found"},te,{title:(null==te?void 0:te.title)?"string"==typeof te.title?i(L,{weight:"bold",children:te.title}):te.title:i(L,{weight:"bold",children:"No <items> found"}),description:(null==te?void 0:te.description)?te.description:"No matching rows"}));return t($,{id:_||"table-wrapper","data-testid":ae["data-testid"]||"table",className:T,ref:pe,tabIndex:0,$scrollable:fe,children:[i(k,{children:t(S,{ref:se,children:[i(C,{ref:ce,$stickyHeader:ee,children:t(j,{children:[J&&Le(),O.map(Ve)]})}),i(v,{children:"success"===G?!P||P.length<1?i(H,{$alternating:!1,children:i(x,{colSpan:Be(),children:ne?ne():Ee()})}):i(n,{children:null==P?void 0:P.map(((e,i)=>t(H,{"data-testid":xe(`row-${e.id.toString()}`),$showLastRowBottomBorder:we,$alternating:je(i),$isSelectable:J,$isSelected:Ce(e.id.toString()),children:[J&&De(e),O.map((t=>ze(t,e)))]},e.id.toString())))}):i(H,{$alternating:!1,children:i("td",{colSpan:Be(),children:i(B,{role:"status","aria-live":"polite","aria-label":"Loading table",children:"loading"===G&&i(c,{})})})})})]})}),X&&(Q&&Q.length>0||Y)&&(()=>{var e,l,r,o;const d=null!==(e=null==Q?void 0:Q.length)&&void 0!==e?e:0,a="item"+(1===d?"":"s");return t(n,{children:[i(R,{ref:he,$strategy:ge,$left:we?null===(r=null===(l=null==se?void 0:se.current)||void 0===l?void 0:l.getBoundingClientRect())||void 0===r?void 0:r.left:0,$width:null===(o=null==se?void 0:se.current)||void 0===o?void 0:o.clientWidth,children:t(A,{$float:we,children:[i(g.BodyMD,{weight:"semibold",children:`${d} ${a} selected`}),d>0?i(I,{type:"button","aria-label":`Clear selection of ${d} ${a}`,onClick:de,children:"Clear selection"}):i(N,{}),ie]})}),"sticky"!==ge&&i(K,{})]})})()]})};export{E as DataTable};
|
|
2
2
|
//# sourceMappingURL=data-table.js.map
|