@hitachivantara/uikit-react-core 5.33.0 → 5.35.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/components/BaseInput/BaseInput.styles.cjs +14 -16
- package/dist/cjs/components/BaseInput/BaseInput.styles.cjs.map +1 -1
- package/dist/cjs/components/Calendar/CalendarHeader/CalendarHeader.cjs +14 -19
- package/dist/cjs/components/Calendar/CalendarHeader/CalendarHeader.cjs.map +1 -1
- package/dist/cjs/components/Calendar/CalendarHeader/CalendarHeader.styles.cjs +7 -38
- package/dist/cjs/components/Calendar/CalendarHeader/CalendarHeader.styles.cjs.map +1 -1
- package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs.map +1 -1
- package/dist/cjs/components/DropDownMenu/DropDownMenu.styles.cjs +1 -1
- package/dist/cjs/components/DropDownMenu/DropDownMenu.styles.cjs.map +1 -1
- package/dist/cjs/components/Dropdown/List/List.cjs +5 -1
- package/dist/cjs/components/Dropdown/List/List.cjs.map +1 -1
- package/dist/esm/components/BaseInput/BaseInput.styles.js +14 -16
- package/dist/esm/components/BaseInput/BaseInput.styles.js.map +1 -1
- package/dist/esm/components/Calendar/CalendarHeader/CalendarHeader.js +15 -20
- package/dist/esm/components/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
- package/dist/esm/components/Calendar/CalendarHeader/CalendarHeader.styles.js +7 -38
- package/dist/esm/components/Calendar/CalendarHeader/CalendarHeader.styles.js.map +1 -1
- package/dist/esm/components/DropDownMenu/DropDownMenu.js.map +1 -1
- package/dist/esm/components/DropDownMenu/DropDownMenu.styles.js +1 -1
- package/dist/esm/components/DropDownMenu/DropDownMenu.styles.js.map +1 -1
- package/dist/esm/components/Dropdown/List/List.js +6 -2
- package/dist/esm/components/Dropdown/List/List.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +5 -5
|
@@ -19,6 +19,10 @@ const {
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
disabled: {
|
|
22
|
+
"& $inputRoot": {
|
|
23
|
+
backgroundColor: uikitStyles.theme.colors.atmo2,
|
|
24
|
+
borderColor: uikitStyles.theme.colors.secondary_60
|
|
25
|
+
},
|
|
22
26
|
"& $inputBorderContainer": {
|
|
23
27
|
backgroundColor: uikitStyles.theme.colors.atmo4
|
|
24
28
|
},
|
|
@@ -83,19 +87,19 @@ const {
|
|
|
83
87
|
"& $inputRootMultiline": {
|
|
84
88
|
"& $input": {
|
|
85
89
|
border: `1px solid ${uikitStyles.theme.colors.secondary_60}`,
|
|
86
|
-
backgroundColor:
|
|
90
|
+
backgroundColor: uikitStyles.theme.colors.atmo2
|
|
87
91
|
}
|
|
88
92
|
},
|
|
89
93
|
"&:hover $inputRootMultiline": {
|
|
90
94
|
"& $input": {
|
|
91
95
|
border: `1px solid ${uikitStyles.theme.colors.secondary_60}`,
|
|
92
|
-
backgroundColor:
|
|
96
|
+
backgroundColor: uikitStyles.theme.colors.atmo2
|
|
93
97
|
}
|
|
94
98
|
},
|
|
95
99
|
"&:focus-within $inputRootMultiline": {
|
|
96
100
|
"& $input": {
|
|
97
101
|
border: `1px solid ${uikitStyles.theme.colors.secondary_60}`,
|
|
98
|
-
backgroundColor:
|
|
102
|
+
backgroundColor: uikitStyles.theme.colors.atmo2
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
},
|
|
@@ -112,14 +116,14 @@ const {
|
|
|
112
116
|
},
|
|
113
117
|
inputRootReadOnly: {
|
|
114
118
|
borderColor: uikitStyles.theme.colors.secondary_60,
|
|
115
|
-
backgroundColor:
|
|
119
|
+
backgroundColor: uikitStyles.theme.colors.atmo2
|
|
116
120
|
},
|
|
117
121
|
inputRoot: {
|
|
118
122
|
margin: 0,
|
|
119
123
|
width: "100%",
|
|
120
124
|
borderRadius: uikitStyles.theme.radii.base,
|
|
121
125
|
height: "32px",
|
|
122
|
-
border: `1px solid ${uikitStyles.theme.colors.
|
|
126
|
+
border: `1px solid ${uikitStyles.theme.colors.secondary}`,
|
|
123
127
|
boxSizing: "border-box",
|
|
124
128
|
backgroundColor: uikitStyles.theme.colors.atmo1,
|
|
125
129
|
fontFamily: uikitStyles.theme.fontFamily.body,
|
|
@@ -137,23 +141,17 @@ const {
|
|
|
137
141
|
}
|
|
138
142
|
},
|
|
139
143
|
inputRootFocused: {
|
|
140
|
-
|
|
144
|
+
backgroundColor: uikitStyles.theme.colors.atmo1,
|
|
141
145
|
...focusUtils.outlineStyles,
|
|
142
146
|
"&:hover": {
|
|
143
|
-
|
|
147
|
+
backgroundColor: uikitStyles.theme.colors.atmo1
|
|
144
148
|
},
|
|
145
|
-
"
|
|
146
|
-
backgroundColor:
|
|
149
|
+
"&$inputRootReadOnly": {
|
|
150
|
+
backgroundColor: uikitStyles.theme.colors.atmo2
|
|
147
151
|
}
|
|
148
152
|
},
|
|
149
153
|
inputRootDisabled: {
|
|
150
|
-
background: uikitStyles.theme.colors.atmo2,
|
|
151
|
-
borderColor: uikitStyles.theme.colors.secondary_60,
|
|
152
154
|
cursor: "not-allowed",
|
|
153
|
-
"&:hover": {
|
|
154
|
-
background: uikitStyles.theme.colors.atmo2,
|
|
155
|
-
cursor: "not-allowed"
|
|
156
|
-
},
|
|
157
155
|
"&&::before": {
|
|
158
156
|
borderBottomStyle: "none"
|
|
159
157
|
}
|
|
@@ -165,7 +163,7 @@ const {
|
|
|
165
163
|
border: "none",
|
|
166
164
|
height: "auto",
|
|
167
165
|
"& $input": {
|
|
168
|
-
border: `1px solid ${uikitStyles.theme.colors.
|
|
166
|
+
border: `1px solid ${uikitStyles.theme.colors.secondary}`,
|
|
169
167
|
borderRadius: uikitStyles.theme.radii.base,
|
|
170
168
|
backgroundColor: uikitStyles.theme.colors.atmo1,
|
|
171
169
|
height: "auto",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInput.styles.cjs","sources":["../../../../src/components/BaseInput/BaseInput.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvBaseInput\", {\n root: {\n display: \"inline-block\",\n width: \"100%\",\n position: \"relative\",\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n },\n disabled: {\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&& $input\": {\n color: theme.colors.secondary_60,\n WebkitTextFillColor: theme.colors.secondary_60,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n },\n invalid: {\n \"&:not(.disabled)\": {\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n },\n },\n resizable: { width: \"auto\" },\n readOnly: {\n \"& $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: \"transparent\",\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: \"transparent\",\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: \"transparent\",\n },\n },\n },\n inputBorderContainer: {\n position: \"absolute\",\n width: \"calc(100% - 4px)\",\n height: \"0px\",\n top: \"31px\",\n left: \"2px\",\n backgroundColor: theme.colors.atmo4,\n },\n inputRootInvalid: { borderColor: theme.colors.negative },\n inputRootReadOnly: {\n borderColor: theme.colors.secondary_60,\n backgroundColor: \"transparent\",\n },\n inputRoot: {\n margin: 0,\n width: \"100%\",\n borderRadius: theme.radii.base,\n height: \"32px\",\n border: `1px solid ${theme.colors.secondary_80}`,\n boxSizing: \"border-box\",\n backgroundColor: theme.colors.atmo1,\n fontFamily: theme.fontFamily.body,\n\n \"&:hover:not($inputRootDisabled):not($inputRootInvalid):not($inputRootReadOnly)\":\n {\n borderColor: theme.colors.primary,\n },\n\n \"&:hover:not($inputRootDisabled)::before\": {\n borderBottom: \"none\",\n },\n\n \"&::before\": {\n borderBottom: \"none\",\n },\n\n \"&::after\": {\n borderBottom: \"none\",\n },\n },\n inputRootFocused: {\n background: theme.colors.atmo1,\n ...outlineStyles,\n\n \"&:hover\": {\n background: theme.colors.atmo1,\n },\n\n \"& $inputRootReadOnly\": {\n backgroundColor: \"transparent\",\n },\n },\n inputRootDisabled: {\n background: theme.colors.atmo2,\n borderColor: theme.colors.secondary_60,\n cursor: \"not-allowed\",\n\n \"&:hover\": {\n background: theme.colors.atmo2,\n cursor: \"not-allowed\",\n },\n\n \"&&::before\": {\n borderBottomStyle: \"none\",\n },\n },\n inputRootMultiline: {\n padding: 0,\n backgroundColor: \"transparent\",\n overflow: \"auto\",\n border: \"none\",\n height: \"auto\",\n\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_80}`,\n borderRadius: theme.radii.base,\n backgroundColor: theme.colors.atmo1,\n height: \"auto\",\n minHeight: \"21px\",\n padding: \"5px 10px\",\n overflow: \"auto\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n\n \"&:hover\": {\n border: `1px solid ${theme.colors.primary}`,\n },\n },\n },\n input: {\n height: \"19px\",\n marginLeft: theme.space.xs,\n marginRight: theme.space.xs,\n padding: \"6px 0 5px\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n outline: \"none\",\n width: \"initial\",\n flexGrow: 1,\n ...(theme.typography.body as CSSProperties),\n\n \"&::placeholder\": {\n opacity: 1,\n color: theme.colors.secondary_80,\n },\n\n \"&::-ms-clear\": {\n display: \"none\",\n },\n },\n inputDisabled: {},\n inputReadOnly: {\n color: theme.colors.secondary_80,\n },\n inputResizable: { resize: \"both\", width: \"100%\" },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","display","width","position","backgroundColor","theme","colors","primary","disabled","atmo4","color","secondary_60","WebkitTextFillColor","atmo2","border","invalid","negative","resizable","readOnly","inputBorderContainer","height","top","left","inputRootInvalid","borderColor","inputRootReadOnly","inputRoot","margin","borderRadius","radii","base","secondary_80","boxSizing","atmo1","fontFamily","body","borderBottom","inputRootFocused","background","outlineStyles","inputRootDisabled","cursor","borderBottomStyle","inputRootMultiline","padding","overflow","minHeight","marginLeft","marginRight","input","space","xs","textOverflow","outline","flexGrow","typography","opacity","inputDisabled","inputReadOnly","inputResizable","resize"],"mappings":";;;;;AAOa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,eAAe;AAAA,EACxEC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,OAAO;AAAA,IACPC,UAAU;AAAA,IAEV,iCAAiC;AAAA,MAC/BC,iBAAiBC,YAAAA,MAAMC,OAAOC;AAAAA,IAChC;AAAA,IAEA,wCAAwC;AAAA,MACtCH,iBAAiBC,YAAAA,MAAMC,OAAOC;AA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,QACTlC,QAAS,aAAYT,YAAMC,MAAAA,OAAOC,OAAQ;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AAAA,EACA0C,OAAO;AAAA,IACL7B,QAAQ;AAAA,IACR2B,YAAY1C,YAAAA,MAAM6C,MAAMC;AAAAA,IACxBH,aAAa3C,YAAAA,MAAM6C,MAAMC;AAAAA,IACzBP,SAAS;AAAA,IACTC,UAAU;AAAA,IACVO,cAAc;AAAA,IACdC,SAAS;AAAA,IACTnD,OAAO;AAAA,IACPoD,UAAU;AAAA,IACV,GAAIjD,YAAAA,MAAMkD,WAAWpB;AAAAA,IAErB,kBAAkB;AAAA,MAChBqB,SAAS;AAAA,MACT9C,OAAOL,YAAAA,MAAMC,OAAOyB;AAAAA,IACtB;AAAA,IAEA,gBAAgB;AAAA,MACd9B,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACAwD,eAAe,CAAC;AAAA,EAChBC,eAAe;AAAA,IACbhD,OAAOL,YAAAA,MAAMC,OAAOyB;AAAAA,EACtB;AAAA,EACA4B,gBAAgB;AAAA,IAAEC,QAAQ;AAAA,IAAQ1D,OAAO;AAAA,EAAO;AAClD,CAAC;;;"}
|
|
1
|
+
{"version":3,"file":"BaseInput.styles.cjs","sources":["../../../../src/components/BaseInput/BaseInput.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvBaseInput\", {\n root: {\n display: \"inline-block\",\n width: \"100%\",\n position: \"relative\",\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n },\n disabled: {\n \"& $inputRoot\": {\n backgroundColor: theme.colors.atmo2,\n borderColor: theme.colors.secondary_60,\n },\n\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&& $input\": {\n color: theme.colors.secondary_60,\n WebkitTextFillColor: theme.colors.secondary_60,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n },\n invalid: {\n \"&:not(.disabled)\": {\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n },\n },\n resizable: { width: \"auto\" },\n readOnly: {\n \"& $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n },\n inputBorderContainer: {\n position: \"absolute\",\n width: \"calc(100% - 4px)\",\n height: \"0px\",\n top: \"31px\",\n left: \"2px\",\n backgroundColor: theme.colors.atmo4,\n },\n inputRootInvalid: { borderColor: theme.colors.negative },\n inputRootReadOnly: {\n borderColor: theme.colors.secondary_60,\n backgroundColor: theme.colors.atmo2,\n },\n inputRoot: {\n margin: 0,\n width: \"100%\",\n borderRadius: theme.radii.base,\n height: \"32px\",\n border: `1px solid ${theme.colors.secondary}`,\n boxSizing: \"border-box\",\n backgroundColor: theme.colors.atmo1,\n fontFamily: theme.fontFamily.body,\n\n \"&:hover:not($inputRootDisabled):not($inputRootInvalid):not($inputRootReadOnly)\":\n {\n borderColor: theme.colors.primary,\n },\n\n \"&:hover:not($inputRootDisabled)::before\": {\n borderBottom: \"none\",\n },\n\n \"&::before\": {\n borderBottom: \"none\",\n },\n\n \"&::after\": {\n borderBottom: \"none\",\n },\n },\n inputRootFocused: {\n backgroundColor: theme.colors.atmo1,\n ...outlineStyles,\n\n \"&:hover\": {\n backgroundColor: theme.colors.atmo1,\n },\n\n \"&$inputRootReadOnly\": {\n backgroundColor: theme.colors.atmo2,\n },\n },\n inputRootDisabled: {\n cursor: \"not-allowed\",\n\n \"&&::before\": {\n borderBottomStyle: \"none\",\n },\n },\n inputRootMultiline: {\n padding: 0,\n backgroundColor: \"transparent\",\n overflow: \"auto\",\n border: \"none\",\n height: \"auto\",\n\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary}`,\n borderRadius: theme.radii.base,\n backgroundColor: theme.colors.atmo1,\n height: \"auto\",\n minHeight: \"21px\",\n padding: \"5px 10px\",\n overflow: \"auto\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n\n \"&:hover\": {\n border: `1px solid ${theme.colors.primary}`,\n },\n },\n },\n input: {\n height: \"19px\",\n marginLeft: theme.space.xs,\n marginRight: theme.space.xs,\n padding: \"6px 0 5px\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n outline: \"none\",\n width: \"initial\",\n flexGrow: 1,\n ...(theme.typography.body as CSSProperties),\n\n \"&::placeholder\": {\n opacity: 1,\n color: theme.colors.secondary_80,\n },\n\n \"&::-ms-clear\": {\n display: \"none\",\n },\n },\n inputDisabled: {},\n inputReadOnly: {\n color: theme.colors.secondary_80,\n },\n inputResizable: { resize: \"both\", width: \"100%\" },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","display","width","position","backgroundColor","theme","colors","primary","disabled","atmo2","borderColor","secondary_60","atmo4","color","WebkitTextFillColor","border","invalid","negative","resizable","readOnly","inputBorderContainer","height","top","left","inputRootInvalid","inputRootReadOnly","inputRoot","margin","borderRadius","radii","base","secondary","boxSizing","atmo1","fontFamily","body","borderBottom","inputRootFocused","outlineStyles","inputRootDisabled","cursor","borderBottomStyle","inputRootMultiline","padding","overflow","minHeight","marginLeft","marginRight","input","space","xs","textOverflow","outline","flexGrow","typography","opacity","secondary_80","inputDisabled","inputReadOnly","inputResizable","resize"],"mappings":";;;;;AAMa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,eAAe;AAAA,EACxEC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,OAAO;AAAA,IACPC,UAAU;AAAA,IAEV,iCAAiC;AAAA,MAC/BC,iBAAiBC,YAAAA,MAAMC,OAAOC;AAAAA,IAChC;AAAA,IAEA,wCAAwC;AAAA,MACtCH,iBAAiBC,YAAAA,MAAMC,OAAOC;AAAAA,IAChC;AAAA,EACF;AAAA,EACAC,UAAU;AAAA,IACR,gBAAgB;AAAA,MACdJ,iBAAiBC,YAAAA,MAAMC,OAAOG;AAAAA,MAC9BC,aAAaL,YAAAA,MAAMC,OAAOK;AAAAA,IAC5B;AAAA,IAEA,2BAA2B;AAAA,MACzBP,iBAAiBC,YAAAA,MAAMC,OAAOM;AAAAA,IAChC;AAAA,IAEA,iCAAiC;AAAA,MAC/BR,iBAAiBC,YAAAA,MAAMC,OAAOM;AAAAA,IAChC;AAAA,IAEA,aAAa;AAAA,MACXC,OAAOR,YAAAA,MAAMC,OAAOK;AAAAA,MACp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,UAAU;AAAA,IACV,GAAIhD,YAAAA,MAAMiD,WAAWnB;AAAAA,IAErB,kBAAkB;AAAA,MAChBoB,SAAS;AAAA,MACT1C,OAAOR,YAAAA,MAAMC,OAAOkD;AAAAA,IACtB;AAAA,IAEA,gBAAgB;AAAA,MACdvD,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACAwD,eAAe,CAAC;AAAA,EAChBC,eAAe;AAAA,IACb7C,OAAOR,YAAAA,MAAMC,OAAOkD;AAAAA,EACtB;AAAA,EACAG,gBAAgB;AAAA,IAAEC,QAAQ;AAAA,IAAQ1D,OAAO;AAAA,EAAO;AAClD,CAAC;;;"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const uikitReactIcons = require("@hitachivantara/uikit-react-icons");
|
|
6
5
|
const dayjs = require("dayjs");
|
|
7
6
|
const localeData = require("dayjs/plugin/localeData");
|
|
8
7
|
const localizedFormat = require("dayjs/plugin/localizedFormat");
|
|
@@ -16,6 +15,7 @@ const useDefaultProps = require("../../../hooks/useDefaultProps.cjs");
|
|
|
16
15
|
const FormElementContext = require("../../Forms/FormElement/context/FormElementContext.cjs");
|
|
17
16
|
const FormElementDescriptorsContext = require("../../Forms/FormElement/context/FormElementDescriptorsContext.cjs");
|
|
18
17
|
const Typography = require("../../Typography/Typography.cjs");
|
|
18
|
+
const Input = require("../../Input/Input.cjs");
|
|
19
19
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
20
20
|
const dayjs__default = /* @__PURE__ */ _interopDefault(dayjs);
|
|
21
21
|
const localeData__default = /* @__PURE__ */ _interopDefault(localeData);
|
|
@@ -34,8 +34,7 @@ const HvCalendarHeader = (props) => {
|
|
|
34
34
|
showEndDate,
|
|
35
35
|
showDayOfWeek = false,
|
|
36
36
|
onFocus,
|
|
37
|
-
invalidDateLabel = "Invalid Date"
|
|
38
|
-
...others
|
|
37
|
+
invalidDateLabel = "Invalid Date"
|
|
39
38
|
} = useDefaultProps.useDefaultProps("HvCalendarHeader", props);
|
|
40
39
|
const {
|
|
41
40
|
classes,
|
|
@@ -115,23 +114,19 @@ const HvCalendarHeader = (props) => {
|
|
|
115
114
|
setEditedValue(formattedDate);
|
|
116
115
|
onFocus?.(event, formattedDate);
|
|
117
116
|
};
|
|
118
|
-
const onChangeHandler = (event) => {
|
|
119
|
-
setEditedValue(
|
|
117
|
+
const onChangeHandler = (event, val) => {
|
|
118
|
+
setEditedValue(val);
|
|
120
119
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}, children: !isValidValue && inputValue !== "" && /* @__PURE__ */ jsxRuntime.jsxs(Typography.HvTypography, { component: "span", variant: "body", className: classes?.invalidMessageStyling, children: [
|
|
132
|
-
/* @__PURE__ */ jsxRuntime.jsx(uikitReactIcons.Info, { color: "brand", iconSize: "S" }),
|
|
133
|
-
invalidDateLabel
|
|
134
|
-
] }) })
|
|
120
|
+
const isInvalid = !isValidValue && inputValue !== "";
|
|
121
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { id: localId, className: cx(classes.root, {
|
|
122
|
+
[classes.invalid]: isInvalid
|
|
123
|
+
}), children: [
|
|
124
|
+
showDayOfWeek && /* @__PURE__ */ jsxRuntime.jsx(Typography.HvTypography, { className: classes.headerDayOfWeek, children: weekdayDisplay || " " }),
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx(Input.HvInput, { type: "text", id: setId.setId(localId, "header-input"), className: classes.headerDate, classes: {
|
|
126
|
+
input: classes.input,
|
|
127
|
+
inputBorderContainer: classes.inputBorderContainer,
|
|
128
|
+
error: classes.invalidMessageStyling
|
|
129
|
+
}, placeholder: localeFormat, value: inputValue, "aria-labelledby": label?.[0]?.id, onBlur: onBlurHandler, onFocus: onFocusHandler, onChange: onChangeHandler, onKeyDown: keyDownHandler, status: isInvalid ? "invalid" : "valid", statusMessage: invalidDateLabel })
|
|
135
130
|
] });
|
|
136
131
|
};
|
|
137
132
|
HvCalendarHeader.formElementType = "HvCalendarHeader";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarHeader.cjs","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useState, useEffect, useContext } from \"react\";\n\nimport { Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\n\nimport {\n HvFormElementContext,\n HvFormElementValueContext,\n HvFormElementDescriptorsContext,\n} from \"@core/components/Forms\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { isRange, isSameDay, formatToLocale, isDate } from \"../utils\";\nimport { DateRangeProp } from \"../types\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\ndayjs.extend(localeData);\ndayjs.extend(localizedFormat);\ndayjs.extend(customParseFormat);\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id,\n value,\n locale = \"en-US\",\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n ...others\n } = useDefaultProps(\"HvCalendarHeader\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId } = useContext(HvFormElementContext);\n const elementValue = useContext(HvFormElementValueContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n let localValue: string | Date | DateRangeProp | undefined =\n value ?? elementValue ?? \"\";\n if (isRange(localValue)) {\n localValue = showEndDate ? localValue.endDate : localValue.startDate;\n }\n const [dateValue, setDateValue] = useState<\n string | Date | DateRangeProp | undefined\n >(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const localId = id ?? setId(elementId, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = dayjs().locale(locale).localeData().longDateFormat(\"L\");\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (!!inputValue && dayjs(localValue).isValid())\n );\n\n const validateInput = (incomingValid) =>\n incomingValid === undefined || dayjs(incomingValid).isValid();\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(formatToLocale(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event, date) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = dayjs(date, localeFormat);\n\n const isValidInput = localeParsedDate.isValid();\n const dateParsed = isValidInput\n ? localeParsedDate.toDate()\n : dayjs(date).toDate();\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? dayjs(localValue).locale(locale).format(\"L\")\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler = (event) => {\n setEditedValue(event.target.value);\n };\n return (\n <>\n <div\n id={localId}\n className={cx(classes.root, {\n [classes.invalid]: !isValidValue && inputValue !== \"\",\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n\n <div className={classes.headerDate}>\n <input\n type=\"text\"\n id={setId(localId, \"header-input\")}\n placeholder={localeFormat}\n value={inputValue}\n className={classes.input}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n aria-labelledby={label?.[0]?.id}\n {...others}\n />\n </div>\n </div>\n {!isValidValue && inputValue !== \"\" && (\n <div role=\"presentation\" className={classes.inputBorderContainer} />\n )}\n <div style={{ height: 32 }}>\n {!isValidValue && inputValue !== \"\" && (\n <HvTypography\n component=\"span\"\n variant=\"body\"\n className={classes?.invalidMessageStyling}\n >\n <Info color=\"brand\" iconSize=\"S\" />\n {invalidDateLabel}\n </HvTypography>\n )}\n </div>\n </>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * The text to be shown on the main part of the header.\n */\n value?: string | Date | DateRangeProp;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event:\n | React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>\n | undefined,\n value: Date | DateRangeProp\n ) => void;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEventHandler<any>,\n formattedDate: string | null\n ) => void;\n /**\n * Indicates if header should display end date in a date range.\n */\n showEndDate?: boolean;\n /**\n * Indicates if header should display the day of week.\n */\n showDayOfWeek?: boolean;\n /**\n * Label shown when date is invalid.\n */\n invalidDateLabel?: string;\n}\n"],"names":["dayjs","extend","localeData","localizedFormat","customParseFormat","HvCalendarHeader","props","id","value","locale","classes","classesProp","onChange","showEndDate","showDayOfWeek","onFocus","invalidDateLabel","others","useDefaultProps","cx","useClasses","elementId","useContext","HvFormElementContext","elementValue","HvFormElementValueContext","label","HvFormElementDescriptorsContext","localValue","isRange","endDate","startDate","dateValue","setDateValue","useState","editedValue","setEditedValue","displayValue","setDisplayValue","weekdayDisplay","setWeekdayDisplay","localId","setId","inputValue","localeFormat","longDateFormat","isValidValue","setIsValidValue","length","isValid","validateInput","incomingValid","undefined","useEffect","valid","weekday","Intl","DateTimeFormat","format","isDate","formatToLocale","handleNewDate","event","date","localeParsedDate","isValidInput","dateParsed","toDate","isSameDay","onBlurHandler","keyDownHandler","isKey","preventDefault","onFocusHandler","formattedDate","onChangeHandler","target","jsxs","Fragment","root","invalid","HvTypography","headerDayOfWeek","headerDate","input","jsx","inputBorderContainer","height","invalidMessageStyling","Info","formElementType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BAA,eAAAA,QAAMC,OAAOC,oBAAAA,OAAU;AACvBF,eAAAA,QAAMC,OAAOE,yBAAAA,OAAe;AAC5BH,eAAAA,QAAMC,OAAOG,2BAAAA,OAAiB;AAEjBC,MAAAA,mBAAmBA,CAACC,UAAiC;AAC1D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAAS;AAAA,IACTC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC;AAAAA,IACAC,mBAAmB;AAAA,I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E;AAAAA,IAAAA,EAAAA,CACH,EAEJ,CAAA;AAAA,EACF,EAAA,CAAA;AAEJ;AAGAX,iBAAiBqF,kBAAkB;;;"}
|
|
1
|
+
{"version":3,"file":"CalendarHeader.cjs","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useState, useEffect, useContext } from \"react\";\nimport dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\n\nimport {\n HvFormElementContext,\n HvFormElementValueContext,\n HvFormElementDescriptorsContext,\n} from \"@core/components/Forms\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks\";\nimport { HvInput, HvInputProps } from \"@core/components/Input\";\n\nimport { isRange, isSameDay, formatToLocale, isDate } from \"../utils\";\nimport { DateRangeProp } from \"../types\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\ndayjs.extend(localeData);\ndayjs.extend(localizedFormat);\ndayjs.extend(customParseFormat);\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id,\n value,\n locale = \"en-US\",\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n } = useDefaultProps(\"HvCalendarHeader\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId } = useContext(HvFormElementContext);\n const elementValue = useContext(HvFormElementValueContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n let localValue: string | Date | DateRangeProp | undefined =\n value ?? elementValue ?? \"\";\n if (isRange(localValue)) {\n localValue = showEndDate ? localValue.endDate : localValue.startDate;\n }\n\n const [dateValue, setDateValue] = useState<\n string | Date | DateRangeProp | undefined\n >(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const localId = id ?? setId(elementId, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = dayjs().locale(locale).localeData().longDateFormat(\"L\");\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (!!inputValue && dayjs(localValue).isValid())\n );\n\n const validateInput = (incomingValid) =>\n incomingValid === undefined || dayjs(incomingValid).isValid();\n\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(formatToLocale(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event, date) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = dayjs(date, localeFormat);\n\n const isValidInput = localeParsedDate.isValid();\n const dateParsed = isValidInput\n ? localeParsedDate.toDate()\n : dayjs(date).toDate();\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler: HvInputProps[\"onBlur\"] = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler: HvInputProps[\"onKeyDown\"] = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler: HvInputProps[\"onFocus\"] = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? dayjs(localValue).locale(locale).format(\"L\")\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler: HvInputProps[\"onChange\"] = (event, val) => {\n setEditedValue(val);\n };\n\n const isInvalid = !isValidValue && inputValue !== \"\";\n\n // This component needs to be further refactored\n // It's not possible to clear the date\n // In a new major there's no need for all these classes\n return (\n <div\n id={localId}\n className={cx(classes.root, {\n [classes.invalid]: isInvalid,\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n <HvInput\n type=\"text\"\n id={setId(localId, \"header-input\")}\n className={classes.headerDate}\n classes={{\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n error: classes.invalidMessageStyling,\n }}\n placeholder={localeFormat}\n value={inputValue}\n aria-labelledby={label?.[0]?.id}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={invalidDateLabel}\n />\n </div>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * The text to be shown on the main part of the header.\n */\n value?: string | Date | DateRangeProp;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event:\n | React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>\n | undefined,\n value: Date | DateRangeProp\n ) => void;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n formattedDate: string | null\n ) => void;\n /**\n * Indicates if header should display end date in a date range.\n */\n showEndDate?: boolean;\n /**\n * Indicates if header should display the day of week.\n */\n showDayOfWeek?: boolean;\n /**\n * Label shown when date is invalid.\n */\n invalidDateLabel?: string;\n}\n"],"names":["dayjs","extend","localeData","localizedFormat","customParseFormat","HvCalendarHeader","props","id","value","locale","classes","classesProp","onChange","showEndDate","showDayOfWeek","onFocus","invalidDateLabel","useDefaultProps","cx","useClasses","elementId","useContext","HvFormElementContext","elementValue","HvFormElementValueContext","label","HvFormElementDescriptorsContext","localValue","isRange","endDate","startDate","dateValue","setDateValue","useState","editedValue","setEditedValue","displayValue","setDisplayValue","weekdayDisplay","setWeekdayDisplay","localId","setId","inputValue","localeFormat","longDateFormat","isValidValue","setIsValidValue","length","isValid","validateInput","incomingValid","undefined","useEffect","valid","weekday","Intl","DateTimeFormat","format","isDate","formatToLocale","handleNewDate","event","date","localeParsedDate","isValidInput","dateParsed","toDate","isSameDay","onBlurHandler","keyDownHandler","isKey","preventDefault","onFocusHandler","formattedDate","onChangeHandler","val","isInvalid","root","invalid","HvTypography","headerDayOfWeek","jsx","HvInput","headerDate","input","inputBorderContainer","error","invalidMessageStyling","formElementType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0BAA,eAAAA,QAAMC,OAAOC,oBAAAA,OAAU;AACvBF,eAAAA,QAAMC,OAAOE,yBAAAA,OAAe;AAC5BH,eAAAA,QAAMC,OAAOG,2BAAAA,OAAiB;AAEjBC,MAAAA,mBAAmBA,CAACC,UAAiC;AAC1D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAAS;AAAA,IACTC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC;AAAAA,IACAC,mBAAmB;AAAA,EAAA,IACjBC,gBAAgB,gBAAA,oBAAoBX,KAAK;AAEvC,QAAA;AAAA,IAAEI;AAAAA,IAASQ;AAAAA,EAAAA,IAAOC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C,aAAa;AAC5B1D,cAAU8C,OAAOY,aAAa;AAAA,EAAA;AAG1BC,QAAAA,kBAA4CA,CAACb,OAAOc,QAAQ;AAChExC,mBAAewC,GAAG;AAAA,EAAA;AAGdC,QAAAA,YAAY,CAAC/B,gBAAgBH,eAAe;AAKlD,yCACG,OACC,EAAA,IAAIF,SACJ,WAAWtB,GAAGR,QAAQmE,MAAM;AAAA,IAC1B,CAACnE,QAAQoE,OAAO,GAAGF;AAAAA,EACpB,CAAA,GAEA9D,UAAAA;AAAAA,IAAAA,gDACEiE,WAAa,cAAA,EAAA,WAAWrE,QAAQsE,iBAC9B1C,4BAAkB,KACrB;AAAA,IAED2C,2BAAAA,IAAAC,MAAAA,SAAA,EACC,MAAK,QACL,IAAIzC,MAAAA,MAAMD,SAAS,cAAc,GACjC,WAAW9B,QAAQyE,YACnB,SAAS;AAAA,MACPC,OAAO1E,QAAQ0E;AAAAA,MACfC,sBAAsB3E,QAAQ2E;AAAAA,MAC9BC,OAAO5E,QAAQ6E;AAAAA,IACjB,GACA,aAAa5C,cACb,OAAOD,YACP,mBAAiBjB,QAAQ,CAAC,GAAGlB,IAC7B,QAAQ6D,eACR,SAASI,gBACT,UAAUE,iBACV,WAAWL,gBACX,QAAQO,YAAY,YAAY,SAChC,eAAe5D,iBAAiB,CAAA;AAAA,EAEpC,EAAA,CAAA;AAEJ;AAGAX,iBAAiBmF,kBAAkB;;;"}
|
|
@@ -2,55 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const uikitStyles = require("@hitachivantara/uikit-styles");
|
|
4
4
|
const classes = require("../../../utils/classes.cjs");
|
|
5
|
-
const focusUtils = require("../../../utils/focusUtils.cjs");
|
|
6
5
|
const {
|
|
7
6
|
staticClasses,
|
|
8
7
|
useClasses
|
|
9
8
|
} = classes.createClasses("HvCalendarHeader", {
|
|
10
9
|
root: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"&:hover, &:focus": {
|
|
15
|
-
borderBottom: `1px solid ${uikitStyles.theme.colors.secondary}`
|
|
10
|
+
paddingBottom: uikitStyles.theme.space.md,
|
|
11
|
+
"&$invalid": {
|
|
12
|
+
paddingBottom: 0
|
|
16
13
|
}
|
|
17
14
|
},
|
|
18
15
|
invalid: {},
|
|
19
16
|
headerDayOfWeek: {
|
|
20
|
-
color: uikitStyles.theme.colors.secondary_80
|
|
21
|
-
paddingLeft: uikitStyles.theme.spacing("xs")
|
|
17
|
+
color: uikitStyles.theme.colors.secondary_80
|
|
22
18
|
},
|
|
23
19
|
headerDate: {},
|
|
24
|
-
input: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
padding: `5px ${uikitStyles.theme.spacing("xs")}`,
|
|
28
|
-
fontFamily: uikitStyles.theme.fontFamily.body,
|
|
29
|
-
color: uikitStyles.theme.colors.secondary_80,
|
|
30
|
-
fontSize: uikitStyles.theme.fontSizes.base,
|
|
31
|
-
lineHeight: uikitStyles.theme.lineHeights.base,
|
|
32
|
-
fontWeight: uikitStyles.theme.fontWeights.normal,
|
|
33
|
-
width: "100%",
|
|
34
|
-
"&::placeholder": {
|
|
35
|
-
color: uikitStyles.theme.colors.secondary_60
|
|
36
|
-
},
|
|
37
|
-
"&:focus": {
|
|
38
|
-
outline: "none"
|
|
39
|
-
},
|
|
40
|
-
"&:focus-visible": {
|
|
41
|
-
...focusUtils.outlineStyles
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
inputBorderContainer: {
|
|
45
|
-
backgroundColor: uikitStyles.theme.colors.negative,
|
|
46
|
-
height: 1,
|
|
47
|
-
marginTop: -1
|
|
48
|
-
},
|
|
49
|
-
invalidMessageStyling: {
|
|
50
|
-
display: "flex",
|
|
51
|
-
alignItems: "center",
|
|
52
|
-
color: uikitStyles.theme.colors.negative
|
|
53
|
-
}
|
|
20
|
+
input: {},
|
|
21
|
+
inputBorderContainer: {},
|
|
22
|
+
invalidMessageStyling: {}
|
|
54
23
|
});
|
|
55
24
|
exports.staticClasses = staticClasses;
|
|
56
25
|
exports.useClasses = useClasses;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarHeader.styles.cjs","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\
|
|
1
|
+
{"version":3,"file":"CalendarHeader.styles.cjs","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvCalendarHeader\", {\n root: {\n paddingBottom: theme.space.md,\n\n \"&$invalid\": {\n paddingBottom: 0,\n },\n },\n invalid: {},\n headerDayOfWeek: {\n color: theme.colors.secondary_80,\n },\n headerDate: {},\n input: {},\n inputBorderContainer: {},\n invalidMessageStyling: {},\n});\n"],"names":["staticClasses","useClasses","createClasses","root","paddingBottom","theme","space","md","invalid","headerDayOfWeek","color","colors","secondary_80","headerDate","input","inputBorderContainer","invalidMessageStyling"],"mappings":";;;;AAIa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,oBAAoB;AAAA,EAC7EC,MAAM;AAAA,IACJC,eAAeC,YAAAA,MAAMC,MAAMC;AAAAA,IAE3B,aAAa;AAAA,MACXH,eAAe;AAAA,IACjB;AAAA,EACF;AAAA,EACAI,SAAS,CAAC;AAAA,EACVC,iBAAiB;AAAA,IACfC,OAAOL,YAAAA,MAAMM,OAAOC;AAAAA,EACtB;AAAA,EACAC,YAAY,CAAC;AAAA,EACbC,OAAO,CAAC;AAAA,EACRC,sBAAsB,CAAC;AAAA,EACvBC,uBAAuB,CAAC;AAC1B,CAAC;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDownMenu.cjs","sources":["../../../../src/components/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { ChangeEvent, useMemo } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\
|
|
1
|
+
{"version":3,"file":"DropDownMenu.cjs","sources":["../../../../src/components/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { ChangeEvent, useMemo } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { getPrevNextFocus } from \"@core/utils/focusableElementFinder\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvButton, HvButtonVariant } from \"@core/components/Button\";\nimport { HvList, HvListProps, HvListValue } from \"@core/components/List\";\nimport { HvPanel } from \"@core/components/Panel\";\n\nimport { staticClasses, useClasses } from \"./DropDownMenu.styles\";\n\nexport { staticClasses as dropDownMenuClasses };\n\nexport type HvDropDownMenuClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropDownMenuProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n /** Icon. */\n icon?: React.ReactElement;\n /**\n * A list containing the elements to be rendered.\n *\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - icon: The icon node to be rendered on the left.\n * - showNavIcon: If true renders the navigation icon on the right.\n */\n dataList: HvListValue[];\n /** Placement of the dropdown. */\n placement?: \"left\" | \"right\";\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Function executed on toggle of the dropdown. Should receive the open status. */\n onToggle?: (event: Event, open: boolean) => void;\n /** Function executed in each onClick. Should received the clicked element. */\n onClick?: (\n event: React.ChangeEvent<HTMLLIElement>,\n value: HvListValue\n ) => void;\n /** Keep the Dropdown Menu opened after clicking one option */\n keepOpened?: boolean;\n /** Defines if the component is disabled. */\n disabled?: boolean;\n /** If true it should be displayed open. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** The variant to be used in the header. */\n category?: HvButtonVariant;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDropDownMenuClasses;\n}\n\n/**\n * A drop-down menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.\n */\nexport const HvDropDownMenu = (props: HvDropDownMenuProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n icon,\n placement = \"right\",\n dataList,\n disablePortal = false,\n onToggle,\n onClick,\n keepOpened = true,\n disabled = false,\n expanded,\n defaultExpanded = false,\n category = \"secondaryGhost\",\n ...others\n } = useDefaultProps(\"HvDropDownMenu\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [open, setOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const id = useUniqueId(idProp, \"dropdown-menu\");\n const focusNodes = getPrevNextFocus(setId(id, \"icon-button\"));\n\n const listId = setId(id, \"list\");\n\n const handleClose = (event: ChangeEvent) => {\n // this will only run if uncontrolled\n setOpen(false);\n onToggle?.(event as any, false);\n };\n\n // If the ESCAPE key is pressed inside the list, the close handler must be called.\n const handleKeyDown: HvListProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Tab\")) {\n const node = event.shiftKey ? focusNodes.prevFocus : focusNodes.nextFocus;\n if (node) setTimeout(() => node.focus(), 0);\n handleClose(event as any);\n }\n event.preventDefault();\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n containerRef?.getElementsByTagName(\"li\")[0]?.focus();\n };\n\n const condensed = useMemo(() => dataList.every((el) => !el.icon), [dataList]);\n const popperStyle: HvBaseDropdownProps[\"popperProps\"] = {\n style: {\n zIndex: theme.zIndices.tooltip,\n width: \"auto\",\n position: \"relative\",\n },\n };\n\n return (\n <HvBaseDropdown\n id={id}\n className={cx(classes.container, className)}\n classes={{\n root: classes.root,\n container: classes.baseContainer,\n }}\n expanded={open && !disabled}\n component={\n <HvButton\n icon\n variant={category}\n id={setId(id, \"icon-button\")}\n className={cx(classes.icon, { [classes.iconSelected]: open })}\n aria-expanded={open}\n disabled={disabled}\n aria-label=\"Dropdown menu\"\n aria-haspopup=\"menu\"\n >\n {icon || (\n <MoreOptionsVertical\n aria-hidden\n color={disabled ? \"secondary_60\" : undefined}\n />\n )}\n </HvButton>\n }\n placement={placement}\n variableWidth\n disablePortal={disablePortal}\n onToggle={(e, s) => {\n // this will only run if uncontrolled\n setOpen(s);\n onToggle?.(e, s);\n }}\n disabled={disabled}\n onContainerCreation={setFocusToContent}\n popperProps={popperStyle}\n {...others}\n >\n <HvPanel className={classes.menuListRoot}>\n <HvList\n id={listId}\n values={dataList}\n selectable={false}\n condensed={condensed}\n onClick={(event, item) => {\n if (!keepOpened) handleClose(event);\n onClick?.(event, item);\n }}\n onKeyDown={handleKeyDown}\n classes={{\n root: classes.menuList,\n }}\n />\n </HvPanel>\n </HvBaseDropdown>\n );\n};\n"],"names":["HvDropDownMenu","props","id","idProp","classes","classesProp","className","icon","placement","dataList","disablePortal","onToggle","onClick","keepOpened","disabled","expanded","defaultExpanded","category","others","useDefaultProps","cx","useClasses","open","setOpen","useControlled","Boolean","useUniqueId","focusNodes","getPrevNextFocus","setId","listId","handleClose","event","handleKeyDown","isKey","node","shiftKey","prevFocus","nextFocus","setTimeout","focus","preventDefault","setFocusToContent","containerRef","getElementsByTagName","condensed","useMemo","every","el","popperStyle","style","zIndex","theme","zIndices","tooltip","width","position","jsx","HvBaseDropdown","container","root","baseContainer","HvButton","iconSelected","MoreOptionsVertical","undefined","e","s","HvPanel","menuListRoot","HvList","item","menuList"],"mappings":";;;;;;;;;;;;;;;;;AAqEaA,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC,IAAIC;AAAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC;AAAAA,IACAC;AAAAA,IACAC,aAAa;AAAA,IACbC,WAAW;AAAA,IACXC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,WAAW;AAAA,IACX,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,kBAAkBlB,KAAK;AAErC,QAAA;AAAA,IAAEG;AAAAA,IAASgB;AAAAA,EAAAA,IAAOC,oBAAAA,WAAWhB,WAAW;AACxC,QAAA,CAACiB,MAAMC,OAAO,IAAIC,cAAAA,cAAcT,UAAUU,QAAQT,eAAe,CAAC;AAClEd,QAAAA,KAAKwB,YAAAA,YAAYvB,QAAQ,eAAe;AAC9C,QAAMwB,aAAaC,uBAAAA,iBAAiBC,MAAAA,MAAM3B,IAAI,aAAa,CAAC;AAEtD4B,QAAAA,SAASD,MAAAA,MAAM3B,IAAI,MAAM;AAEzB6B,QAAAA,cAAcA,CAACC,UAAuB;AAE1CT,YAAQ,KAAK;AACbZ,eAAWqB,OAAc,KAAK;AAAA,EAAA;AAIhC,QAAMC,gBAA2CD,CAAU,UAAA;AACrDE,QAAAA,cAAAA,MAAMF,OAAO,KAAK,GAAG;AACvB,YAAMG,OAAOH,MAAMI,WAAWT,WAAWU,YAAYV,WAAWW;AAC5DH,UAAAA;AAAMI,mBAAW,MAAMJ,KAAKK,MAAM,GAAG,CAAC;AAC1CT,kBAAYC,KAAa;AAAA,IAC3B;AACAA,UAAMS,eAAe;AAAA,EAAA;AAGvB,QAAMC,oBACJC,CACG,iBAAA;AACHA,kBAAcC,qBAAqB,IAAI,EAAE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CpB,cAAUoB,OAAOuC,IAAI;AAAA,EAAA,GAEvB,WAAWtC,eACX,SAAS;AAAA,IACP2B,MAAMxD,QAAQoE;AAAAA,EAAAA,GACd,GAEN,EACF,CAAA;AAEJ;;;"}
|
|
@@ -42,7 +42,7 @@ const {
|
|
|
42
42
|
fill: uikitStyles.theme.colors.secondary
|
|
43
43
|
},
|
|
44
44
|
borderRadius: `${uikitStyles.theme.radii.base} ${uikitStyles.theme.radii.base} 0px 0px`,
|
|
45
|
-
border: `1px solid ${uikitStyles.theme.colors.
|
|
45
|
+
border: `1px solid ${uikitStyles.theme.colors.secondary}`
|
|
46
46
|
},
|
|
47
47
|
/** Styles applied to the list root. */
|
|
48
48
|
menuListRoot: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDownMenu.styles.cjs","sources":["../../../../src/components/DropDownMenu/DropDownMenu.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropDownMenu\", {\n /** Styles applied to the container. */\n container: {\n width: 32,\n },\n /** Styles applied to the BaseDropdown container. */\n baseContainer: {},\n /** Styles applied to the root. */\n root: {\n display: \"inline-block\",\n width: \"auto\",\n \"&:focus-visible $icon\": {\n ...outlineStyles,\n },\n },\n /** Styles applied to the icon. */\n icon: {\n position: \"relative\",\n width: 32,\n height: 32,\n boxSizing: \"border-box\",\n padding: 0,\n borderRadius: theme.radii.base,\n border: \"1px solid transparent\",\n },\n /** Styles applied to the icon when selected. */\n iconSelected: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n\n \"&:hover\": {\n backgroundColor: theme.colors.atmo1,\n },\n\n \"& svg .color0\": {\n fill: theme.colors.secondary,\n },\n\n borderRadius: `${theme.radii.base} ${theme.radii.base} 0px 0px`,\n border: `1px solid ${theme.colors.
|
|
1
|
+
{"version":3,"file":"DropDownMenu.styles.cjs","sources":["../../../../src/components/DropDownMenu/DropDownMenu.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropDownMenu\", {\n /** Styles applied to the container. */\n container: {\n width: 32,\n },\n /** Styles applied to the BaseDropdown container. */\n baseContainer: {},\n /** Styles applied to the root. */\n root: {\n display: \"inline-block\",\n width: \"auto\",\n \"&:focus-visible $icon\": {\n ...outlineStyles,\n },\n },\n /** Styles applied to the icon. */\n icon: {\n position: \"relative\",\n width: 32,\n height: 32,\n boxSizing: \"border-box\",\n padding: 0,\n borderRadius: theme.radii.base,\n border: \"1px solid transparent\",\n },\n /** Styles applied to the icon when selected. */\n iconSelected: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n\n \"&:hover\": {\n backgroundColor: theme.colors.atmo1,\n },\n\n \"& svg .color0\": {\n fill: theme.colors.secondary,\n },\n\n borderRadius: `${theme.radii.base} ${theme.radii.base} 0px 0px`,\n border: `1px solid ${theme.colors.secondary}`,\n },\n /** Styles applied to the list root. */\n menuListRoot: {},\n /** Styles applied to the list. */\n menuList: {},\n});\n"],"names":["staticClasses","useClasses","createClasses","container","width","baseContainer","root","display","outlineStyles","icon","position","height","boxSizing","padding","borderRadius","theme","radii","base","border","iconSelected","backgroundColor","colors","atmo1","boxShadow","shadow","fill","secondary","menuListRoot","menuList"],"mappings":";;;;;AAKa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,QAAAA,cAAc,kBAAkB;AAAA;AAAA,EAE3EC,WAAW;AAAA,IACTC,OAAO;AAAA,EACT;AAAA;AAAA,EAEAC,eAAe,CAAC;AAAA;AAAA,EAEhBC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTH,OAAO;AAAA,IACP,yBAAyB;AAAA,MACvB,GAAGI,WAAAA;AAAAA,IACL;AAAA,EACF;AAAA;AAAA,EAEAC,MAAM;AAAA,IACJC,UAAU;AAAA,IACVN,OAAO;AAAA,IACPO,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,SAAS;AAAA,IACTC,cAAcC,YAAAA,MAAMC,MAAMC;AAAAA,IAC1BC,QAAQ;AAAA,EACV;AAAA;AAAA,EAEAC,cAAc;AAAA,IACZC,iBAAiBL,YAAAA,MAAMM,OAAOC;AAAAA,IAC9BC,WAAWR,YAAAA,MAAMM,OAAOG;AAAAA,IAExB,WAAW;AAAA,MACTJ,iBAAiBL,YAAAA,MAAMM,OAAOC;AAAAA,IAChC;AAAA,IAEA,iBAAiB;AAAA,MACfG,MAAMV,YAAAA,MAAMM,OAAOK;AAAAA,IACrB;AAAA,IAEAZ,cAAe,GAAEC,YAAMC,MAAAA,MAAMC,IAAK,IAAGF,kBAAMC,MAAMC,IAAK;AAAA,IACtDC,QAAS,aAAYH,YAAMM,MAAAA,OAAOK,SAAU;AAAA,EAC9C;AAAA;AAAA,EAEAC,cAAc,CAAC;AAAA;AAAA,EAEfC,UAAU,CAAC;AACb,CAAC;;;"}
|
|
@@ -22,6 +22,7 @@ const cleanHidden = (lst) => lst.map((item) => ({
|
|
|
22
22
|
isHidden: false
|
|
23
23
|
}));
|
|
24
24
|
const valuesExist = (values) => values != null && values?.length > 0;
|
|
25
|
+
const getSelectedIds = (list) => utils.getSelected(list).map((item) => item.id || item.label);
|
|
25
26
|
const HvDropdownList = (props) => {
|
|
26
27
|
const {
|
|
27
28
|
id,
|
|
@@ -53,6 +54,9 @@ const HvDropdownList = (props) => {
|
|
|
53
54
|
width,
|
|
54
55
|
height
|
|
55
56
|
} = React.useContext(BaseDropdownContext.default);
|
|
57
|
+
const hasChanges = React.useMemo(() => {
|
|
58
|
+
return String(getSelectedIds(values)) !== String(getSelectedIds(list));
|
|
59
|
+
}, [list, values]);
|
|
56
60
|
const newLabels = {
|
|
57
61
|
selectAll: labels?.selectAll,
|
|
58
62
|
selectionConjunction: labels?.multiSelectionConjunction
|
|
@@ -140,7 +144,7 @@ const HvDropdownList = (props) => {
|
|
|
140
144
|
const applyLabel = labels?.applyLabel;
|
|
141
145
|
const cancelLabel = labels?.cancelLabel;
|
|
142
146
|
return /* @__PURE__ */ jsxRuntime.jsxs(ActionBar.HvActionBar, { id: setId.setId(id, "actions"), children: [
|
|
143
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button.HvButton, { id: setId.setId(id, "actions-apply"), onClick: () => onChange(cleanHidden(list), true, true, true), variant: "primaryGhost", children: applyLabel }),
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button.HvButton, { id: setId.setId(id, "actions-apply"), disabled: !hasChanges, onClick: () => onChange(cleanHidden(list), true, true, true), variant: "primaryGhost", children: applyLabel }),
|
|
144
148
|
/* @__PURE__ */ jsxRuntime.jsx(Button.HvButton, { id: setId.setId(id, "actions-cancel"), onClick: onCancel, variant: "primaryGhost", children: cancelLabel })
|
|
145
149
|
] });
|
|
146
150
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.cjs","sources":["../../../../../src/components/Dropdown/List/List.tsx"],"sourcesContent":["import { MouseEvent, useContext, useEffect, useState } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport { HvInput } from \"@core/components/Input\";\nimport { HvList, HvListProps, HvListValue } from \"@core/components/List\";\nimport { HvActionBar } from \"@core/components/ActionBar\";\nimport BaseDropdownContext from \"@core/components/BaseDropdown/BaseDropdownContext\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { staticClasses, useClasses } from \"./List.styles\";\nimport { getSelected } from \"../utils\";\nimport { HvDropdownLabelsProps } from \"../types\";\n\nexport { staticClasses as dropdownListClasses };\n\nexport type HvDropdownListClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownListProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvDropdownListClasses;\n /**\n * The list to be rendered.\n */\n values?: HvListValue[];\n /**\n * If true renders a multi select list.\n */\n multiSelect?: boolean;\n /**\n * If true renders the search component.\n */\n showSearch?: boolean;\n /**\n * A function to be executed whenever a item is selected in the list\n * or the Apply button is activated (when `multiSelect` is `true`).\n */\n onChange: (\n /** An array containing the selected values */\n listValues: HvListValue[],\n /** If `true` the selection if finally committed the dropdown header text should reflect the new selection */\n commitChanges: boolean,\n /** If `true` the dropdown should toggle it's current state */\n toggle: boolean,\n /** If `true` the dropdown will call onChange */\n notifyChanges: boolean\n ) => void;\n /**\n * A function to be executed whenever the Cancel button is activated.\n */\n onCancel: (event: MouseEvent) => void;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Max height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class.\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n}\n\n/**\n * The values property was being deeply cloned. That created a significant performance\n * hit when the values contained complex properties' values, like React Nodes.\n *\n * For minimizing the impact of removing the clone, a shallow clone of the array and its\n * objects is performed instead. That should have the same effect in the majority of the\n * cases, where the properties' values are primitive.\n */\nconst clone = (values: HvListValue[]) => values.map((value) => ({ ...value }));\n\n/**\n * Set all hidden's to false.\n */\nconst cleanHidden = (lst: HvListValue[]) =>\n lst.map((item) => ({ ...item, isHidden: false }));\n\nconst valuesExist = (values: HvListValue[]) =>\n values != null && values?.length > 0;\n\nexport const HvDropdownList = (props: HvDropdownListProps) => {\n const {\n id,\n classes: classesProp,\n values = [],\n multiSelect = false,\n showSearch = false,\n onChange,\n onCancel,\n labels,\n notifyChangesOnFirstRender = false,\n hasTooltips = false,\n singleSelectionToggle,\n height: dropdownHeight,\n maxHeight,\n virtualized = false,\n ...others\n } = useDefaultProps(\"HvDropdownList\", props);\n const { classes, cx, css } = useClasses(classesProp);\n\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [list, setList] = useState<HvListValue[]>(clone(values));\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n const { width, height } = useContext(BaseDropdownContext);\n\n const newLabels = {\n selectAll: labels?.selectAll,\n selectionConjunction: labels?.multiSelectionConjunction,\n };\n\n /**\n * Update states associated with select all.\n */\n const updateSelectAll = (listValues: HvListValue[]) => {\n if (!listValues) return;\n const nbrSelected = getSelected(listValues).length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === listValues.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n };\n\n /**\n * After the first render, call onChange if notifyChangesOnFirstRender.\n */\n useEffect(() => {\n if (!valuesExist(values)) return;\n setList(clone(values));\n updateSelectAll(values);\n if (notifyChangesOnFirstRender) {\n onChange?.(values, false, false, true);\n }\n }, [values, notifyChangesOnFirstRender, onChange]);\n\n /**\n * Sets the filtered values to the state.\n *\n * @param {String} str - The value that is being looked.\n */\n const handleSearch = (str: string) => {\n const results = list\n ? list.filter(\n ({\n searchValue,\n label,\n value,\n }: {\n searchValue?: any;\n label?: any;\n value?: any;\n }) => {\n let stringValue = \"\";\n if (\n typeof searchValue === \"string\" ||\n searchValue instanceof String\n ) {\n stringValue = searchValue.toLowerCase();\n } else if (typeof label === \"string\" || label instanceof String) {\n stringValue = label.toLowerCase();\n } else if (typeof value === \"string\" || value instanceof String) {\n stringValue = value.toLowerCase();\n }\n\n return stringValue.indexOf(str.toLowerCase()) >= 0;\n }\n )\n : null;\n\n if (results != null) {\n const newList = list.map((elem) => {\n const isResult = results.find((result) => result.label === elem.label);\n return { ...elem, isHidden: !isResult };\n });\n\n setList(newList);\n setSearchStr(str);\n }\n return str;\n };\n\n /**\n * Create search element.\n *\n * @returns {*}\n */\n const renderSearch = () => (\n <div className={classes.searchContainer}>\n <HvInput\n id={setId(id, \"search\")}\n type=\"search\"\n value={searchStr}\n placeholder={labels?.searchPlaceholder}\n aria-label={labels?.searchPlaceholder}\n onChange={(event, str) => handleSearch(str)}\n />\n </div>\n );\n\n /**\n * Select all the values inside the dropdown.\n *\n */\n const handleSelectAll = () => {\n const newList = list.map((elem) => ({ ...elem, selected: !anySelected }));\n setList(newList);\n updateSelectAll(newList);\n };\n\n /**\n * Create selecteAll component.\n *\n * @returns {*}\n */\n const renderSelectAll = () => {\n const selectAll = labels?.selectAll;\n const multiSelectionConjunction = labels?.multiSelectionConjunction;\n const nbrSelected = getSelected(list).length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${multiSelectionConjunction} ${list.length}`}\n </>\n ) : (\n <>\n <b>{selectAll}</b>\n {` (${list.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <div className={classes.selectAllContainer}>\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n classes={{\n container: classes.selection,\n }}\n className={classes.selectAll}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n );\n };\n\n /**\n * When selecting the state list is updated with the corresponding selection.\n *\n * @param listValues - elements selected.\n */\n const onSelection: HvListProps[\"onChange\"] = (listValues) => {\n if (!multiSelect) {\n onChange(cleanHidden(listValues), true, true, true);\n } else {\n updateSelectAll(listValues);\n setList(clone(listValues));\n }\n };\n\n /**\n * Render action buttons.\n */\n const renderActions = () => {\n const applyLabel = labels?.applyLabel;\n const cancelLabel = labels?.cancelLabel;\n return (\n <HvActionBar id={setId(id, \"actions\")}>\n <HvButton\n id={setId(id, \"actions-apply\")}\n onClick={() => onChange(cleanHidden(list), true, true, true)}\n variant=\"primaryGhost\"\n >\n {applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"actions-cancel\")}\n onClick={onCancel}\n variant=\"primaryGhost\"\n >\n {cancelLabel}\n </HvButton>\n </HvActionBar>\n );\n };\n\n const showList = valuesExist(values);\n\n return (\n <div className={classes.rootList}>\n <div className={classes.listBorderDown} />\n <div className={classes.listContainer}>\n {showSearch && renderSearch()}\n {showList && multiSelect && renderSelectAll()}\n {showList && (\n <HvList\n id={setId(id, \"list\")}\n classes={{\n root: cx(\n classes.dropdownListContainer,\n css({\n maxWidth: width,\n maxHeight:\n maxHeight ??\n `calc(${height}px - 32px - ${theme.space.xs} - ${theme.space.sm})`,\n overflow: \"auto\",\n padding: 4,\n margin: -4,\n }),\n dropdownHeight &&\n css({\n height: dropdownHeight,\n }),\n virtualized &&\n css({\n maxWidth: \"inherit\",\n maxHeight: \"inherit\",\n overflow: \"inherit\",\n padding: 0,\n })\n ),\n }}\n values={list}\n multiSelect={multiSelect}\n useSelector={multiSelect}\n showSelectAll={false}\n onChange={onSelection}\n labels={newLabels}\n hasTooltips={hasTooltips}\n selectable\n condensed\n singleSelectionToggle={singleSelectionToggle}\n height={dropdownHeight}\n virtualized={virtualized}\n {...others}\n />\n )}\n </div>\n {showList && multiSelect ? renderActions() : null}\n </div>\n );\n};\n"],"names":["clone","values","map","value","cleanHidden","lst","item","isHidden","valuesExist","length","HvDropdownList","props","id","classes","classesProp","multiSelect","showSearch","onChange","onCancel","labels","notifyChangesOnFirstRender","hasTooltips","singleSelectionToggle","height","dropdownHeight","maxHeight","virtualized","others","useDefaultProps","cx","css","useClasses","searchStr","setSearchStr","useState","list","setList","allSelected","setAllSelected","anySelected","setAnySelected","width","useContext","BaseDropdownContext","newLabels","selectAll","selectionConjunction","multiSelectionConjunction","updateSelectAll","listValues","nbrSelected","getSelected","hasSelection","allSelect","useEffect","handleSearch","str","results","filter","searchValue","label","stringValue","String","toLowerCase","indexOf","newList","elem","isResult","find","result","renderSearch","jsx","searchContainer","HvInput","setId","searchPlaceholder","event","handleSelectAll","selected","renderSelectAll","defaultLabel","HvTypography","jsxs","Fragment","selectAllContainer","HvCheckBox","container","selection","onSelection","renderActions","applyLabel","cancelLabel","HvActionBar","HvButton","showList","rootList","listBorderDown","listContainer","HvList","root","dropdownListContainer","maxWidth","theme","space","xs","sm","overflow","padding","margin"],"mappings":";;;;;;;;;;;;;;;;AAqGA,MAAMA,QAAQA,CAACC,WAA0BA,OAAOC,IAAKC,CAAW,WAAA;AAAA,EAAE,GAAGA;AAAM,EAAE;AAK7E,MAAMC,cAAcA,CAACC,QACnBA,IAAIH,IAAKI,CAAU,UAAA;AAAA,EAAE,GAAGA;AAAAA,EAAMC,UAAU;AAAM,EAAE;AAElD,MAAMC,cAAcA,CAACP,WACnBA,UAAU,QAAQA,QAAQQ,SAAS;AAExBC,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTb,SAAS,CAAE;AAAA,IACXc,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,6BAA6B;AAAA,IAC7BC,cAAc;AAAA,IACdC;AAAAA,IACAC,QAAQC;AAAAA,IACRC;AAAAA,IACAC,cAAc;AAAA,IACd,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,kBAAkBjB,KAAK;AACrC,QAAA;AAAA,IAAEE;AAAAA,IAASgB;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,YAAAA,WAAWjB,WAAW;AAEnD,QAAM,CAACkB,WA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/Dropdown/List/List.tsx"],"sourcesContent":["import { MouseEvent, useContext, useEffect, useMemo, useState } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport { HvInput } from \"@core/components/Input\";\nimport { HvList, HvListProps, HvListValue } from \"@core/components/List\";\nimport { HvActionBar } from \"@core/components/ActionBar\";\nimport BaseDropdownContext from \"@core/components/BaseDropdown/BaseDropdownContext\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { staticClasses, useClasses } from \"./List.styles\";\nimport { getSelected } from \"../utils\";\nimport { HvDropdownLabelsProps } from \"../types\";\n\nexport { staticClasses as dropdownListClasses };\n\nexport type HvDropdownListClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownListProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvDropdownListClasses;\n /**\n * The list to be rendered.\n */\n values?: HvListValue[];\n /**\n * If true renders a multi select list.\n */\n multiSelect?: boolean;\n /**\n * If true renders the search component.\n */\n showSearch?: boolean;\n /**\n * A function to be executed whenever a item is selected in the list\n * or the Apply button is activated (when `multiSelect` is `true`).\n */\n onChange: (\n /** An array containing the selected values */\n listValues: HvListValue[],\n /** If `true` the selection if finally committed the dropdown header text should reflect the new selection */\n commitChanges: boolean,\n /** If `true` the dropdown should toggle it's current state */\n toggle: boolean,\n /** If `true` the dropdown will call onChange */\n notifyChanges: boolean\n ) => void;\n /**\n * A function to be executed whenever the Cancel button is activated.\n */\n onCancel: (event: MouseEvent) => void;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Max height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class.\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n}\n\n/**\n * The values property was being deeply cloned. That created a significant performance\n * hit when the values contained complex properties' values, like React Nodes.\n *\n * For minimizing the impact of removing the clone, a shallow clone of the array and its\n * objects is performed instead. That should have the same effect in the majority of the\n * cases, where the properties' values are primitive.\n */\nconst clone = (values: HvListValue[]) => values.map((value) => ({ ...value }));\n\n/**\n * Set all hidden's to false.\n */\nconst cleanHidden = (lst: HvListValue[]) =>\n lst.map((item) => ({ ...item, isHidden: false }));\n\nconst valuesExist = (values: HvListValue[]) =>\n values != null && values?.length > 0;\n\n/** Filter selected ordered element `id`s (or `label`) */\nconst getSelectedIds = (list: HvListValue[]) =>\n getSelected(list).map((item) => item.id || item.label);\n\nexport const HvDropdownList = (props: HvDropdownListProps) => {\n const {\n id,\n classes: classesProp,\n values = [],\n multiSelect = false,\n showSearch = false,\n onChange,\n onCancel,\n labels,\n notifyChangesOnFirstRender = false,\n hasTooltips = false,\n singleSelectionToggle,\n height: dropdownHeight,\n maxHeight,\n virtualized = false,\n ...others\n } = useDefaultProps(\"HvDropdownList\", props);\n const { classes, cx, css } = useClasses(classesProp);\n\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [list, setList] = useState<HvListValue[]>(clone(values));\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n const { width, height } = useContext(BaseDropdownContext);\n\n const hasChanges = useMemo(() => {\n return String(getSelectedIds(values)) !== String(getSelectedIds(list));\n }, [list, values]);\n\n const newLabels = {\n selectAll: labels?.selectAll,\n selectionConjunction: labels?.multiSelectionConjunction,\n };\n\n /**\n * Update states associated with select all.\n */\n const updateSelectAll = (listValues: HvListValue[]) => {\n if (!listValues) return;\n const nbrSelected = getSelected(listValues).length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === listValues.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n };\n\n /**\n * After the first render, call onChange if notifyChangesOnFirstRender.\n */\n useEffect(() => {\n if (!valuesExist(values)) return;\n setList(clone(values));\n updateSelectAll(values);\n if (notifyChangesOnFirstRender) {\n onChange?.(values, false, false, true);\n }\n }, [values, notifyChangesOnFirstRender, onChange]);\n\n /**\n * Sets the filtered values to the state.\n *\n * @param {String} str - The value that is being looked.\n */\n const handleSearch = (str: string) => {\n const results = list\n ? list.filter(\n ({\n searchValue,\n label,\n value,\n }: {\n searchValue?: any;\n label?: any;\n value?: any;\n }) => {\n let stringValue = \"\";\n if (\n typeof searchValue === \"string\" ||\n searchValue instanceof String\n ) {\n stringValue = searchValue.toLowerCase();\n } else if (typeof label === \"string\" || label instanceof String) {\n stringValue = label.toLowerCase();\n } else if (typeof value === \"string\" || value instanceof String) {\n stringValue = value.toLowerCase();\n }\n\n return stringValue.indexOf(str.toLowerCase()) >= 0;\n }\n )\n : null;\n\n if (results != null) {\n const newList = list.map((elem) => {\n const isResult = results.find((result) => result.label === elem.label);\n return { ...elem, isHidden: !isResult };\n });\n\n setList(newList);\n setSearchStr(str);\n }\n return str;\n };\n\n /**\n * Create search element.\n *\n * @returns {*}\n */\n const renderSearch = () => (\n <div className={classes.searchContainer}>\n <HvInput\n id={setId(id, \"search\")}\n type=\"search\"\n value={searchStr}\n placeholder={labels?.searchPlaceholder}\n aria-label={labels?.searchPlaceholder}\n onChange={(event, str) => handleSearch(str)}\n />\n </div>\n );\n\n /**\n * Select all the values inside the dropdown.\n *\n */\n const handleSelectAll = () => {\n const newList = list.map((elem) => ({ ...elem, selected: !anySelected }));\n setList(newList);\n updateSelectAll(newList);\n };\n\n /**\n * Create selecteAll component.\n *\n * @returns {*}\n */\n const renderSelectAll = () => {\n const selectAll = labels?.selectAll;\n const multiSelectionConjunction = labels?.multiSelectionConjunction;\n const nbrSelected = getSelected(list).length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${multiSelectionConjunction} ${list.length}`}\n </>\n ) : (\n <>\n <b>{selectAll}</b>\n {` (${list.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <div className={classes.selectAllContainer}>\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n classes={{\n container: classes.selection,\n }}\n className={classes.selectAll}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n );\n };\n\n /**\n * When selecting the state list is updated with the corresponding selection.\n *\n * @param listValues - elements selected.\n */\n const onSelection: HvListProps[\"onChange\"] = (listValues) => {\n if (!multiSelect) {\n onChange(cleanHidden(listValues), true, true, true);\n } else {\n updateSelectAll(listValues);\n setList(clone(listValues));\n }\n };\n\n /**\n * Render action buttons.\n */\n const renderActions = () => {\n const applyLabel = labels?.applyLabel;\n const cancelLabel = labels?.cancelLabel;\n return (\n <HvActionBar id={setId(id, \"actions\")}>\n <HvButton\n id={setId(id, \"actions-apply\")}\n disabled={!hasChanges}\n onClick={() => onChange(cleanHidden(list), true, true, true)}\n variant=\"primaryGhost\"\n >\n {applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"actions-cancel\")}\n onClick={onCancel}\n variant=\"primaryGhost\"\n >\n {cancelLabel}\n </HvButton>\n </HvActionBar>\n );\n };\n\n const showList = valuesExist(values);\n\n return (\n <div className={classes.rootList}>\n <div className={classes.listBorderDown} />\n <div className={classes.listContainer}>\n {showSearch && renderSearch()}\n {showList && multiSelect && renderSelectAll()}\n {showList && (\n <HvList\n id={setId(id, \"list\")}\n classes={{\n root: cx(\n classes.dropdownListContainer,\n css({\n maxWidth: width,\n maxHeight:\n maxHeight ??\n `calc(${height}px - 32px - ${theme.space.xs} - ${theme.space.sm})`,\n overflow: \"auto\",\n padding: 4,\n margin: -4,\n }),\n dropdownHeight &&\n css({\n height: dropdownHeight,\n }),\n virtualized &&\n css({\n maxWidth: \"inherit\",\n maxHeight: \"inherit\",\n overflow: \"inherit\",\n padding: 0,\n })\n ),\n }}\n values={list}\n multiSelect={multiSelect}\n useSelector={multiSelect}\n showSelectAll={false}\n onChange={onSelection}\n labels={newLabels}\n hasTooltips={hasTooltips}\n selectable\n condensed\n singleSelectionToggle={singleSelectionToggle}\n height={dropdownHeight}\n virtualized={virtualized}\n {...others}\n />\n )}\n </div>\n {showList && multiSelect ? renderActions() : null}\n </div>\n );\n};\n"],"names":["clone","values","map","value","cleanHidden","lst","item","isHidden","valuesExist","length","getSelectedIds","list","getSelected","id","label","HvDropdownList","props","classes","classesProp","multiSelect","showSearch","onChange","onCancel","labels","notifyChangesOnFirstRender","hasTooltips","singleSelectionToggle","height","dropdownHeight","maxHeight","virtualized","others","useDefaultProps","cx","css","useClasses","searchStr","setSearchStr","useState","setList","allSelected","setAllSelected","anySelected","setAnySelected","width","useContext","BaseDropdownContext","hasChanges","useMemo","String","newLabels","selectAll","selectionConjunction","multiSelectionConjunction","updateSelectAll","listValues","nbrSelected","hasSelection","allSelect","useEffect","handleSearch","str","results","filter","searchValue","stringValue","toLowerCase","indexOf","newList","elem","isResult","find","result","renderSearch","jsx","searchContainer","HvInput","setId","searchPlaceholder","event","handleSelectAll","selected","renderSelectAll","defaultLabel","HvTypography","jsxs","Fragment","selectAllContainer","HvCheckBox","container","selection","onSelection","renderActions","applyLabel","cancelLabel","HvActionBar","HvButton","showList","rootList","listBorderDown","listContainer","HvList","root","dropdownListContainer","maxWidth","theme","space","xs","sm","overflow","padding","margin"],"mappings":";;;;;;;;;;;;;;;;AAqGA,MAAMA,QAAQA,CAACC,WA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F,UACtB,UAAA;AAAA,IAACxB,2BAAAA,IAAA,OAAA,EAAI,WAAWzD,QAAQkF,eAAe,CAAA;AAAA,IACtCd,2BAAA,KAAA,OAAA,EAAI,WAAWpE,QAAQmF,eACrBhF,UAAAA;AAAAA,MAAAA,cAAcqD,aAAa;AAAA,MAC3BwB,YAAY9E,eAAe+D,gBAAgB;AAAA,MAC3Ce,2CACEI,KAAAA,QACC,EAAA,IAAIxB,MAAAA,MAAMhE,IAAI,MAAM,GACpB,SAAS;AAAA,QACPyF,MAAMrE,GACJhB,QAAQsF,uBACRrE,IAAI;AAAA,UACFsE,UAAU5D;AAAAA,UACVf,WACEA,aACC,QAAOF,MAAO,eAAc8E,YAAMC,MAAAA,MAAMC,EAAG,MAAKF,YAAAA,MAAMC,MAAME,EAAG;AAAA,UAClEC,UAAU;AAAA,UACVC,SAAS;AAAA,UACTC,QAAQ;AAAA,QAAA,CACT,GACDnF,kBACEM,IAAI;AAAA,UACFP,QAAQC;AAAAA,QAAAA,CACT,GACHE,eACEI,IAAI;AAAA,UACFsE,UAAU;AAAA,UACV3E,WAAW;AAAA,UACXgF,UAAU;AAAA,UACVC,SAAS;AAAA,QAAA,CACV,CACL;AAAA,MACF,GACA,QAAQnG,MACR,aACA,aAAaQ,aACb,eAAe,OACf,UAAUwE,aACV,QAAQzC,WACR,aACA,YAAU,MACV,WAAS,MACT,uBACA,QAAQtB,gBACR,aACIG,GAAAA,QAEP;AAAA,IAAA,GACH;AAAA,IACCkE,YAAY9E,cAAcyE,cAAAA,IAAkB;AAAA,EAC/C,EAAA,CAAA;AAEJ;;;"}
|
|
@@ -17,6 +17,10 @@ const {
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
disabled: {
|
|
20
|
+
"& $inputRoot": {
|
|
21
|
+
backgroundColor: theme.colors.atmo2,
|
|
22
|
+
borderColor: theme.colors.secondary_60
|
|
23
|
+
},
|
|
20
24
|
"& $inputBorderContainer": {
|
|
21
25
|
backgroundColor: theme.colors.atmo4
|
|
22
26
|
},
|
|
@@ -81,19 +85,19 @@ const {
|
|
|
81
85
|
"& $inputRootMultiline": {
|
|
82
86
|
"& $input": {
|
|
83
87
|
border: `1px solid ${theme.colors.secondary_60}`,
|
|
84
|
-
backgroundColor:
|
|
88
|
+
backgroundColor: theme.colors.atmo2
|
|
85
89
|
}
|
|
86
90
|
},
|
|
87
91
|
"&:hover $inputRootMultiline": {
|
|
88
92
|
"& $input": {
|
|
89
93
|
border: `1px solid ${theme.colors.secondary_60}`,
|
|
90
|
-
backgroundColor:
|
|
94
|
+
backgroundColor: theme.colors.atmo2
|
|
91
95
|
}
|
|
92
96
|
},
|
|
93
97
|
"&:focus-within $inputRootMultiline": {
|
|
94
98
|
"& $input": {
|
|
95
99
|
border: `1px solid ${theme.colors.secondary_60}`,
|
|
96
|
-
backgroundColor:
|
|
100
|
+
backgroundColor: theme.colors.atmo2
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
},
|
|
@@ -110,14 +114,14 @@ const {
|
|
|
110
114
|
},
|
|
111
115
|
inputRootReadOnly: {
|
|
112
116
|
borderColor: theme.colors.secondary_60,
|
|
113
|
-
backgroundColor:
|
|
117
|
+
backgroundColor: theme.colors.atmo2
|
|
114
118
|
},
|
|
115
119
|
inputRoot: {
|
|
116
120
|
margin: 0,
|
|
117
121
|
width: "100%",
|
|
118
122
|
borderRadius: theme.radii.base,
|
|
119
123
|
height: "32px",
|
|
120
|
-
border: `1px solid ${theme.colors.
|
|
124
|
+
border: `1px solid ${theme.colors.secondary}`,
|
|
121
125
|
boxSizing: "border-box",
|
|
122
126
|
backgroundColor: theme.colors.atmo1,
|
|
123
127
|
fontFamily: theme.fontFamily.body,
|
|
@@ -135,23 +139,17 @@ const {
|
|
|
135
139
|
}
|
|
136
140
|
},
|
|
137
141
|
inputRootFocused: {
|
|
138
|
-
|
|
142
|
+
backgroundColor: theme.colors.atmo1,
|
|
139
143
|
...outlineStyles,
|
|
140
144
|
"&:hover": {
|
|
141
|
-
|
|
145
|
+
backgroundColor: theme.colors.atmo1
|
|
142
146
|
},
|
|
143
|
-
"
|
|
144
|
-
backgroundColor:
|
|
147
|
+
"&$inputRootReadOnly": {
|
|
148
|
+
backgroundColor: theme.colors.atmo2
|
|
145
149
|
}
|
|
146
150
|
},
|
|
147
151
|
inputRootDisabled: {
|
|
148
|
-
background: theme.colors.atmo2,
|
|
149
|
-
borderColor: theme.colors.secondary_60,
|
|
150
152
|
cursor: "not-allowed",
|
|
151
|
-
"&:hover": {
|
|
152
|
-
background: theme.colors.atmo2,
|
|
153
|
-
cursor: "not-allowed"
|
|
154
|
-
},
|
|
155
153
|
"&&::before": {
|
|
156
154
|
borderBottomStyle: "none"
|
|
157
155
|
}
|
|
@@ -163,7 +161,7 @@ const {
|
|
|
163
161
|
border: "none",
|
|
164
162
|
height: "auto",
|
|
165
163
|
"& $input": {
|
|
166
|
-
border: `1px solid ${theme.colors.
|
|
164
|
+
border: `1px solid ${theme.colors.secondary}`,
|
|
167
165
|
borderRadius: theme.radii.base,
|
|
168
166
|
backgroundColor: theme.colors.atmo1,
|
|
169
167
|
height: "auto",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInput.styles.js","sources":["../../../../src/components/BaseInput/BaseInput.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvBaseInput\", {\n root: {\n display: \"inline-block\",\n width: \"100%\",\n position: \"relative\",\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n },\n disabled: {\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&& $input\": {\n color: theme.colors.secondary_60,\n WebkitTextFillColor: theme.colors.secondary_60,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n },\n invalid: {\n \"&:not(.disabled)\": {\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n },\n },\n resizable: { width: \"auto\" },\n readOnly: {\n \"& $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: \"transparent\",\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: \"transparent\",\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: \"transparent\",\n },\n },\n },\n inputBorderContainer: {\n position: \"absolute\",\n width: \"calc(100% - 4px)\",\n height: \"0px\",\n top: \"31px\",\n left: \"2px\",\n backgroundColor: theme.colors.atmo4,\n },\n inputRootInvalid: { borderColor: theme.colors.negative },\n inputRootReadOnly: {\n borderColor: theme.colors.secondary_60,\n backgroundColor: \"transparent\",\n },\n inputRoot: {\n margin: 0,\n width: \"100%\",\n borderRadius: theme.radii.base,\n height: \"32px\",\n border: `1px solid ${theme.colors.secondary_80}`,\n boxSizing: \"border-box\",\n backgroundColor: theme.colors.atmo1,\n fontFamily: theme.fontFamily.body,\n\n \"&:hover:not($inputRootDisabled):not($inputRootInvalid):not($inputRootReadOnly)\":\n {\n borderColor: theme.colors.primary,\n },\n\n \"&:hover:not($inputRootDisabled)::before\": {\n borderBottom: \"none\",\n },\n\n \"&::before\": {\n borderBottom: \"none\",\n },\n\n \"&::after\": {\n borderBottom: \"none\",\n },\n },\n inputRootFocused: {\n background: theme.colors.atmo1,\n ...outlineStyles,\n\n \"&:hover\": {\n background: theme.colors.atmo1,\n },\n\n \"& $inputRootReadOnly\": {\n backgroundColor: \"transparent\",\n },\n },\n inputRootDisabled: {\n background: theme.colors.atmo2,\n borderColor: theme.colors.secondary_60,\n cursor: \"not-allowed\",\n\n \"&:hover\": {\n background: theme.colors.atmo2,\n cursor: \"not-allowed\",\n },\n\n \"&&::before\": {\n borderBottomStyle: \"none\",\n },\n },\n inputRootMultiline: {\n padding: 0,\n backgroundColor: \"transparent\",\n overflow: \"auto\",\n border: \"none\",\n height: \"auto\",\n\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_80}`,\n borderRadius: theme.radii.base,\n backgroundColor: theme.colors.atmo1,\n height: \"auto\",\n minHeight: \"21px\",\n padding: \"5px 10px\",\n overflow: \"auto\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n\n \"&:hover\": {\n border: `1px solid ${theme.colors.primary}`,\n },\n },\n },\n input: {\n height: \"19px\",\n marginLeft: theme.space.xs,\n marginRight: theme.space.xs,\n padding: \"6px 0 5px\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n outline: \"none\",\n width: \"initial\",\n flexGrow: 1,\n ...(theme.typography.body as CSSProperties),\n\n \"&::placeholder\": {\n opacity: 1,\n color: theme.colors.secondary_80,\n },\n\n \"&::-ms-clear\": {\n display: \"none\",\n },\n },\n inputDisabled: {},\n inputReadOnly: {\n color: theme.colors.secondary_80,\n },\n inputResizable: { resize: \"both\", width: \"100%\" },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","display","width","position","backgroundColor","theme","colors","primary","disabled","atmo4","color","secondary_60","WebkitTextFillColor","atmo2","border","invalid","negative","resizable","readOnly","inputBorderContainer","height","top","left","inputRootInvalid","borderColor","inputRootReadOnly","inputRoot","margin","borderRadius","radii","base","secondary_80","boxSizing","atmo1","fontFamily","body","borderBottom","inputRootFocused","background","outlineStyles","inputRootDisabled","cursor","borderBottomStyle","inputRootMultiline","padding","overflow","minHeight","marginLeft","marginRight","input","space","xs","textOverflow","outline","flexGrow","typography","opacity","inputDisabled","inputReadOnly","inputResizable","resize"],"mappings":";;;AAOa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,eAAe;AAAA,EACxEC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,OAAO;AAAA,IACPC,UAAU;AAAA,IAEV,iCAAiC;AAAA,MAC/BC,iBAAiBC,MAAMC,OAAOC;AAAAA,IAChC;AAAA,IAEA,wCAAwC;AAAA,MACtCH,iBAAiBC,MAAMC,OAAOC;AAAAA,IAChC;AAAA,EACF;AAAA,EACAC,UAAU;AAAA,IACR,2BAA2B;AAAA,MACzBJ,iBAAiBC,MAAMC,OAAOG;AAAAA,IAChC;AAAA,IAEA,iCAAiC;AAAA,MAC/BL,iBAAiBC,MAAMC,OAAOG;AAAAA,IAChC;AAAA,IAEA,aAAa;AAAA,MACXC,OAAOL,MAAMC,OAAOK;AAAAA,MACpBC,qBAAqBP,MAAMC,OAAOK;AAAAA,IACpC;AAAA,IAEA,yBAAyB;AAAA,MACvB,YAAY;AAAA,QACVP,iBAAiBC,MAAMC,OAAOO;AAAAA,QAC9BC,QAAS,aAAYT,MAAMC,OAAOK,YAAa;AAAA,MACjD;AAAA,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AClD,CAAC;"}
|
|
1
|
+
{"version":3,"file":"BaseInput.styles.js","sources":["../../../../src/components/BaseInput/BaseInput.styles.tsx"],"sourcesContent":["import { CSSProperties } from \"react\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvBaseInput\", {\n root: {\n display: \"inline-block\",\n width: \"100%\",\n position: \"relative\",\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: theme.colors.primary,\n },\n },\n disabled: {\n \"& $inputRoot\": {\n backgroundColor: theme.colors.atmo2,\n borderColor: theme.colors.secondary_60,\n },\n\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.atmo4,\n },\n\n \"&& $input\": {\n color: theme.colors.secondary_60,\n WebkitTextFillColor: theme.colors.secondary_60,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n backgroundColor: theme.colors.atmo2,\n border: `1px solid ${theme.colors.secondary_60}`,\n },\n },\n },\n invalid: {\n \"&:not(.disabled)\": {\n \"& $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: theme.colors.negative,\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.negative}`,\n },\n },\n },\n },\n resizable: { width: \"auto\" },\n readOnly: {\n \"& $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:hover $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"&:focus-within $inputBorderContainer\": {\n backgroundColor: \"transparent\",\n },\n\n \"& $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n\n \"&:hover $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n\n \"&:focus-within $inputRootMultiline\": {\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary_60}`,\n backgroundColor: theme.colors.atmo2,\n },\n },\n },\n inputBorderContainer: {\n position: \"absolute\",\n width: \"calc(100% - 4px)\",\n height: \"0px\",\n top: \"31px\",\n left: \"2px\",\n backgroundColor: theme.colors.atmo4,\n },\n inputRootInvalid: { borderColor: theme.colors.negative },\n inputRootReadOnly: {\n borderColor: theme.colors.secondary_60,\n backgroundColor: theme.colors.atmo2,\n },\n inputRoot: {\n margin: 0,\n width: \"100%\",\n borderRadius: theme.radii.base,\n height: \"32px\",\n border: `1px solid ${theme.colors.secondary}`,\n boxSizing: \"border-box\",\n backgroundColor: theme.colors.atmo1,\n fontFamily: theme.fontFamily.body,\n\n \"&:hover:not($inputRootDisabled):not($inputRootInvalid):not($inputRootReadOnly)\":\n {\n borderColor: theme.colors.primary,\n },\n\n \"&:hover:not($inputRootDisabled)::before\": {\n borderBottom: \"none\",\n },\n\n \"&::before\": {\n borderBottom: \"none\",\n },\n\n \"&::after\": {\n borderBottom: \"none\",\n },\n },\n inputRootFocused: {\n backgroundColor: theme.colors.atmo1,\n ...outlineStyles,\n\n \"&:hover\": {\n backgroundColor: theme.colors.atmo1,\n },\n\n \"&$inputRootReadOnly\": {\n backgroundColor: theme.colors.atmo2,\n },\n },\n inputRootDisabled: {\n cursor: \"not-allowed\",\n\n \"&&::before\": {\n borderBottomStyle: \"none\",\n },\n },\n inputRootMultiline: {\n padding: 0,\n backgroundColor: \"transparent\",\n overflow: \"auto\",\n border: \"none\",\n height: \"auto\",\n\n \"& $input\": {\n border: `1px solid ${theme.colors.secondary}`,\n borderRadius: theme.radii.base,\n backgroundColor: theme.colors.atmo1,\n height: \"auto\",\n minHeight: \"21px\",\n padding: \"5px 10px\",\n overflow: \"auto\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n\n \"&:hover\": {\n border: `1px solid ${theme.colors.primary}`,\n },\n },\n },\n input: {\n height: \"19px\",\n marginLeft: theme.space.xs,\n marginRight: theme.space.xs,\n padding: \"6px 0 5px\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n outline: \"none\",\n width: \"initial\",\n flexGrow: 1,\n ...(theme.typography.body as CSSProperties),\n\n \"&::placeholder\": {\n opacity: 1,\n color: theme.colors.secondary_80,\n },\n\n \"&::-ms-clear\": {\n display: \"none\",\n },\n },\n inputDisabled: {},\n inputReadOnly: {\n color: theme.colors.secondary_80,\n },\n inputResizable: { resize: \"both\", width: \"100%\" },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","display","width","position","backgroundColor","theme","colors","primary","disabled","atmo2","borderColor","secondary_60","atmo4","color","WebkitTextFillColor","border","invalid","negative","resizable","readOnly","inputBorderContainer","height","top","left","inputRootInvalid","inputRootReadOnly","inputRoot","margin","borderRadius","radii","base","secondary","boxSizing","atmo1","fontFamily","body","borderBottom","inputRootFocused","outlineStyles","inputRootDisabled","cursor","borderBottomStyle","inputRootMultiline","padding","overflow","minHeight","marginLeft","marginRight","input","space","xs","textOverflow","outline","flexGrow","typography","opacity","secondary_80","inputDisabled","inputReadOnly","inputResizable","resize"],"mappings":";;;AAMa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,eAAe;AAAA,EACxEC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,OAAO;AAAA,IACPC,UAAU;AAAA,IAEV,iCAAiC;AAAA,MA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O;AAAA,IACL3B,QAAQ;AAAA,IACRyB,YAAYzC,MAAM4C,MAAMC;AAAAA,IACxBH,aAAa1C,MAAM4C,MAAMC;AAAAA,IACzBP,SAAS;AAAA,IACTC,UAAU;AAAA,IACVO,cAAc;AAAA,IACdC,SAAS;AAAA,IACTlD,OAAO;AAAA,IACPmD,UAAU;AAAA,IACV,GAAIhD,MAAMiD,WAAWnB;AAAAA,IAErB,kBAAkB;AAAA,MAChBoB,SAAS;AAAA,MACT1C,OAAOR,MAAMC,OAAOkD;AAAAA,IACtB;AAAA,IAEA,gBAAgB;AAAA,MACdvD,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACAwD,eAAe,CAAC;AAAA,EAChBC,eAAe;AAAA,IACb7C,OAAOR,MAAMC,OAAOkD;AAAAA,EACtB;AAAA,EACAG,gBAAgB;AAAA,IAAEC,QAAQ;AAAA,IAAQ1D,OAAO;AAAA,EAAO;AAClD,CAAC;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useContext, useState, useEffect } from "react";
|
|
3
|
-
import { Info } from "@hitachivantara/uikit-react-icons";
|
|
4
3
|
import dayjs from "dayjs";
|
|
5
4
|
import localeData from "dayjs/plugin/localeData";
|
|
6
5
|
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
@@ -15,6 +14,7 @@ import { useDefaultProps } from "../../../hooks/useDefaultProps.js";
|
|
|
15
14
|
import { HvFormElementContext } from "../../Forms/FormElement/context/FormElementContext.js";
|
|
16
15
|
import { HvFormElementDescriptorsContext } from "../../Forms/FormElement/context/FormElementDescriptorsContext.js";
|
|
17
16
|
import { HvTypography } from "../../Typography/Typography.js";
|
|
17
|
+
import { HvInput } from "../../Input/Input.js";
|
|
18
18
|
dayjs.extend(localeData);
|
|
19
19
|
dayjs.extend(localizedFormat);
|
|
20
20
|
dayjs.extend(customParseFormat);
|
|
@@ -28,8 +28,7 @@ const HvCalendarHeader = (props) => {
|
|
|
28
28
|
showEndDate,
|
|
29
29
|
showDayOfWeek = false,
|
|
30
30
|
onFocus,
|
|
31
|
-
invalidDateLabel = "Invalid Date"
|
|
32
|
-
...others
|
|
31
|
+
invalidDateLabel = "Invalid Date"
|
|
33
32
|
} = useDefaultProps("HvCalendarHeader", props);
|
|
34
33
|
const {
|
|
35
34
|
classes,
|
|
@@ -109,23 +108,19 @@ const HvCalendarHeader = (props) => {
|
|
|
109
108
|
setEditedValue(formattedDate);
|
|
110
109
|
onFocus?.(event, formattedDate);
|
|
111
110
|
};
|
|
112
|
-
const onChangeHandler = (event) => {
|
|
113
|
-
setEditedValue(
|
|
111
|
+
const onChangeHandler = (event, val) => {
|
|
112
|
+
setEditedValue(val);
|
|
114
113
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}, children: !isValidValue && inputValue !== "" && /* @__PURE__ */ jsxs(HvTypography, { component: "span", variant: "body", className: classes?.invalidMessageStyling, children: [
|
|
126
|
-
/* @__PURE__ */ jsx(Info, { color: "brand", iconSize: "S" }),
|
|
127
|
-
invalidDateLabel
|
|
128
|
-
] }) })
|
|
114
|
+
const isInvalid = !isValidValue && inputValue !== "";
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", { id: localId, className: cx(classes.root, {
|
|
116
|
+
[classes.invalid]: isInvalid
|
|
117
|
+
}), children: [
|
|
118
|
+
showDayOfWeek && /* @__PURE__ */ jsx(HvTypography, { className: classes.headerDayOfWeek, children: weekdayDisplay || " " }),
|
|
119
|
+
/* @__PURE__ */ jsx(HvInput, { type: "text", id: setId(localId, "header-input"), className: classes.headerDate, classes: {
|
|
120
|
+
input: classes.input,
|
|
121
|
+
inputBorderContainer: classes.inputBorderContainer,
|
|
122
|
+
error: classes.invalidMessageStyling
|
|
123
|
+
}, placeholder: localeFormat, value: inputValue, "aria-labelledby": label?.[0]?.id, onBlur: onBlurHandler, onFocus: onFocusHandler, onChange: onChangeHandler, onKeyDown: keyDownHandler, status: isInvalid ? "invalid" : "valid", statusMessage: invalidDateLabel })
|
|
129
124
|
] });
|
|
130
125
|
};
|
|
131
126
|
HvCalendarHeader.formElementType = "HvCalendarHeader";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarHeader.js","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useState, useEffect, useContext } from \"react\";\n\nimport { Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\n\nimport {\n HvFormElementContext,\n HvFormElementValueContext,\n HvFormElementDescriptorsContext,\n} from \"@core/components/Forms\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { isRange, isSameDay, formatToLocale, isDate } from \"../utils\";\nimport { DateRangeProp } from \"../types\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\ndayjs.extend(localeData);\ndayjs.extend(localizedFormat);\ndayjs.extend(customParseFormat);\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id,\n value,\n locale = \"en-US\",\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n ...others\n } = useDefaultProps(\"HvCalendarHeader\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId } = useContext(HvFormElementContext);\n const elementValue = useContext(HvFormElementValueContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n let localValue: string | Date | DateRangeProp | undefined =\n value ?? elementValue ?? \"\";\n if (isRange(localValue)) {\n localValue = showEndDate ? localValue.endDate : localValue.startDate;\n }\n const [dateValue, setDateValue] = useState<\n string | Date | DateRangeProp | undefined\n >(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const localId = id ?? setId(elementId, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = dayjs().locale(locale).localeData().longDateFormat(\"L\");\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (!!inputValue && dayjs(localValue).isValid())\n );\n\n const validateInput = (incomingValid) =>\n incomingValid === undefined || dayjs(incomingValid).isValid();\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(formatToLocale(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event, date) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = dayjs(date, localeFormat);\n\n const isValidInput = localeParsedDate.isValid();\n const dateParsed = isValidInput\n ? localeParsedDate.toDate()\n : dayjs(date).toDate();\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? dayjs(localValue).locale(locale).format(\"L\")\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler = (event) => {\n setEditedValue(event.target.value);\n };\n return (\n <>\n <div\n id={localId}\n className={cx(classes.root, {\n [classes.invalid]: !isValidValue && inputValue !== \"\",\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n\n <div className={classes.headerDate}>\n <input\n type=\"text\"\n id={setId(localId, \"header-input\")}\n placeholder={localeFormat}\n value={inputValue}\n className={classes.input}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n aria-labelledby={label?.[0]?.id}\n {...others}\n />\n </div>\n </div>\n {!isValidValue && inputValue !== \"\" && (\n <div role=\"presentation\" className={classes.inputBorderContainer} />\n )}\n <div style={{ height: 32 }}>\n {!isValidValue && inputValue !== \"\" && (\n <HvTypography\n component=\"span\"\n variant=\"body\"\n className={classes?.invalidMessageStyling}\n >\n <Info color=\"brand\" iconSize=\"S\" />\n {invalidDateLabel}\n </HvTypography>\n )}\n </div>\n </>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * The text to be shown on the main part of the header.\n */\n value?: string | Date | DateRangeProp;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event:\n | React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>\n | undefined,\n value: Date | DateRangeProp\n ) => void;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEventHandler<any>,\n formattedDate: string | null\n ) => void;\n /**\n * Indicates if header should display end date in a date range.\n */\n showEndDate?: boolean;\n /**\n * Indicates if header should display the day of week.\n */\n showDayOfWeek?: boolean;\n /**\n * Label shown when date is invalid.\n */\n invalidDateLabel?: string;\n}\n"],"names":["dayjs","extend","localeData","localizedFormat","customParseFormat","HvCalendarHeader","props","id","value","locale","classes","classesProp","onChange","showEndDate","showDayOfWeek","onFocus","invalidDateLabel","others","useDefaultProps","cx","useClasses","elementId","useContext","HvFormElementContext","elementValue","HvFormElementValueContext","label","HvFormElementDescriptorsContext","localValue","isRange","endDate","startDate","dateValue","setDateValue","useState","editedValue","setEditedValue","displayValue","setDisplayValue","weekdayDisplay","setWeekdayDisplay","localId","setId","inputValue","localeFormat","longDateFormat","isValidValue","setIsValidValue","length","isValid","validateInput","incomingValid","undefined","useEffect","valid","weekday","Intl","DateTimeFormat","format","isDate","formatToLocale","handleNewDate","event","date","localeParsedDate","isValidInput","dateParsed","toDate","isSameDay","onBlurHandler","keyDownHandler","isKey","preventDefault","onFocusHandler","formattedDate","onChangeHandler","target","root","invalid","headerDayOfWeek","headerDate","input","inputBorderContainer","height","invalidMessageStyling","formElementType"],"mappings":";;;;;;;;;;;;;;;;;AA6BAA,MAAMC,OAAOC,UAAU;AACvBF,MAAMC,OAAOE,eAAe;AAC5BH,MAAMC,OAAOG,iBAAiB;AAEjBC,MAAAA,mBAAmBA,CAACC,UAAiC;AAC1D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAAS;AAAA,IACTC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC;AAAAA,IACAC,mBAAmB;AAAA,IACnB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,oBAAoBZ,KAAK;AACvC,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b,CAAU,UAAA;AAClBA,mBAAAA,MAAMc,OAAOpE,KAAK;AAAA,EAAA;AAEnC,SAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,IAAA,qBAAC,SACC,IAAIiC,SACJ,WAAWtB,GAAGT,QAAQmE,MAAM;AAAA,MAC1B,CAACnE,QAAQoE,OAAO,GAAG,CAAChC,gBAAgBH,eAAe;AAAA,IACpD,CAAA,GAEA7B,UAAAA;AAAAA,MAAAA,qCACE,cAAa,EAAA,WAAWJ,QAAQqE,iBAC9BxC,4BAAkB,KACrB;AAAA,0BAGD,OAAI,EAAA,WAAW7B,QAAQsE,YACtB,8BAAC,SACC,EAAA,MAAK,QACL,IAAItC,MAAMD,SAAS,cAAc,GACjC,aAAaG,cACb,OAAOD,YACP,WAAWjC,QAAQuE,OACnB,QAAQZ,eACR,SAASI,gBACT,UAAUE,iBACV,WAAWL,gBACX,mBAAiB5C,QAAQ,CAAC,GAAGnB,IAC7B,GAAIU,OAAO,CAAA,GAEf;AAAA,IAAA,GACF;AAAA,IACC,CAAC6B,gBAAgBH,eAAe,MAC/B,oBAAC,SAAI,MAAK,gBAAe,WAAWjC,QAAQwE,qBAC7C,CAAA;AAAA,IACD,oBAAC,SAAI,OAAO;AAAA,MAAEC,QAAQ;AAAA,IAAA,GACnB,UAAA,CAACrC,gBAAgBH,eAAe,MAC/B,qBAAC,cACC,EAAA,WAAU,QACV,SAAQ,QACR,WAAWjC,SAAS0E,uBAEpB,UAAA;AAAA,MAAA,oBAAC,MAAK,EAAA,OAAM,SAAQ,UAAS,KAAG;AAAA,MAC/BpE;AAAAA,IAAAA,EAAAA,CACH,EAEJ,CAAA;AAAA,EACF,EAAA,CAAA;AAEJ;AAGAX,iBAAiBgF,kBAAkB;"}
|
|
1
|
+
{"version":3,"file":"CalendarHeader.js","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useState, useEffect, useContext } from \"react\";\nimport dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\n\nimport {\n HvFormElementContext,\n HvFormElementValueContext,\n HvFormElementDescriptorsContext,\n} from \"@core/components/Forms\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks\";\nimport { HvInput, HvInputProps } from \"@core/components/Input\";\n\nimport { isRange, isSameDay, formatToLocale, isDate } from \"../utils\";\nimport { DateRangeProp } from \"../types\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\ndayjs.extend(localeData);\ndayjs.extend(localizedFormat);\ndayjs.extend(customParseFormat);\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id,\n value,\n locale = \"en-US\",\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n } = useDefaultProps(\"HvCalendarHeader\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId } = useContext(HvFormElementContext);\n const elementValue = useContext(HvFormElementValueContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n let localValue: string | Date | DateRangeProp | undefined =\n value ?? elementValue ?? \"\";\n if (isRange(localValue)) {\n localValue = showEndDate ? localValue.endDate : localValue.startDate;\n }\n\n const [dateValue, setDateValue] = useState<\n string | Date | DateRangeProp | undefined\n >(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const localId = id ?? setId(elementId, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = dayjs().locale(locale).localeData().longDateFormat(\"L\");\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (!!inputValue && dayjs(localValue).isValid())\n );\n\n const validateInput = (incomingValid) =>\n incomingValid === undefined || dayjs(incomingValid).isValid();\n\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(formatToLocale(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event, date) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = dayjs(date, localeFormat);\n\n const isValidInput = localeParsedDate.isValid();\n const dateParsed = isValidInput\n ? localeParsedDate.toDate()\n : dayjs(date).toDate();\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler: HvInputProps[\"onBlur\"] = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler: HvInputProps[\"onKeyDown\"] = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler: HvInputProps[\"onFocus\"] = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? dayjs(localValue).locale(locale).format(\"L\")\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler: HvInputProps[\"onChange\"] = (event, val) => {\n setEditedValue(val);\n };\n\n const isInvalid = !isValidValue && inputValue !== \"\";\n\n // This component needs to be further refactored\n // It's not possible to clear the date\n // In a new major there's no need for all these classes\n return (\n <div\n id={localId}\n className={cx(classes.root, {\n [classes.invalid]: isInvalid,\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n <HvInput\n type=\"text\"\n id={setId(localId, \"header-input\")}\n className={classes.headerDate}\n classes={{\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n error: classes.invalidMessageStyling,\n }}\n placeholder={localeFormat}\n value={inputValue}\n aria-labelledby={label?.[0]?.id}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={invalidDateLabel}\n />\n </div>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * The text to be shown on the main part of the header.\n */\n value?: string | Date | DateRangeProp;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event:\n | React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>\n | undefined,\n value: Date | DateRangeProp\n ) => void;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n formattedDate: string | null\n ) => void;\n /**\n * Indicates if header should display end date in a date range.\n */\n showEndDate?: boolean;\n /**\n * Indicates if header should display the day of week.\n */\n showDayOfWeek?: boolean;\n /**\n * Label shown when date is invalid.\n */\n invalidDateLabel?: string;\n}\n"],"names":["dayjs","extend","localeData","localizedFormat","customParseFormat","HvCalendarHeader","props","id","value","locale","classes","classesProp","onChange","showEndDate","showDayOfWeek","onFocus","invalidDateLabel","useDefaultProps","cx","useClasses","elementId","useContext","HvFormElementContext","elementValue","HvFormElementValueContext","label","HvFormElementDescriptorsContext","localValue","isRange","endDate","startDate","dateValue","setDateValue","useState","editedValue","setEditedValue","displayValue","setDisplayValue","weekdayDisplay","setWeekdayDisplay","localId","setId","inputValue","localeFormat","longDateFormat","isValidValue","setIsValidValue","length","isValid","validateInput","incomingValid","undefined","useEffect","valid","weekday","Intl","DateTimeFormat","format","isDate","formatToLocale","handleNewDate","event","date","localeParsedDate","isValidInput","dateParsed","toDate","isSameDay","onBlurHandler","keyDownHandler","isKey","preventDefault","onFocusHandler","formattedDate","onChangeHandler","val","isInvalid","root","invalid","headerDayOfWeek","headerDate","input","inputBorderContainer","error","invalidMessageStyling","formElementType"],"mappings":";;;;;;;;;;;;;;;;;AA0BAA,MAAMC,OAAOC,UAAU;AACvBF,MAAMC,OAAOE,eAAe;AAC5BH,MAAMC,OAAOG,iBAAiB;AAEjBC,MAAAA,mBAAmBA,CAACC,UAAiC;AAC1D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAAS;AAAA,IACTC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC;AAAAA,IACAC,mBAAmB;AAAA,EAAA,IACjBC,gBAAgB,oBAAoBX,KAAK;AAEvC,QAAA;AAAA,IAAEI;AAAAA,IAASQ;AAAAA,EAAAA,IAAOC,WAAWR,WAAW;AAExC,QAAA;AAAA,IAAES;AAAAA,EAAAA,IAAcC,WAAWC,oBAAoB;AAC/CC,QAAAA,eAAeF,WAAWG,yBAAyB;AACnD,QAAA;AAAA,IAAEC;AAAAA,EAAAA,IAAUJ,WAAWK,+BAA+B;AAExDC,MAAAA,aACFnB,SAASe,gBAAgB;AACvBK,MAAAA,QAAQD,UAAU,GAAG;AACVd,iBAAAA,cAAcc,WAAWE,UAAUF,WAAWG;AAAAA,EAC7D;AAEA,QAAM,CAACC,WAAWC,YAAY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GACjC,WAAW9B,QAAQsE,YACnB,SAAS;AAAA,MACPC,OAAOvE,QAAQuE;AAAAA,MACfC,sBAAsBxE,QAAQwE;AAAAA,MAC9BC,OAAOzE,QAAQ0E;AAAAA,IACjB,GACA,aAAazC,cACb,OAAOD,YACP,mBAAiBjB,QAAQ,CAAC,GAAGlB,IAC7B,QAAQ6D,eACR,SAASI,gBACT,UAAUE,iBACV,WAAWL,gBACX,QAAQO,YAAY,YAAY,SAChC,eAAe5D,iBAAiB,CAAA;AAAA,EAEpC,EAAA,CAAA;AAEJ;AAGAX,iBAAiBgF,kBAAkB;"}
|
|
@@ -1,54 +1,23 @@
|
|
|
1
1
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
2
|
import { createClasses } from "../../../utils/classes.js";
|
|
3
|
-
import { outlineStyles } from "../../../utils/focusUtils.js";
|
|
4
3
|
const {
|
|
5
4
|
staticClasses,
|
|
6
5
|
useClasses
|
|
7
6
|
} = createClasses("HvCalendarHeader", {
|
|
8
7
|
root: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"&:hover, &:focus": {
|
|
13
|
-
borderBottom: `1px solid ${theme.colors.secondary}`
|
|
8
|
+
paddingBottom: theme.space.md,
|
|
9
|
+
"&$invalid": {
|
|
10
|
+
paddingBottom: 0
|
|
14
11
|
}
|
|
15
12
|
},
|
|
16
13
|
invalid: {},
|
|
17
14
|
headerDayOfWeek: {
|
|
18
|
-
color: theme.colors.secondary_80
|
|
19
|
-
paddingLeft: theme.spacing("xs")
|
|
15
|
+
color: theme.colors.secondary_80
|
|
20
16
|
},
|
|
21
17
|
headerDate: {},
|
|
22
|
-
input: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
padding: `5px ${theme.spacing("xs")}`,
|
|
26
|
-
fontFamily: theme.fontFamily.body,
|
|
27
|
-
color: theme.colors.secondary_80,
|
|
28
|
-
fontSize: theme.fontSizes.base,
|
|
29
|
-
lineHeight: theme.lineHeights.base,
|
|
30
|
-
fontWeight: theme.fontWeights.normal,
|
|
31
|
-
width: "100%",
|
|
32
|
-
"&::placeholder": {
|
|
33
|
-
color: theme.colors.secondary_60
|
|
34
|
-
},
|
|
35
|
-
"&:focus": {
|
|
36
|
-
outline: "none"
|
|
37
|
-
},
|
|
38
|
-
"&:focus-visible": {
|
|
39
|
-
...outlineStyles
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
inputBorderContainer: {
|
|
43
|
-
backgroundColor: theme.colors.negative,
|
|
44
|
-
height: 1,
|
|
45
|
-
marginTop: -1
|
|
46
|
-
},
|
|
47
|
-
invalidMessageStyling: {
|
|
48
|
-
display: "flex",
|
|
49
|
-
alignItems: "center",
|
|
50
|
-
color: theme.colors.negative
|
|
51
|
-
}
|
|
18
|
+
input: {},
|
|
19
|
+
inputBorderContainer: {},
|
|
20
|
+
invalidMessageStyling: {}
|
|
52
21
|
});
|
|
53
22
|
export {
|
|
54
23
|
staticClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarHeader.styles.js","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\
|
|
1
|
+
{"version":3,"file":"CalendarHeader.styles.js","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvCalendarHeader\", {\n root: {\n paddingBottom: theme.space.md,\n\n \"&$invalid\": {\n paddingBottom: 0,\n },\n },\n invalid: {},\n headerDayOfWeek: {\n color: theme.colors.secondary_80,\n },\n headerDate: {},\n input: {},\n inputBorderContainer: {},\n invalidMessageStyling: {},\n});\n"],"names":["staticClasses","useClasses","createClasses","root","paddingBottom","theme","space","md","invalid","headerDayOfWeek","color","colors","secondary_80","headerDate","input","inputBorderContainer","invalidMessageStyling"],"mappings":";;AAIa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,oBAAoB;AAAA,EAC7EC,MAAM;AAAA,IACJC,eAAeC,MAAMC,MAAMC;AAAAA,IAE3B,aAAa;AAAA,MACXH,eAAe;AAAA,IACjB;AAAA,EACF;AAAA,EACAI,SAAS,CAAC;AAAA,EACVC,iBAAiB;AAAA,IACfC,OAAOL,MAAMM,OAAOC;AAAAA,EACtB;AAAA,EACAC,YAAY,CAAC;AAAA,EACbC,OAAO,CAAC;AAAA,EACRC,sBAAsB,CAAC;AAAA,EACvBC,uBAAuB,CAAC;AAC1B,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDownMenu.js","sources":["../../../../src/components/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { ChangeEvent, useMemo } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\
|
|
1
|
+
{"version":3,"file":"DropDownMenu.js","sources":["../../../../src/components/DropDownMenu/DropDownMenu.tsx"],"sourcesContent":["import { ChangeEvent, useMemo } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { MoreOptionsVertical } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { getPrevNextFocus } from \"@core/utils/focusableElementFinder\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { HvButton, HvButtonVariant } from \"@core/components/Button\";\nimport { HvList, HvListProps, HvListValue } from \"@core/components/List\";\nimport { HvPanel } from \"@core/components/Panel\";\n\nimport { staticClasses, useClasses } from \"./DropDownMenu.styles\";\n\nexport { staticClasses as dropDownMenuClasses };\n\nexport type HvDropDownMenuClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropDownMenuProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n /** Icon. */\n icon?: React.ReactElement;\n /**\n * A list containing the elements to be rendered.\n *\n * - label: The label of the element to be rendered.\n * - selected: The selection state of the element.\n * - disabled: The disabled state of the element.\n * - icon: The icon node to be rendered on the left.\n * - showNavIcon: If true renders the navigation icon on the right.\n */\n dataList: HvListValue[];\n /** Placement of the dropdown. */\n placement?: \"left\" | \"right\";\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Function executed on toggle of the dropdown. Should receive the open status. */\n onToggle?: (event: Event, open: boolean) => void;\n /** Function executed in each onClick. Should received the clicked element. */\n onClick?: (\n event: React.ChangeEvent<HTMLLIElement>,\n value: HvListValue\n ) => void;\n /** Keep the Dropdown Menu opened after clicking one option */\n keepOpened?: boolean;\n /** Defines if the component is disabled. */\n disabled?: boolean;\n /** If true it should be displayed open. */\n expanded?: boolean;\n /** When uncontrolled, defines the initial expanded state. */\n defaultExpanded?: boolean;\n /** The variant to be used in the header. */\n category?: HvButtonVariant;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvDropDownMenuClasses;\n}\n\n/**\n * A drop-down menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.\n */\nexport const HvDropDownMenu = (props: HvDropDownMenuProps) => {\n const {\n id: idProp,\n classes: classesProp,\n className,\n icon,\n placement = \"right\",\n dataList,\n disablePortal = false,\n onToggle,\n onClick,\n keepOpened = true,\n disabled = false,\n expanded,\n defaultExpanded = false,\n category = \"secondaryGhost\",\n ...others\n } = useDefaultProps(\"HvDropDownMenu\", props);\n\n const { classes, cx } = useClasses(classesProp);\n const [open, setOpen] = useControlled(expanded, Boolean(defaultExpanded));\n const id = useUniqueId(idProp, \"dropdown-menu\");\n const focusNodes = getPrevNextFocus(setId(id, \"icon-button\"));\n\n const listId = setId(id, \"list\");\n\n const handleClose = (event: ChangeEvent) => {\n // this will only run if uncontrolled\n setOpen(false);\n onToggle?.(event as any, false);\n };\n\n // If the ESCAPE key is pressed inside the list, the close handler must be called.\n const handleKeyDown: HvListProps[\"onKeyDown\"] = (event) => {\n if (isKey(event, \"Tab\")) {\n const node = event.shiftKey ? focusNodes.prevFocus : focusNodes.nextFocus;\n if (node) setTimeout(() => node.focus(), 0);\n handleClose(event as any);\n }\n event.preventDefault();\n };\n\n const setFocusToContent: HvBaseDropdownProps[\"onContainerCreation\"] = (\n containerRef\n ) => {\n containerRef?.getElementsByTagName(\"li\")[0]?.focus();\n };\n\n const condensed = useMemo(() => dataList.every((el) => !el.icon), [dataList]);\n const popperStyle: HvBaseDropdownProps[\"popperProps\"] = {\n style: {\n zIndex: theme.zIndices.tooltip,\n width: \"auto\",\n position: \"relative\",\n },\n };\n\n return (\n <HvBaseDropdown\n id={id}\n className={cx(classes.container, className)}\n classes={{\n root: classes.root,\n container: classes.baseContainer,\n }}\n expanded={open && !disabled}\n component={\n <HvButton\n icon\n variant={category}\n id={setId(id, \"icon-button\")}\n className={cx(classes.icon, { [classes.iconSelected]: open })}\n aria-expanded={open}\n disabled={disabled}\n aria-label=\"Dropdown menu\"\n aria-haspopup=\"menu\"\n >\n {icon || (\n <MoreOptionsVertical\n aria-hidden\n color={disabled ? \"secondary_60\" : undefined}\n />\n )}\n </HvButton>\n }\n placement={placement}\n variableWidth\n disablePortal={disablePortal}\n onToggle={(e, s) => {\n // this will only run if uncontrolled\n setOpen(s);\n onToggle?.(e, s);\n }}\n disabled={disabled}\n onContainerCreation={setFocusToContent}\n popperProps={popperStyle}\n {...others}\n >\n <HvPanel className={classes.menuListRoot}>\n <HvList\n id={listId}\n values={dataList}\n selectable={false}\n condensed={condensed}\n onClick={(event, item) => {\n if (!keepOpened) handleClose(event);\n onClick?.(event, item);\n }}\n onKeyDown={handleKeyDown}\n classes={{\n root: classes.menuList,\n }}\n />\n </HvPanel>\n </HvBaseDropdown>\n );\n};\n"],"names":["HvDropDownMenu","props","id","idProp","classes","classesProp","className","icon","placement","dataList","disablePortal","onToggle","onClick","keepOpened","disabled","expanded","defaultExpanded","category","others","useDefaultProps","cx","useClasses","open","setOpen","useControlled","Boolean","useUniqueId","focusNodes","getPrevNextFocus","setId","listId","handleClose","event","handleKeyDown","isKey","node","shiftKey","prevFocus","nextFocus","setTimeout","focus","preventDefault","setFocusToContent","containerRef","getElementsByTagName","condensed","useMemo","every","el","popperStyle","style","zIndex","theme","zIndices","tooltip","width","position","container","root","baseContainer","iconSelected","undefined","e","s","menuListRoot","item","menuList"],"mappings":";;;;;;;;;;;;;;;;AAqEaA,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC,IAAIC;AAAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC;AAAAA,IACAC;AAAAA,IACAC,aAAa;AAAA,IACbC,WAAW;AAAA,IACXC;AAAAA,IACAC,kBAAkB;AAAA,IAClBC,WAAW;AAAA,IACX,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,kBAAkBlB,KAAK;AAErC,QAAA;AAAA,IAAEG;AAAAA,IAASgB;AAAAA,EAAAA,IAAOC,WAAWhB,WAAW;AACxC,QAAA,CAACiB,MAAMC,OAAO,IAAIC,cAAcT,UAAUU,QAAQT,eAAe,CAAC;AAClEd,QAAAA,KAAKwB,YAAYvB,QAAQ,eAAe;AAC9C,QAAMwB,aAAaC,iBAAiBC,MAAM3B,IAAI,aAAa,CAAC;AAEtD4B,QAAAA,SAASD,MAAM3B,IAAI,MAAM;AAEzB6B,QAAAA,cAAcA,CAACC,UAAuB;AAE1CT,YAAQ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AACTpD,eAAWmD,GAAGC,CAAC;AAAA,EACjB,GACA,UACA,qBAAqBrB,mBACrB,aAAaO,aACT/B,GAAAA,QAEJ,UAAC,oBAAA,SAAA,EAAQ,WAAWd,QAAQ4D,cAC1B,UAAC,oBAAA,QAAA,EACC,IAAIlC,QACJ,QAAQrB,UACR,YAAY,OACZ,WACA,SAAS,CAACuB,OAAOiC,SAAS;AACxB,QAAI,CAACpD;AAAYkB,kBAAYC,KAAK;AAClCpB,cAAUoB,OAAOiC,IAAI;AAAA,EAAA,GAEvB,WAAWhC,eACX,SAAS;AAAA,IACPyB,MAAMtD,QAAQ8D;AAAAA,EAAAA,GACd,GAEN,EACF,CAAA;AAEJ;"}
|
|
@@ -40,7 +40,7 @@ const {
|
|
|
40
40
|
fill: theme.colors.secondary
|
|
41
41
|
},
|
|
42
42
|
borderRadius: `${theme.radii.base} ${theme.radii.base} 0px 0px`,
|
|
43
|
-
border: `1px solid ${theme.colors.
|
|
43
|
+
border: `1px solid ${theme.colors.secondary}`
|
|
44
44
|
},
|
|
45
45
|
/** Styles applied to the list root. */
|
|
46
46
|
menuListRoot: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropDownMenu.styles.js","sources":["../../../../src/components/DropDownMenu/DropDownMenu.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropDownMenu\", {\n /** Styles applied to the container. */\n container: {\n width: 32,\n },\n /** Styles applied to the BaseDropdown container. */\n baseContainer: {},\n /** Styles applied to the root. */\n root: {\n display: \"inline-block\",\n width: \"auto\",\n \"&:focus-visible $icon\": {\n ...outlineStyles,\n },\n },\n /** Styles applied to the icon. */\n icon: {\n position: \"relative\",\n width: 32,\n height: 32,\n boxSizing: \"border-box\",\n padding: 0,\n borderRadius: theme.radii.base,\n border: \"1px solid transparent\",\n },\n /** Styles applied to the icon when selected. */\n iconSelected: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n\n \"&:hover\": {\n backgroundColor: theme.colors.atmo1,\n },\n\n \"& svg .color0\": {\n fill: theme.colors.secondary,\n },\n\n borderRadius: `${theme.radii.base} ${theme.radii.base} 0px 0px`,\n border: `1px solid ${theme.colors.
|
|
1
|
+
{"version":3,"file":"DropDownMenu.styles.js","sources":["../../../../src/components/DropDownMenu/DropDownMenu.styles.tsx"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { outlineStyles } from \"@core/utils/focusUtils\";\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvDropDownMenu\", {\n /** Styles applied to the container. */\n container: {\n width: 32,\n },\n /** Styles applied to the BaseDropdown container. */\n baseContainer: {},\n /** Styles applied to the root. */\n root: {\n display: \"inline-block\",\n width: \"auto\",\n \"&:focus-visible $icon\": {\n ...outlineStyles,\n },\n },\n /** Styles applied to the icon. */\n icon: {\n position: \"relative\",\n width: 32,\n height: 32,\n boxSizing: \"border-box\",\n padding: 0,\n borderRadius: theme.radii.base,\n border: \"1px solid transparent\",\n },\n /** Styles applied to the icon when selected. */\n iconSelected: {\n backgroundColor: theme.colors.atmo1,\n boxShadow: theme.colors.shadow,\n\n \"&:hover\": {\n backgroundColor: theme.colors.atmo1,\n },\n\n \"& svg .color0\": {\n fill: theme.colors.secondary,\n },\n\n borderRadius: `${theme.radii.base} ${theme.radii.base} 0px 0px`,\n border: `1px solid ${theme.colors.secondary}`,\n },\n /** Styles applied to the list root. */\n menuListRoot: {},\n /** Styles applied to the list. */\n menuList: {},\n});\n"],"names":["staticClasses","useClasses","createClasses","container","width","baseContainer","root","display","outlineStyles","icon","position","height","boxSizing","padding","borderRadius","theme","radii","base","border","iconSelected","backgroundColor","colors","atmo1","boxShadow","shadow","fill","secondary","menuListRoot","menuList"],"mappings":";;;AAKa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,kBAAkB;AAAA;AAAA,EAE3EC,WAAW;AAAA,IACTC,OAAO;AAAA,EACT;AAAA;AAAA,EAEAC,eAAe,CAAC;AAAA;AAAA,EAEhBC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTH,OAAO;AAAA,IACP,yBAAyB;AAAA,MACvB,GAAGI;AAAAA,IACL;AAAA,EACF;AAAA;AAAA,EAEAC,MAAM;AAAA,IACJC,UAAU;AAAA,IACVN,OAAO;AAAA,IACPO,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,SAAS;AAAA,IACTC,cAAcC,MAAMC,MAAMC;AAAAA,IAC1BC,QAAQ;AAAA,EACV;AAAA;AAAA,EAEAC,cAAc;AAAA,IACZC,iBAAiBL,MAAMM,OAAOC;AAAAA,IAC9BC,WAAWR,MAAMM,OAAOG;AAAAA,IAExB,WAAW;AAAA,MACTJ,iBAAiBL,MAAMM,OAAOC;AAAAA,IAChC;AAAA,IAEA,iBAAiB;AAAA,MACfG,MAAMV,MAAMM,OAAOK;AAAAA,IACrB;AAAA,IAEAZ,cAAe,GAAEC,MAAMC,MAAMC,IAAK,IAAGF,MAAMC,MAAMC,IAAK;AAAA,IACtDC,QAAS,aAAYH,MAAMM,OAAOK,SAAU;AAAA,EAC9C;AAAA;AAAA,EAEAC,cAAc,CAAC;AAAA;AAAA,EAEfC,UAAU,CAAC;AACb,CAAC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useState, useContext, useEffect } from "react";
|
|
2
|
+
import { useState, useContext, useMemo, useEffect } from "react";
|
|
3
3
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
4
4
|
import { setId } from "../../../utils/setId.js";
|
|
5
5
|
import { useClasses } from "./List.styles.js";
|
|
@@ -21,6 +21,7 @@ const cleanHidden = (lst) => lst.map((item) => ({
|
|
|
21
21
|
isHidden: false
|
|
22
22
|
}));
|
|
23
23
|
const valuesExist = (values) => values != null && values?.length > 0;
|
|
24
|
+
const getSelectedIds = (list) => getSelected(list).map((item) => item.id || item.label);
|
|
24
25
|
const HvDropdownList = (props) => {
|
|
25
26
|
const {
|
|
26
27
|
id,
|
|
@@ -52,6 +53,9 @@ const HvDropdownList = (props) => {
|
|
|
52
53
|
width,
|
|
53
54
|
height
|
|
54
55
|
} = useContext(BaseDropdownContext);
|
|
56
|
+
const hasChanges = useMemo(() => {
|
|
57
|
+
return String(getSelectedIds(values)) !== String(getSelectedIds(list));
|
|
58
|
+
}, [list, values]);
|
|
55
59
|
const newLabels = {
|
|
56
60
|
selectAll: labels?.selectAll,
|
|
57
61
|
selectionConjunction: labels?.multiSelectionConjunction
|
|
@@ -139,7 +143,7 @@ const HvDropdownList = (props) => {
|
|
|
139
143
|
const applyLabel = labels?.applyLabel;
|
|
140
144
|
const cancelLabel = labels?.cancelLabel;
|
|
141
145
|
return /* @__PURE__ */ jsxs(HvActionBar, { id: setId(id, "actions"), children: [
|
|
142
|
-
/* @__PURE__ */ jsx(HvButton, { id: setId(id, "actions-apply"), onClick: () => onChange(cleanHidden(list), true, true, true), variant: "primaryGhost", children: applyLabel }),
|
|
146
|
+
/* @__PURE__ */ jsx(HvButton, { id: setId(id, "actions-apply"), disabled: !hasChanges, onClick: () => onChange(cleanHidden(list), true, true, true), variant: "primaryGhost", children: applyLabel }),
|
|
143
147
|
/* @__PURE__ */ jsx(HvButton, { id: setId(id, "actions-cancel"), onClick: onCancel, variant: "primaryGhost", children: cancelLabel })
|
|
144
148
|
] });
|
|
145
149
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sources":["../../../../../src/components/Dropdown/List/List.tsx"],"sourcesContent":["import { MouseEvent, useContext, useEffect, useState } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport { HvInput } from \"@core/components/Input\";\nimport { HvList, HvListProps, HvListValue } from \"@core/components/List\";\nimport { HvActionBar } from \"@core/components/ActionBar\";\nimport BaseDropdownContext from \"@core/components/BaseDropdown/BaseDropdownContext\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { staticClasses, useClasses } from \"./List.styles\";\nimport { getSelected } from \"../utils\";\nimport { HvDropdownLabelsProps } from \"../types\";\n\nexport { staticClasses as dropdownListClasses };\n\nexport type HvDropdownListClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownListProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvDropdownListClasses;\n /**\n * The list to be rendered.\n */\n values?: HvListValue[];\n /**\n * If true renders a multi select list.\n */\n multiSelect?: boolean;\n /**\n * If true renders the search component.\n */\n showSearch?: boolean;\n /**\n * A function to be executed whenever a item is selected in the list\n * or the Apply button is activated (when `multiSelect` is `true`).\n */\n onChange: (\n /** An array containing the selected values */\n listValues: HvListValue[],\n /** If `true` the selection if finally committed the dropdown header text should reflect the new selection */\n commitChanges: boolean,\n /** If `true` the dropdown should toggle it's current state */\n toggle: boolean,\n /** If `true` the dropdown will call onChange */\n notifyChanges: boolean\n ) => void;\n /**\n * A function to be executed whenever the Cancel button is activated.\n */\n onCancel: (event: MouseEvent) => void;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Max height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class.\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n}\n\n/**\n * The values property was being deeply cloned. That created a significant performance\n * hit when the values contained complex properties' values, like React Nodes.\n *\n * For minimizing the impact of removing the clone, a shallow clone of the array and its\n * objects is performed instead. That should have the same effect in the majority of the\n * cases, where the properties' values are primitive.\n */\nconst clone = (values: HvListValue[]) => values.map((value) => ({ ...value }));\n\n/**\n * Set all hidden's to false.\n */\nconst cleanHidden = (lst: HvListValue[]) =>\n lst.map((item) => ({ ...item, isHidden: false }));\n\nconst valuesExist = (values: HvListValue[]) =>\n values != null && values?.length > 0;\n\nexport const HvDropdownList = (props: HvDropdownListProps) => {\n const {\n id,\n classes: classesProp,\n values = [],\n multiSelect = false,\n showSearch = false,\n onChange,\n onCancel,\n labels,\n notifyChangesOnFirstRender = false,\n hasTooltips = false,\n singleSelectionToggle,\n height: dropdownHeight,\n maxHeight,\n virtualized = false,\n ...others\n } = useDefaultProps(\"HvDropdownList\", props);\n const { classes, cx, css } = useClasses(classesProp);\n\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [list, setList] = useState<HvListValue[]>(clone(values));\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n const { width, height } = useContext(BaseDropdownContext);\n\n const newLabels = {\n selectAll: labels?.selectAll,\n selectionConjunction: labels?.multiSelectionConjunction,\n };\n\n /**\n * Update states associated with select all.\n */\n const updateSelectAll = (listValues: HvListValue[]) => {\n if (!listValues) return;\n const nbrSelected = getSelected(listValues).length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === listValues.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n };\n\n /**\n * After the first render, call onChange if notifyChangesOnFirstRender.\n */\n useEffect(() => {\n if (!valuesExist(values)) return;\n setList(clone(values));\n updateSelectAll(values);\n if (notifyChangesOnFirstRender) {\n onChange?.(values, false, false, true);\n }\n }, [values, notifyChangesOnFirstRender, onChange]);\n\n /**\n * Sets the filtered values to the state.\n *\n * @param {String} str - The value that is being looked.\n */\n const handleSearch = (str: string) => {\n const results = list\n ? list.filter(\n ({\n searchValue,\n label,\n value,\n }: {\n searchValue?: any;\n label?: any;\n value?: any;\n }) => {\n let stringValue = \"\";\n if (\n typeof searchValue === \"string\" ||\n searchValue instanceof String\n ) {\n stringValue = searchValue.toLowerCase();\n } else if (typeof label === \"string\" || label instanceof String) {\n stringValue = label.toLowerCase();\n } else if (typeof value === \"string\" || value instanceof String) {\n stringValue = value.toLowerCase();\n }\n\n return stringValue.indexOf(str.toLowerCase()) >= 0;\n }\n )\n : null;\n\n if (results != null) {\n const newList = list.map((elem) => {\n const isResult = results.find((result) => result.label === elem.label);\n return { ...elem, isHidden: !isResult };\n });\n\n setList(newList);\n setSearchStr(str);\n }\n return str;\n };\n\n /**\n * Create search element.\n *\n * @returns {*}\n */\n const renderSearch = () => (\n <div className={classes.searchContainer}>\n <HvInput\n id={setId(id, \"search\")}\n type=\"search\"\n value={searchStr}\n placeholder={labels?.searchPlaceholder}\n aria-label={labels?.searchPlaceholder}\n onChange={(event, str) => handleSearch(str)}\n />\n </div>\n );\n\n /**\n * Select all the values inside the dropdown.\n *\n */\n const handleSelectAll = () => {\n const newList = list.map((elem) => ({ ...elem, selected: !anySelected }));\n setList(newList);\n updateSelectAll(newList);\n };\n\n /**\n * Create selecteAll component.\n *\n * @returns {*}\n */\n const renderSelectAll = () => {\n const selectAll = labels?.selectAll;\n const multiSelectionConjunction = labels?.multiSelectionConjunction;\n const nbrSelected = getSelected(list).length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${multiSelectionConjunction} ${list.length}`}\n </>\n ) : (\n <>\n <b>{selectAll}</b>\n {` (${list.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <div className={classes.selectAllContainer}>\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n classes={{\n container: classes.selection,\n }}\n className={classes.selectAll}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n );\n };\n\n /**\n * When selecting the state list is updated with the corresponding selection.\n *\n * @param listValues - elements selected.\n */\n const onSelection: HvListProps[\"onChange\"] = (listValues) => {\n if (!multiSelect) {\n onChange(cleanHidden(listValues), true, true, true);\n } else {\n updateSelectAll(listValues);\n setList(clone(listValues));\n }\n };\n\n /**\n * Render action buttons.\n */\n const renderActions = () => {\n const applyLabel = labels?.applyLabel;\n const cancelLabel = labels?.cancelLabel;\n return (\n <HvActionBar id={setId(id, \"actions\")}>\n <HvButton\n id={setId(id, \"actions-apply\")}\n onClick={() => onChange(cleanHidden(list), true, true, true)}\n variant=\"primaryGhost\"\n >\n {applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"actions-cancel\")}\n onClick={onCancel}\n variant=\"primaryGhost\"\n >\n {cancelLabel}\n </HvButton>\n </HvActionBar>\n );\n };\n\n const showList = valuesExist(values);\n\n return (\n <div className={classes.rootList}>\n <div className={classes.listBorderDown} />\n <div className={classes.listContainer}>\n {showSearch && renderSearch()}\n {showList && multiSelect && renderSelectAll()}\n {showList && (\n <HvList\n id={setId(id, \"list\")}\n classes={{\n root: cx(\n classes.dropdownListContainer,\n css({\n maxWidth: width,\n maxHeight:\n maxHeight ??\n `calc(${height}px - 32px - ${theme.space.xs} - ${theme.space.sm})`,\n overflow: \"auto\",\n padding: 4,\n margin: -4,\n }),\n dropdownHeight &&\n css({\n height: dropdownHeight,\n }),\n virtualized &&\n css({\n maxWidth: \"inherit\",\n maxHeight: \"inherit\",\n overflow: \"inherit\",\n padding: 0,\n })\n ),\n }}\n values={list}\n multiSelect={multiSelect}\n useSelector={multiSelect}\n showSelectAll={false}\n onChange={onSelection}\n labels={newLabels}\n hasTooltips={hasTooltips}\n selectable\n condensed\n singleSelectionToggle={singleSelectionToggle}\n height={dropdownHeight}\n virtualized={virtualized}\n {...others}\n />\n )}\n </div>\n {showList && multiSelect ? renderActions() : null}\n </div>\n );\n};\n"],"names":["clone","values","map","value","cleanHidden","lst","item","isHidden","valuesExist","length","HvDropdownList","props","id","classes","classesProp","multiSelect","showSearch","onChange","onCancel","labels","notifyChangesOnFirstRender","hasTooltips","singleSelectionToggle","height","dropdownHeight","maxHeight","virtualized","others","useDefaultProps","cx","css","useClasses","searchStr","setSearchStr","useState","list","setList","allSelected","setAllSelected","anySelected","setAnySelected","width","useContext","BaseDropdownContext","newLabels","selectAll","selectionConjunction","multiSelectionConjunction","updateSelectAll","listValues","nbrSelected","getSelected","hasSelection","allSelect","useEffect","handleSearch","str","results","filter","searchValue","label","stringValue","String","toLowerCase","indexOf","newList","elem","isResult","find","result","renderSearch","searchContainer","setId","searchPlaceholder","event","handleSelectAll","selected","renderSelectAll","defaultLabel","selectAllContainer","container","selection","onSelection","renderActions","applyLabel","cancelLabel","showList","rootList","listBorderDown","listContainer","root","dropdownListContainer","maxWidth","theme","space","xs","sm","overflow","padding","margin"],"mappings":";;;;;;;;;;;;;;;AAqGA,MAAMA,QAAQA,CAACC,WAA0BA,OAAOC,IAAKC,CAAW,WAAA;AAAA,EAAE,GAAGA;AAAM,EAAE;AAK7E,MAAMC,cAAcA,CAACC,QACnBA,IAAIH,IAAKI,CAAU,UAAA;AAAA,EAAE,GAAGA;AAAAA,EAAMC,UAAU;AAAM,EAAE;AAElD,MAAMC,cAAcA,CAACP,WACnBA,UAAU,QAAQA,QAAQQ,SAAS;AAExBC,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTb,SAAS,CAAE;AAAA,IACXc,cAAc;AAAA,IACdC,aAAa;AAAA,IACbC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,I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ources":["../../../../../src/components/Dropdown/List/List.tsx"],"sourcesContent":["import { MouseEvent, useContext, useEffect, useMemo, useState } from \"react\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvButton } from \"@core/components/Button\";\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport { HvInput } from \"@core/components/Input\";\nimport { HvList, HvListProps, HvListValue } from \"@core/components/List\";\nimport { HvActionBar } from \"@core/components/ActionBar\";\nimport BaseDropdownContext from \"@core/components/BaseDropdown/BaseDropdownContext\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { staticClasses, useClasses } from \"./List.styles\";\nimport { getSelected } from \"../utils\";\nimport { HvDropdownLabelsProps } from \"../types\";\n\nexport { staticClasses as dropdownListClasses };\n\nexport type HvDropdownListClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvDropdownListProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvDropdownListClasses;\n /**\n * The list to be rendered.\n */\n values?: HvListValue[];\n /**\n * If true renders a multi select list.\n */\n multiSelect?: boolean;\n /**\n * If true renders the search component.\n */\n showSearch?: boolean;\n /**\n * A function to be executed whenever a item is selected in the list\n * or the Apply button is activated (when `multiSelect` is `true`).\n */\n onChange: (\n /** An array containing the selected values */\n listValues: HvListValue[],\n /** If `true` the selection if finally committed the dropdown header text should reflect the new selection */\n commitChanges: boolean,\n /** If `true` the dropdown should toggle it's current state */\n toggle: boolean,\n /** If `true` the dropdown will call onChange */\n notifyChanges: boolean\n ) => void;\n /**\n * A function to be executed whenever the Cancel button is activated.\n */\n onCancel: (event: MouseEvent) => void;\n /**\n * An object containing all the labels for the dropdown.\n */\n labels?: HvDropdownLabelsProps;\n /**\n * If 'true' the dropdown will notify on the first render.\n */\n notifyChangesOnFirstRender?: boolean;\n /**\n * If `true` the dropdown will show tooltips when user mouseenter text in list\n */\n hasTooltips?: boolean;\n /**\n * If `true`, selection can be toggled when single selection.\n */\n singleSelectionToggle?: boolean;\n /**\n * Experimental. Height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class. Required in case virtualized is used\n */\n height?: number;\n /**\n * Experimental. Max height of the dropdown, in case you want to control it from a prop. Styles can also be used through dropdownListContainer class.\n */\n maxHeight?: number;\n /**\n * Experimental. Uses dropdown in a virtualized form, where not all options are rendered initially. Good for use cases with a lot of options.\n */\n virtualized?: boolean;\n}\n\n/**\n * The values property was being deeply cloned. That created a significant performance\n * hit when the values contained complex properties' values, like React Nodes.\n *\n * For minimizing the impact of removing the clone, a shallow clone of the array and its\n * objects is performed instead. That should have the same effect in the majority of the\n * cases, where the properties' values are primitive.\n */\nconst clone = (values: HvListValue[]) => values.map((value) => ({ ...value }));\n\n/**\n * Set all hidden's to false.\n */\nconst cleanHidden = (lst: HvListValue[]) =>\n lst.map((item) => ({ ...item, isHidden: false }));\n\nconst valuesExist = (values: HvListValue[]) =>\n values != null && values?.length > 0;\n\n/** Filter selected ordered element `id`s (or `label`) */\nconst getSelectedIds = (list: HvListValue[]) =>\n getSelected(list).map((item) => item.id || item.label);\n\nexport const HvDropdownList = (props: HvDropdownListProps) => {\n const {\n id,\n classes: classesProp,\n values = [],\n multiSelect = false,\n showSearch = false,\n onChange,\n onCancel,\n labels,\n notifyChangesOnFirstRender = false,\n hasTooltips = false,\n singleSelectionToggle,\n height: dropdownHeight,\n maxHeight,\n virtualized = false,\n ...others\n } = useDefaultProps(\"HvDropdownList\", props);\n const { classes, cx, css } = useClasses(classesProp);\n\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [list, setList] = useState<HvListValue[]>(clone(values));\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n const { width, height } = useContext(BaseDropdownContext);\n\n const hasChanges = useMemo(() => {\n return String(getSelectedIds(values)) !== String(getSelectedIds(list));\n }, [list, values]);\n\n const newLabels = {\n selectAll: labels?.selectAll,\n selectionConjunction: labels?.multiSelectionConjunction,\n };\n\n /**\n * Update states associated with select all.\n */\n const updateSelectAll = (listValues: HvListValue[]) => {\n if (!listValues) return;\n const nbrSelected = getSelected(listValues).length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === listValues.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n };\n\n /**\n * After the first render, call onChange if notifyChangesOnFirstRender.\n */\n useEffect(() => {\n if (!valuesExist(values)) return;\n setList(clone(values));\n updateSelectAll(values);\n if (notifyChangesOnFirstRender) {\n onChange?.(values, false, false, true);\n }\n }, [values, notifyChangesOnFirstRender, onChange]);\n\n /**\n * Sets the filtered values to the state.\n *\n * @param {String} str - The value that is being looked.\n */\n const handleSearch = (str: string) => {\n const results = list\n ? list.filter(\n ({\n searchValue,\n label,\n value,\n }: {\n searchValue?: any;\n label?: any;\n value?: any;\n }) => {\n let stringValue = \"\";\n if (\n typeof searchValue === \"string\" ||\n searchValue instanceof String\n ) {\n stringValue = searchValue.toLowerCase();\n } else if (typeof label === \"string\" || label instanceof String) {\n stringValue = label.toLowerCase();\n } else if (typeof value === \"string\" || value instanceof String) {\n stringValue = value.toLowerCase();\n }\n\n return stringValue.indexOf(str.toLowerCase()) >= 0;\n }\n )\n : null;\n\n if (results != null) {\n const newList = list.map((elem) => {\n const isResult = results.find((result) => result.label === elem.label);\n return { ...elem, isHidden: !isResult };\n });\n\n setList(newList);\n setSearchStr(str);\n }\n return str;\n };\n\n /**\n * Create search element.\n *\n * @returns {*}\n */\n const renderSearch = () => (\n <div className={classes.searchContainer}>\n <HvInput\n id={setId(id, \"search\")}\n type=\"search\"\n value={searchStr}\n placeholder={labels?.searchPlaceholder}\n aria-label={labels?.searchPlaceholder}\n onChange={(event, str) => handleSearch(str)}\n />\n </div>\n );\n\n /**\n * Select all the values inside the dropdown.\n *\n */\n const handleSelectAll = () => {\n const newList = list.map((elem) => ({ ...elem, selected: !anySelected }));\n setList(newList);\n updateSelectAll(newList);\n };\n\n /**\n * Create selecteAll component.\n *\n * @returns {*}\n */\n const renderSelectAll = () => {\n const selectAll = labels?.selectAll;\n const multiSelectionConjunction = labels?.multiSelectionConjunction;\n const nbrSelected = getSelected(list).length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${multiSelectionConjunction} ${list.length}`}\n </>\n ) : (\n <>\n <b>{selectAll}</b>\n {` (${list.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <div className={classes.selectAllContainer}>\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n classes={{\n container: classes.selection,\n }}\n className={classes.selectAll}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n );\n };\n\n /**\n * When selecting the state list is updated with the corresponding selection.\n *\n * @param listValues - elements selected.\n */\n const onSelection: HvListProps[\"onChange\"] = (listValues) => {\n if (!multiSelect) {\n onChange(cleanHidden(listValues), true, true, true);\n } else {\n updateSelectAll(listValues);\n setList(clone(listValues));\n }\n };\n\n /**\n * Render action buttons.\n */\n const renderActions = () => {\n const applyLabel = labels?.applyLabel;\n const cancelLabel = labels?.cancelLabel;\n return (\n <HvActionBar id={setId(id, \"actions\")}>\n <HvButton\n id={setId(id, \"actions-apply\")}\n disabled={!hasChanges}\n onClick={() => onChange(cleanHidden(list), true, true, true)}\n variant=\"primaryGhost\"\n >\n {applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"actions-cancel\")}\n onClick={onCancel}\n variant=\"primaryGhost\"\n >\n {cancelLabel}\n </HvButton>\n </HvActionBar>\n );\n };\n\n const showList = valuesExist(values);\n\n return (\n <div className={classes.rootList}>\n <div className={classes.listBorderDown} />\n <div className={classes.listContainer}>\n {showSearch && renderSearch()}\n {showList && multiSelect && renderSelectAll()}\n {showList && (\n <HvList\n id={setId(id, \"list\")}\n classes={{\n root: cx(\n classes.dropdownListContainer,\n css({\n maxWidth: width,\n maxHeight:\n maxHeight ??\n `calc(${height}px - 32px - ${theme.space.xs} - ${theme.space.sm})`,\n overflow: \"auto\",\n padding: 4,\n margin: -4,\n }),\n dropdownHeight &&\n css({\n height: dropdownHeight,\n }),\n virtualized &&\n css({\n maxWidth: \"inherit\",\n maxHeight: \"inherit\",\n overflow: \"inherit\",\n padding: 0,\n })\n ),\n }}\n values={list}\n multiSelect={multiSelect}\n useSelector={multiSelect}\n showSelectAll={false}\n onChange={onSelection}\n labels={newLabels}\n hasTooltips={hasTooltips}\n selectable\n condensed\n singleSelectionToggle={singleSelectionToggle}\n height={dropdownHeight}\n virtualized={virtualized}\n {...others}\n />\n )}\n </div>\n {showList && multiSelect ? renderActions() : null}\n </div>\n );\n};\n"],"names":["clone","values","map","value","cleanHidden","lst","item","isHidden","valuesExist","length","getSelectedIds","list","getSelected","id","label","HvDropdownList","props","classes","classesProp","multiSelect","showSearch","onChange","onCancel","labels","notifyChangesOnFirstRender","hasTooltips","singleSelectionToggle","height","dropdownHeight","maxHeight","virtualized","others","useDefaultProps","cx","css","useClasses","searchStr","setSearchStr","useState","setList","allSelected","setAllSelected","anySelected","setAnySelected","width","useContext","BaseDropdownContext","hasChanges","useMemo","String","newLabels","selectAll","selectionConjunction","multiSelectionConjunction","updateSelectAll","listValues","nbrSelected","hasSelection","allSelect","useEffect","handleSearch","str","results","filter","searchValue","stringValue","toLowerCase","indexOf","newList","elem","isResult","find","result","renderSearch","searchContainer","setId","searchPlaceholder","event","handleSelectAll","selected","renderSelectAll","defaultLabel","selectAllContainer","container","selection","onSelection","renderActions","applyLabel","cancelLabel","showList","rootList","listBorderDown","listContainer","root","dropdownListContainer","maxWidth","theme","space","xs","sm","overflow","padding","margin"],"mappings":";;;;;;;;;;;;;;;AAqGA,MAAMA,QAAQA,CAACC,WAA0BA,OAAOC,IAAKC,CAAW,WAAA;AAAA,EAAE,GA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ACPgF,MAAM5D,GACJhB,QAAQ6E,uBACR5D,IAAI;AAAA,UACF6D,UAAUnD;AAAAA,UACVf,WACEA,aACC,QAAOF,MAAO,eAAcqE,MAAMC,MAAMC,EAAG,MAAKF,MAAMC,MAAME,EAAG;AAAA,UAClEC,UAAU;AAAA,UACVC,SAAS;AAAA,UACTC,QAAQ;AAAA,QAAA,CACT,GACD1E,kBACEM,IAAI;AAAA,UACFP,QAAQC;AAAAA,QAAAA,CACT,GACHE,eACEI,IAAI;AAAA,UACF6D,UAAU;AAAA,UACVlE,WAAW;AAAA,UACXuE,UAAU;AAAA,UACVC,SAAS;AAAA,QAAA,CACV,CACL;AAAA,MACF,GACA,QAAQ1F,MACR,aACA,aAAaQ,aACb,eAAe,OACf,UAAUkE,aACV,QAAQnC,WACR,aACA,YAAU,MACV,WAAS,MACT,uBACA,QAAQtB,gBACR,aACIG,GAAAA,QAEP;AAAA,IAAA,GACH;AAAA,IACC0D,YAAYtE,cAAcmE,cAAAA,IAAkB;AAAA,EAC/C,EAAA,CAAA;AAEJ;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1922,7 +1922,7 @@ export declare interface HvCalendarHeaderProps {
|
|
|
1922
1922
|
/**
|
|
1923
1923
|
* Callback to handle input onFocus.
|
|
1924
1924
|
*/
|
|
1925
|
-
onFocus?: (event: React.
|
|
1925
|
+
onFocus?: (event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>, formattedDate: string | null) => void;
|
|
1926
1926
|
/**
|
|
1927
1927
|
* Indicates if header should display end date in a date range.
|
|
1928
1928
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.35.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Hitachi Vantara UI Kit Team",
|
|
6
6
|
"description": "Core React components for the NEXT Design System.",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"@emotion/css": "^11.11.0",
|
|
34
34
|
"@emotion/serialize": "^1.1.2",
|
|
35
35
|
"@emotion/utils": "^1.2.1",
|
|
36
|
-
"@hitachivantara/uikit-react-icons": "^5.6.
|
|
37
|
-
"@hitachivantara/uikit-react-shared": "^5.1.
|
|
38
|
-
"@hitachivantara/uikit-styles": "^5.
|
|
36
|
+
"@hitachivantara/uikit-react-icons": "^5.6.12",
|
|
37
|
+
"@hitachivantara/uikit-react-shared": "^5.1.16",
|
|
38
|
+
"@hitachivantara/uikit-styles": "^5.16.0",
|
|
39
39
|
"@internationalized/date": "^3.2.0",
|
|
40
40
|
"@mui/base": "^5.0.0-beta.4",
|
|
41
41
|
"@popperjs/core": "^2.11.8",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"access": "public",
|
|
65
65
|
"directory": "package"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "e322581164467dcb33d75ddcd8cfc12da884f71e",
|
|
68
68
|
"main": "dist/cjs/index.cjs",
|
|
69
69
|
"exports": {
|
|
70
70
|
".": {
|