@lifesg/react-design-system 3.4.0-canary.5 → 3.4.0-canary.7
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/badge/badge.style.d.ts +3 -3
- package/badge/badge.style.js +8 -8
- package/badge/badge.style.js.map +1 -1
- package/badge/types.d.ts +1 -1
- package/calendar/calendar.js +1 -1
- package/calendar/calendar.js.map +1 -1
- package/cjs/badge/badge.style.js +11 -11
- package/cjs/badge/badge.style.js.map +1 -1
- package/cjs/calendar/calendar.js +7 -7
- package/cjs/calendar/calendar.js.map +1 -1
- package/cjs/data-table/data-table.js +1 -1
- package/cjs/data-table/data-table.js.map +1 -1
- package/cjs/date-input/date-input.js +1 -1
- package/cjs/date-input/date-input.js.map +1 -1
- package/cjs/filter/filter-badge.js +2 -0
- package/cjs/filter/filter-badge.js.map +1 -0
- package/cjs/filter/filter-modal.js +1 -1
- package/cjs/filter/filter-modal.js.map +1 -1
- package/cjs/filter/filter-modal.styles.js +24 -15
- package/cjs/filter/filter-modal.styles.js.map +1 -1
- package/cjs/filter/filter-sidebar.js +1 -1
- package/cjs/filter/filter-sidebar.js.map +1 -1
- package/cjs/filter/filter-sidebar.styles.js +20 -14
- package/cjs/filter/filter-sidebar.styles.js.map +1 -1
- package/cjs/filter/filter.styles.js +6 -5
- package/cjs/filter/filter.styles.js.map +1 -1
- package/cjs/form/form-wrapper.js +1 -1
- package/cjs/form/form-wrapper.js.map +1 -1
- package/cjs/index.js +1 -1
- package/cjs/shared/dropdown-wrapper/dropdown-wrapper.styles.js +6 -5
- package/cjs/shared/dropdown-wrapper/dropdown-wrapper.styles.js.map +1 -1
- package/cjs/shared/internal-calendar/single/single-cell.js +1 -1
- package/cjs/shared/internal-calendar/single/single-cell.js.map +1 -1
- package/cjs/shared/standalone-date-input/standalone-date-input.js +1 -1
- package/cjs/shared/standalone-date-input/standalone-date-input.js.map +1 -1
- package/cjs/shared/standalone-date-input/standalone-date-input.style.js +19 -16
- package/cjs/shared/standalone-date-input/standalone-date-input.style.js.map +1 -1
- package/cjs/theme/colour-primitive/specs/careercompass-colour-set.js +2 -0
- package/cjs/theme/colour-primitive/specs/careercompass-colour-set.js.map +1 -0
- package/cjs/theme/colour-primitive/specs/spf-colour-set.js +1 -1
- package/cjs/theme/colour-primitive/specs/spf-colour-set.js.map +1 -1
- package/cjs/theme/colour-primitive/theme-helper.js +1 -1
- package/cjs/theme/colour-primitive/theme-helper.js.map +1 -1
- package/cjs/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js +1 -1
- package/cjs/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js.map +1 -1
- package/cjs/theme/colour-semantic/specs/lifesg-semantic-tokens.js +1 -1
- package/cjs/theme/colour-semantic/specs/lifesg-semantic-tokens.js.map +1 -1
- package/cjs/theme/colour-semantic/specs/pa-semantic-tokens.js +1 -1
- package/cjs/theme/colour-semantic/specs/pa-semantic-tokens.js.map +1 -1
- package/cjs/theme/colour-semantic/specs/sgwdigitallobby-tokens.js +1 -1
- package/cjs/theme/colour-semantic/specs/sgwdigitallobby-tokens.js.map +1 -1
- package/cjs/theme/colour-semantic/specs/spf-semantic-tokens.js +2 -0
- package/cjs/theme/colour-semantic/specs/spf-semantic-tokens.js.map +1 -0
- package/cjs/theme/colour-semantic/theme-helper.js +1 -1
- package/cjs/theme/colour-semantic/theme-helper.js.map +1 -1
- package/cjs/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js +1 -1
- package/cjs/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js.map +1 -1
- package/cjs/theme/index.js +1 -1
- package/cjs/theme/index.js.map +1 -1
- package/cjs/timepicker/timepicker.js +1 -1
- package/cjs/timepicker/timepicker.js.map +1 -1
- package/cjs/timepicker/timepicker.styles.js +4 -3
- package/cjs/timepicker/timepicker.styles.js.map +1 -1
- package/data-table/data-table.js +1 -1
- package/data-table/data-table.js.map +1 -1
- package/date-input/date-input.js +1 -1
- package/date-input/date-input.js.map +1 -1
- package/filter/filter-badge.d.ts +5 -0
- package/filter/filter-badge.js +2 -0
- package/filter/filter-badge.js.map +1 -0
- package/filter/filter-modal.d.ts +1 -1
- package/filter/filter-modal.js +1 -1
- package/filter/filter-modal.js.map +1 -1
- package/filter/filter-modal.styles.d.ts +2 -0
- package/filter/filter-modal.styles.js +25 -16
- package/filter/filter-modal.styles.js.map +1 -1
- package/filter/filter-sidebar.d.ts +1 -1
- package/filter/filter-sidebar.js +1 -1
- package/filter/filter-sidebar.js.map +1 -1
- package/filter/filter-sidebar.styles.d.ts +1 -0
- package/filter/filter-sidebar.styles.js +20 -14
- package/filter/filter-sidebar.styles.js.map +1 -1
- package/filter/filter.d.ts +2 -2
- package/filter/filter.styles.js +10 -9
- package/filter/filter.styles.js.map +1 -1
- package/filter/types.d.ts +1 -0
- package/form/form-wrapper.js +1 -1
- package/form/form-wrapper.js.map +1 -1
- package/index.js +1 -1
- package/package.json +17 -1
- package/shared/dropdown-wrapper/dropdown-wrapper.styles.js +8 -7
- package/shared/dropdown-wrapper/dropdown-wrapper.styles.js.map +1 -1
- package/shared/internal-calendar/single/single-cell.js +1 -1
- package/shared/internal-calendar/single/single-cell.js.map +1 -1
- package/shared/standalone-date-input/standalone-date-input.js +1 -1
- package/shared/standalone-date-input/standalone-date-input.js.map +1 -1
- package/shared/standalone-date-input/standalone-date-input.style.d.ts +2 -1
- package/shared/standalone-date-input/standalone-date-input.style.js +20 -17
- package/shared/standalone-date-input/standalone-date-input.style.js.map +1 -1
- package/theme/colour-primitive/specs/careercompass-colour-set.d.ts +3 -0
- package/theme/colour-primitive/specs/careercompass-colour-set.js +2 -0
- package/theme/colour-primitive/specs/careercompass-colour-set.js.map +1 -0
- package/theme/colour-primitive/specs/spf-colour-set.js +1 -1
- package/theme/colour-primitive/specs/spf-colour-set.js.map +1 -1
- package/theme/colour-primitive/theme-helper.js +1 -1
- package/theme/colour-primitive/theme-helper.js.map +1 -1
- package/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js +1 -1
- package/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js.map +1 -1
- package/theme/colour-semantic/specs/lifesg-semantic-tokens.js +1 -1
- package/theme/colour-semantic/specs/lifesg-semantic-tokens.js.map +1 -1
- package/theme/colour-semantic/specs/pa-semantic-tokens.js +1 -1
- package/theme/colour-semantic/specs/pa-semantic-tokens.js.map +1 -1
- package/theme/colour-semantic/specs/sgwdigitallobby-tokens.js +1 -1
- package/theme/colour-semantic/specs/sgwdigitallobby-tokens.js.map +1 -1
- package/theme/colour-semantic/specs/spf-semantic-tokens.d.ts +2 -0
- package/theme/colour-semantic/specs/spf-semantic-tokens.js +2 -0
- package/theme/colour-semantic/specs/spf-semantic-tokens.js.map +1 -0
- package/theme/colour-semantic/theme-helper.js +1 -1
- package/theme/colour-semantic/theme-helper.js.map +1 -1
- package/theme/colour-semantic/types.d.ts +14 -0
- package/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js +1 -1
- package/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js.map +1 -1
- package/theme/index.d.ts +33 -0
- package/theme/index.js +1 -1
- package/theme/index.js.map +1 -1
- package/theme/types.d.ts +2 -2
- package/timepicker/timepicker.js +1 -1
- package/timepicker/timepicker.js.map +1 -1
- package/timepicker/timepicker.styles.d.ts +6 -2
- package/timepicker/timepicker.styles.js +3 -2
- package/timepicker/timepicker.styles.js.map +1 -1
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
background-color: ${
|
|
3
|
-
border: ${
|
|
4
|
-
border-radius: ${
|
|
1
|
+
import i from"styled-components";import{Button as o}from"../button/button.js";import{Colour as t,Border as r,Radius as e,Spacing as n,Font as d}from"../theme/index.js";const a=i.div`
|
|
2
|
+
background-color: ${t.bg};
|
|
3
|
+
border: ${r["width-010"]} ${r.solid} ${t.border};
|
|
4
|
+
border-radius: ${e.md};
|
|
5
5
|
overflow: hidden;
|
|
6
6
|
width: 100%;
|
|
7
|
-
`,
|
|
7
|
+
`,s=i.div`
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
10
|
|
|
11
|
-
background-color: ${
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
background-color: ${t.bg};
|
|
12
|
+
color: ${t.text};
|
|
13
|
+
`,g=i.div`
|
|
14
14
|
flex: 1;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: flex-start;
|
|
18
|
+
gap: ${n["spacing-8"]};
|
|
19
|
+
margin: ${n["spacing-24"]} 0 ${n["spacing-24"]}
|
|
20
|
+
${n["spacing-20"]};
|
|
21
|
+
`,l=i.h2`
|
|
22
|
+
${d["heading-xs-semibold"]}
|
|
23
|
+
`,c=i(o.Small)`
|
|
18
24
|
background-color: transparent;
|
|
19
|
-
padding-right: ${
|
|
20
|
-
padding-left: ${
|
|
25
|
+
padding-right: ${n["spacing-20"]};
|
|
26
|
+
padding-left: ${n["spacing-20"]};
|
|
21
27
|
height: 100%;
|
|
22
|
-
`;export{a as DesktopContainer,c as FilterClearButton,
|
|
28
|
+
`;export{a as DesktopContainer,c as FilterClearButton,s as FilterHeader,l as FilterTitle,g as FilterTitleGroup};
|
|
23
29
|
//# sourceMappingURL=filter-sidebar.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-sidebar.styles.js","sources":["../../src/filter/filter-sidebar.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { Button } from \"../button\";\nimport { Border, Colour, Font, Radius, Spacing } from \"../theme\";\n\n// =============================================================================\n// CONTAINER STYLES\n// =============================================================================\n\nexport const DesktopContainer = styled.div`\n background-color: ${Colour[\"bg\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n border-radius: ${Radius[\"md\"]};\n overflow: hidden;\n width: 100%;\n`;\n\n// =============================================================================\n// HEADER STYLES\n// =============================================================================\n\nexport const FilterHeader = styled.div`\n display: flex;\n align-items: center;\n\n background-color: ${Colour[\"bg\"]};\n`;\n\nexport const
|
|
1
|
+
{"version":3,"file":"filter-sidebar.styles.js","sources":["../../src/filter/filter-sidebar.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { Button } from \"../button\";\nimport { Border, Colour, Font, Radius, Spacing } from \"../theme\";\n\n// =============================================================================\n// CONTAINER STYLES\n// =============================================================================\n\nexport const DesktopContainer = styled.div`\n background-color: ${Colour[\"bg\"]};\n border: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n border-radius: ${Radius[\"md\"]};\n overflow: hidden;\n width: 100%;\n`;\n\n// =============================================================================\n// HEADER STYLES\n// =============================================================================\n\nexport const FilterHeader = styled.div`\n display: flex;\n align-items: center;\n\n background-color: ${Colour[\"bg\"]};\n color: ${Colour[\"text\"]};\n`;\n\nexport const FilterTitleGroup = styled.div`\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: ${Spacing[\"spacing-8\"]};\n margin: ${Spacing[\"spacing-24\"]} 0 ${Spacing[\"spacing-24\"]}\n ${Spacing[\"spacing-20\"]};\n`;\n\nexport const FilterTitle = styled.h2`\n ${Font[\"heading-xs-semibold\"]}\n`;\n\nexport const FilterClearButton = styled(Button.Small)`\n background-color: transparent;\n padding-right: ${Spacing[\"spacing-20\"]};\n padding-left: ${Spacing[\"spacing-20\"]};\n height: 100%;\n`;\n"],"names":["DesktopContainer","styled","div","Colour","Border","Radius","FilterHeader","FilterTitleGroup","Spacing","FilterTitle","h2","Font","FilterClearButton","Button","Small"],"mappings":"wKAQO,MAAMA,EAAmBC,EAAOC,GAAG;wBAClBC,EAAW;cACrBC,EAAO,gBAAgBA,EAAc,SAAKD,EAAe;qBAClDE,EAAW;;;EASnBC,EAAeL,EAAOC,GAAG;;;;wBAIdC,EAAW;aACtBA,EAAa;EAGbI,EAAmBN,EAAOC,GAAG;;;;;WAK/BM,EAAQ;cACLA,EAAQ,mBAAmBA,EAAQ;UACvCA,EAAQ;EAGLC,EAAcR,EAAOS,EAAE;MAC9BC,EAAK;EAGEC,EAAoBX,EAAOY,EAAOC,MAAM;;qBAEhCN,EAAQ;oBACTA,EAAQ;;"}
|
package/filter/filter.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { FilterProps } from "./types";
|
|
|
2
2
|
export declare const Filter: {
|
|
3
3
|
({ children, className, style, onDismiss, onDone, onModalOpen, toggleFilterButtonStyle, insets, id, "data-testid": testId, ...props }: FilterProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
Sidebar: {
|
|
5
|
-
({ customLabels, onClear, clearButtonDisabled, children, headerTitle: _headerTitle, ...otherProps }: import("./types").FilterSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
({ customLabels, onClear, clearButtonDisabled, count, children, headerTitle: _headerTitle, ...otherProps }: import("./types").FilterSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
8
|
Modal: {
|
|
9
|
-
({ customLabels, onClear, onDone, onDismiss, onModalOpen, toggleFilterButtonStyle, clearButtonDisabled, insets, children, toggleFilterButtonLabel: _toggleFilterButtonLabel, headerTitle: _headerTitle, doneButtonLabel: _doneButtonLabel, ...otherProps }: import("./types").FilterModalProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
({ customLabels, onClear, onDone, onDismiss, onModalOpen, toggleFilterButtonStyle, clearButtonDisabled, insets, count, children, toggleFilterButtonLabel: _toggleFilterButtonLabel, headerTitle: _headerTitle, doneButtonLabel: _doneButtonLabel, ...otherProps }: import("./types").FilterModalProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
displayName: string;
|
|
11
11
|
};
|
|
12
12
|
Item: {
|
package/filter/filter.styles.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import o from"styled-components";import{Button as t}from"../button/button.js";import{ClickableIcon as i}from"../shared/clickable-icon/clickable-icon.js";import{
|
|
1
|
+
import o from"styled-components";import{Button as t}from"../button/button.js";import{ClickableIcon as i}from"../shared/clickable-icon/clickable-icon.js";import{Colour as r,Spacing as e,Border as n}from"../theme/index.js";const c=o.div`
|
|
2
2
|
flex: 1;
|
|
3
3
|
width: 100%;
|
|
4
4
|
overflow-y: auto;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
color: ${r.text};
|
|
6
|
+
`,d=o(i)`
|
|
7
|
+
padding: ${e["spacing-24"]} ${e["spacing-20"]};
|
|
7
8
|
margin-right: auto;
|
|
8
|
-
color: ${
|
|
9
|
+
color: ${r.icon};
|
|
9
10
|
|
|
10
11
|
svg {
|
|
11
12
|
height: 1.5rem;
|
|
@@ -13,14 +14,14 @@ import o from"styled-components";import{Button as t}from"../button/button.js";im
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
&:hover {
|
|
16
|
-
color: ${
|
|
17
|
+
color: ${r["icon-hover"]};
|
|
17
18
|
}
|
|
18
19
|
`,m=o.div`
|
|
19
|
-
padding: ${
|
|
20
|
-
background-color: ${
|
|
21
|
-
border-top: ${n["width-010"]} ${n.solid} ${
|
|
20
|
+
padding: ${e["spacing-24"]} ${e["spacing-20"]};
|
|
21
|
+
background-color: ${r.bg};
|
|
22
|
+
border-top: ${n["width-010"]} ${n.solid} ${r.border};
|
|
22
23
|
${o=>o.$insetBottom&&`padding-bottom: ${o.$insetBottom}px;`}
|
|
23
24
|
`,a=o(t.Default)`
|
|
24
25
|
width: 100%;
|
|
25
|
-
`;export{
|
|
26
|
+
`;export{c as FilterBody,a as FilterDoneButton,m as FilterFooter,d as FilterHeaderButton};
|
|
26
27
|
//# sourceMappingURL=filter.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.styles.js","sources":["../../src/filter/filter.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { Button } from \"../button\";\nimport { ClickableIcon } from \"../shared/clickable-icon\";\nimport { Border, Colour, Spacing } from \"../theme\";\n\n// =============================================================================\n// STYLE INTERFACES\n// =============================================================================\n\ntype FilterFooterProps = {\n $insetBottom?: number | undefined;\n};\n\n// =============================================================================\n// CONTAINER STYLES\n// =============================================================================\n\nexport const FilterBody = styled.div`\n flex: 1;\n width: 100%;\n overflow-y: auto;\n`;\n\n// =============================================================================\n// HEADER STYLES\n// =============================================================================\n\nexport const FilterHeaderButton = styled(ClickableIcon)`\n padding: ${Spacing[\"spacing-24\"]} ${Spacing[\"spacing-20\"]};\n margin-right: auto;\n color: ${Colour[\"icon\"]};\n\n svg {\n height: 1.5rem;\n width: 1.5rem;\n }\n\n &:hover {\n color: ${Colour[\"icon-hover\"]};\n }\n`;\n\n// =============================================================================\n// COMPONENT STYLES\n// =============================================================================\n\nexport const FilterFooter = styled.div<FilterFooterProps>`\n padding: ${Spacing[\"spacing-24\"]} ${Spacing[\"spacing-20\"]};\n background-color: ${Colour[\"bg\"]};\n border-top: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n ${(props) =>\n props.$insetBottom && `padding-bottom: ${props.$insetBottom}px;`}\n`;\n\nexport const FilterDoneButton = styled(Button.Default)`\n width: 100%;\n`;\n"],"names":["FilterBody","styled","div","FilterHeaderButton","ClickableIcon","Spacing","
|
|
1
|
+
{"version":3,"file":"filter.styles.js","sources":["../../src/filter/filter.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { Button } from \"../button\";\nimport { ClickableIcon } from \"../shared/clickable-icon\";\nimport { Border, Colour, Spacing } from \"../theme\";\n\n// =============================================================================\n// STYLE INTERFACES\n// =============================================================================\n\ntype FilterFooterProps = {\n $insetBottom?: number | undefined;\n};\n\n// =============================================================================\n// CONTAINER STYLES\n// =============================================================================\n\nexport const FilterBody = styled.div`\n flex: 1;\n width: 100%;\n overflow-y: auto;\n color: ${Colour[\"text\"]};\n`;\n\n// =============================================================================\n// HEADER STYLES\n// =============================================================================\n\nexport const FilterHeaderButton = styled(ClickableIcon)`\n padding: ${Spacing[\"spacing-24\"]} ${Spacing[\"spacing-20\"]};\n margin-right: auto;\n color: ${Colour[\"icon\"]};\n\n svg {\n height: 1.5rem;\n width: 1.5rem;\n }\n\n &:hover {\n color: ${Colour[\"icon-hover\"]};\n }\n`;\n\n// =============================================================================\n// COMPONENT STYLES\n// =============================================================================\n\nexport const FilterFooter = styled.div<FilterFooterProps>`\n padding: ${Spacing[\"spacing-24\"]} ${Spacing[\"spacing-20\"]};\n background-color: ${Colour[\"bg\"]};\n border-top: ${Border[\"width-010\"]} ${Border[\"solid\"]} ${Colour[\"border\"]};\n ${(props) =>\n props.$insetBottom && `padding-bottom: ${props.$insetBottom}px;`}\n`;\n\nexport const FilterDoneButton = styled(Button.Default)`\n width: 100%;\n`;\n"],"names":["FilterBody","styled","div","Colour","FilterHeaderButton","ClickableIcon","Spacing","FilterFooter","Border","props","$insetBottom","FilterDoneButton","Button","Default"],"mappings":"6NAiBO,MAAMA,EAAaC,EAAOC,GAAG;;;;aAIvBC,EAAa;EAObC,EAAqBH,EAAOI,EAAc;eACxCC,EAAQ,iBAAiBA,EAAQ;;aAEnCH,EAAa;;;;;;;;iBAQTA,EAAO;;EAQXI,EAAeN,EAAOC,GAAsB;eAC1CI,EAAQ,iBAAiBA,EAAQ;wBACxBH,EAAW;kBACjBK,EAAO,gBAAgBA,EAAc,SAAKL,EAAe;MACpEM,GACCA,EAAMC,cAAgB,mBAAmBD,EAAMC;EAG1CC,EAAmBV,EAAOW,EAAOC,QAAQ;;"}
|
package/filter/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface FilterBaseProps {
|
|
|
18
18
|
"data-testid"?: string | undefined;
|
|
19
19
|
className?: string | undefined;
|
|
20
20
|
style?: CSSProperties | undefined;
|
|
21
|
+
count?: number | undefined;
|
|
21
22
|
clearButtonDisabled?: boolean | undefined;
|
|
22
23
|
/** Called when clear button is pressed */
|
|
23
24
|
onClear?: (() => void) | undefined;
|
package/form/form-wrapper.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as l}from"react/jsx-runtime";import{Children as r,cloneElement as
|
|
1
|
+
import{jsxs as e,jsx as l}from"react/jsx-runtime";import{Children as r,isValidElement as t,Fragment as s,cloneElement as i}from"react";import"../util/calendar-helper.js";import"../util/date-helper.js";import"../util/date-input-helper.js";import{useId as o}from"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{FormLabel as a}from"./form-label.js";import{ErrorMessageContainer as d,ErrorIcon as n,ErrorMessage as m}from"./form-label.style.js";import{Container as b,ColDivContainer as p,V2_ColDivContainer as c}from"./form-wrapper.style.js";const u=({label:u,errorMessage:C,id:f,disabled:g,children:x,layoutType:h,mobileCols:j,tabletCols:v,desktopCols:y,xxsCols:$,xsCols:w,smCols:k,mdCols:F,lgCols:O,xlCols:B,xxlCols:I,"data-testid":M,"data-error-testid":T})=>{const q=!h&&(j||v||y)?"v2-grid":!h&&($||w||k||F||O||B||I)?"grid":h||"flex",z="string"==typeof C?C.trim():C,A=o(),D=`${null!=f?f:A}-label`,E=`${null!=f?f:A}-label-subtitle`,G=`${null!=f?f:A}-error-message`;const H=(e=>{switch(e){case"v2-grid":return c;case"grid":return p;case"flex":return b}})(q);return e(H,Object.assign({"data-testid":M},(e=>{switch(e){case"v2-grid":return{mobileCols:j,tabletCols:v,desktopCols:y};case"grid":return{xxsCols:$,xsCols:w,smCols:k,mdCols:F,lgCols:O,xlCols:B,xxlCols:I};case"flex":return}})(q),{children:[u&&l(a,"string"==typeof u?{htmlFor:`${f}-base`,"data-testid":f?`${f}-label`:"form-label",id:D,disabled:g,children:u}:Object.assign({htmlFor:`${f}-base`,"data-testid":f?`${f}-label`:"form-label",id:D,disabled:g},u)),(()=>{const e={"aria-invalid":!!C,"aria-describedby":[z?G:void 0,"object"==typeof u&&(null==u?void 0:u.subtitle)?E:void 0].filter(Boolean).join(" ")||void 0,"aria-labelledby":u?D:void 0};return r.map(x,(l=>t(l)&&l.type===s?i(l):i(l,e)))})(),z&&e(d,{children:[l(n,{"aria-hidden":!0}),l(m,{id:G,tabIndex:0,"data-testid":null!=T?T:f?`${f}-error-message`:"error-message",children:z})]})]}))};export{u as FormWrapper};
|
|
2
2
|
//# sourceMappingURL=form-wrapper.js.map
|
package/form/form-wrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-wrapper.js","sources":["../../src/form/form-wrapper.tsx"],"sourcesContent":["/**\n * This is a SUPPORTING component\n * (Do not include in the main export)\n *\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"form-wrapper.js","sources":["../../src/form/form-wrapper.tsx"],"sourcesContent":["/**\n * This is a SUPPORTING component\n * (Do not include in the main export)\n *\n */\n\nimport {\n Children,\n ComponentType,\n Fragment,\n cloneElement,\n isValidElement,\n} from \"react\";\nimport { useId } from \"../util\";\nimport { FormLabel } from \"./form-label\";\nimport {\n ErrorIcon,\n ErrorMessage,\n ErrorMessageContainer,\n} from \"./form-label.style\";\nimport {\n ColDivContainer,\n Container,\n V2_ColDivContainer,\n} from \"./form-wrapper.style\";\nimport { FormElementLayoutType, FormWrapperProps } from \"./types\";\n\nexport const FormWrapper = ({\n label,\n errorMessage: eRaw,\n id,\n disabled,\n children,\n layoutType,\n mobileCols,\n tabletCols,\n desktopCols,\n xxsCols,\n xsCols,\n smCols,\n mdCols,\n lgCols,\n xlCols,\n xxlCols,\n \"data-testid\": testId,\n \"data-error-testid\": errorTestId,\n}: FormWrapperProps): JSX.Element => {\n // =============================================================================\n // CONST, STATE, REFS\n // =============================================================================\n const updatedLayoutType = getLayoutType();\n const errorMessage = typeof eRaw === \"string\" ? eRaw.trim() : eRaw;\n const internalId = useId();\n const labelId = `${id ?? internalId}-label`; // matches FormLabel\n const subtitleId = `${id ?? internalId}-label-subtitle`; // matches FormLabel\n const errorMessageId = `${id ?? internalId}-error-message`;\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n\n const isInvalidState = (): boolean => {\n return !!eRaw;\n };\n\n const hasSubtitleLabel = (): boolean => {\n return typeof label === \"object\" && !!label?.subtitle;\n };\n\n const getAriaDescribedBy = (): string | undefined => {\n return (\n [\n errorMessage ? errorMessageId : undefined,\n hasSubtitleLabel() ? subtitleId : undefined,\n ]\n .filter(Boolean)\n .join(\" \") || undefined\n );\n };\n\n function getLayoutType(): FormElementLayoutType {\n if (!layoutType && (mobileCols || tabletCols || desktopCols)) {\n return \"v2-grid\";\n } else if (\n !layoutType &&\n (xxsCols ||\n xsCols ||\n smCols ||\n mdCols ||\n lgCols ||\n xlCols ||\n xxlCols)\n ) {\n return \"grid\";\n } else if (!layoutType) {\n return \"flex\";\n } else {\n return layoutType;\n }\n }\n\n const getContainerLayoutProps = (layoutType: FormElementLayoutType) => {\n switch (layoutType) {\n case \"v2-grid\":\n return {\n mobileCols,\n tabletCols,\n desktopCols,\n };\n case \"grid\":\n return {\n xxsCols,\n xsCols,\n smCols,\n mdCols,\n lgCols,\n xlCols,\n xxlCols,\n };\n case \"flex\":\n return undefined;\n }\n };\n\n const getContainerComponent = (\n layoutType: FormElementLayoutType\n ): ComponentType => {\n switch (layoutType) {\n case \"v2-grid\":\n return V2_ColDivContainer;\n case \"grid\":\n return ColDivContainer;\n case \"flex\":\n return Container;\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n\n const renderFormLabel = (): JSX.Element => {\n if (typeof label === \"string\") {\n return (\n <FormLabel\n htmlFor={`${id}-base`}\n // FIXME: kept for backwards-compatibility\n // in most cases data-testid should be separate from id\n data-testid={id ? `${id}-label` : \"form-label\"}\n id={labelId}\n disabled={disabled}\n >\n {label}\n </FormLabel>\n );\n }\n return (\n <FormLabel\n htmlFor={`${id}-base`}\n data-testid={id ? `${id}-label` : \"form-label\"}\n id={labelId}\n disabled={disabled}\n {...label}\n />\n );\n };\n\n const renderChildren = (): JSX.Element | JSX.Element[] => {\n const ariaState = {\n \"aria-invalid\": isInvalidState(),\n \"aria-describedby\": getAriaDescribedBy(),\n \"aria-labelledby\": label ? labelId : undefined,\n };\n return Children.map(children, (child) => {\n if (isValidElement(child) && child.type === Fragment) {\n return cloneElement(child);\n }\n return cloneElement(child, ariaState);\n });\n };\n\n const ContainerComponent = getContainerComponent(updatedLayoutType);\n\n return (\n <ContainerComponent\n data-testid={testId}\n {...getContainerLayoutProps(updatedLayoutType)}\n >\n {label && renderFormLabel()}\n {renderChildren()}\n {errorMessage && (\n <ErrorMessageContainer>\n <ErrorIcon aria-hidden />\n <ErrorMessage\n id={errorMessageId}\n tabIndex={0}\n data-testid={\n errorTestId ??\n // FIXME: kept for backwards-compatibility\n // in most cases data-testid should be separate from id\n (id ? `${id}-error-message` : \"error-message\")\n }\n >\n {errorMessage}\n </ErrorMessage>\n </ErrorMessageContainer>\n )}\n </ContainerComponent>\n );\n};\n"],"names":["FormWrapper","label","errorMessage","eRaw","id","disabled","children","layoutType","mobileCols","tabletCols","desktopCols","xxsCols","xsCols","smCols","mdCols","lgCols","xlCols","xxlCols","testId","errorTestId","updatedLayoutType","trim","internalId","useId","labelId","subtitleId","errorMessageId","ContainerComponent","V2_ColDivContainer","ColDivContainer","Container","getContainerComponent","_jsxs","Object","assign","getContainerLayoutProps","_jsx","FormLabel","htmlFor","ariaState","undefined","subtitle","filter","Boolean","join","Children","map","child","isValidElement","type","Fragment","cloneElement","renderChildren","ErrorMessageContainer","ErrorIcon","ErrorMessage","tabIndex"],"mappings":"2lBA2BaA,EAAc,EACvBC,QACAC,aAAcC,EACdC,KACAC,WACAC,WACAC,aACAC,aACAC,aACAC,cACAC,UACAC,SACAC,SACAC,SACAC,SACAC,SACAC,UACA,cAAeC,EACf,oBAAqBC,MAKrB,MAAMC,GA+BGb,IAAeC,GAAcC,GAAcC,GACrC,WAENH,IACAI,GACGC,GACAC,GACAC,GACAC,GACAC,GACAC,GAEG,OACCV,GACD,OA5CTL,EAA+B,iBAATC,EAAoBA,EAAKkB,OAASlB,EACxDmB,EAAaC,IACbC,EAAU,GAAGpB,QAAAA,E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CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{Accordion}from"./accordion/accordion.js";export{Alert}from"./alert/alert.js";export{LoadingSpinner}from"./animations/loading-spinner/loading-spinner.js";export{LoadingDots}from"./animations/loading-dots/loading-dots.js";export{LoadingDotsSpinner}from"./animations/loading-dots-spinner/loading-dots-spinner.js";export{ThemedLoadingSpinner}from"./animations/themed-loading-spinner/themed-loading-spinner.js";export{Avatar}from"./avatar/avatar.js";export{Badge}from"./badge/badge.js";export{BoxContainer}from"./box-container/box-container.js";export{Breadcrumb}from"./breadcrumb/breadcrumb.js";export{Button}from"./button/button.js";export{ButtonWithIcon}from"./button-with-icon/button-with-icon.js";export{Calendar}from"./calendar/calendar.js";export{Card}from"./card/card.js";export{Checkbox}from"./checkbox/checkbox.js";export{CountdownTimer}from"./countdown-timer/countdown-timer.js";export{DataTable}from"./data-table/data-table.js";export{DateInput}from"./date-input/date-input.js";export{DateNavigator}from"./date-navigator/date-navigator.js";export{DateRangeInput}from"./date-range-input/date-range-input.js";export{Divider}from"./divider/divider.js";export{Drawer}from"./drawer/drawer.js";export{ESignature}from"./e-signature/e-signature.js";export{ErrorDisplay}from"./error-display/error-display.js";export{ErrorDisplayHelper}from"./error-display/helper.js";export{FeedbackRating}from"./feedback-rating/feedback-rating.js";export{FileDownload}from"./file-download/file-download.js";export{FileUpload}from"./file-upload/file-upload.js";export{Filter}from"./filter/filter.js";export{Footer}from"./footer/footer.js";export{Form}from"./form/index.js";export{Component,FullscreenImageCarousel}from"./fullscreen-image-carousel/fullscreen-image-carousel.js";export{HistogramSlider}from"./histogram-slider/histogram-slider.js";export{IconButton}from"./icon-button/icon-button.js";export{ImageButton}from"./image-button/image-button.js";export{Input}from"./input/input.js";export{InputGroup}from"./input-group/input-group.js";export{InputMultiSelect}from"./input-multi-select/input-multi-select.js";export{InputNestedMultiSelect}from"./input-nested-multi-select/input-nested-multi-select.js";export{InputNestedSelect}from"./input-nested-select/input-nested-select.js";export{InputRangeSelect}from"./input-range-select/input-range-select.js";export{InputRangeSlider}from"./input-range-slider/input-range-slider.js";export{InputSelect}from"./input-select/input-select.js";export{InputSlider}from"./input-slider/input-slider.js";export{Textarea}from"./input-textarea/textarea.js";export{LanguageSwitcher}from"./language-switcher/language-switcher.js";export{Layout}from"./layout/index.js";export{LinkList}from"./link-list/link-list.js";export{Markup}from"./markup/markup.js";export{MaskedInput}from"./masked-input/masked-input.js";export{Masonry}from"./masonry/masonry.js";export{Masthead}from"./masthead/masthead.js";export{Menu,MenuTrigger}from"./menu/menu.js";export{Modal}from"./modal/index.js";export{ModalV2}from"./modal-v2/index.js";export{Navbar}from"./navbar/navbar.js";export{NBComponent,NotificationBanner}from"./notification-banner/notification-banner.js";export{withNotificationBanner}from"./notification-banner/notification-banner-hoc.js";export{OtpInput}from"./otp-input/otp-input.js";export{Overlay}from"./overlay/overlay.js";export{Pagination}from"./pagination/pagination.js";export{PhoneNumberInput}from"./phone-number-input/phone-number-input.js";export{Pill}from"./pill/pill.js";export{withPopover}from"./popover/popover-hoc.js";export{Popover}from"./popover/popover.js";export{PopoverV2}from"./popover-v2/popover.js";export{PopoverInline}from"./popover-v2/popover-inline/popover-inline.js";export{PopoverTrigger}from"./popover-v2/popover-trigger.js";export{PredictiveTextInput}from"./predictive-text-input/predictive-text-input.js";export{ProgressIndicator}from"./progress-indicator/progress-indicator.js";export{RadioButton}from"./radio-button/radio-button.js";export{SelectHistogram}from"./select-histogram/select-histogram.js";export{Sidenav}from"./sidenav/sidenav.js";export{SingpassButton}from"./singpass-button/singpass-button.js";export{SmartAppBanner}from"./smart-app-banner/smart-app-banner.js";export{Tab}from"./tab/tab.js";export{Table}from"./table/table.js";export{Tag}from"./tag/tag.js";export{TextList}from"./text-list/index.js";export{A11yPlaygroundTheme,BookingSGTheme,Border,Breakpoint,CCubeTheme,Colour,Font,IMDATheme,LifeSGTheme,MediaQuery,Motion,MyLegacyTheme,OneServiceTheme,PATheme,RBSTheme,Radius,SGWDigitalLobbyTheme,SGWDigitalLobbyThemeBase,SMGSTheme,SPFTheme,Shadow,Spacing,SupportGoWhereTheme,SupportGoWhereThemeBase,ThemeComponent}from"./theme/index.js";export{TimeRangePicker}from"./time-range-picker/time-range-picker.js";export{TimeSlotBar}from"./time-slot-bar/time-slot-bar.js";export{TimeSlotBarWeek}from"./time-slot-bar-week/time-slot-bar-week.js";export{TimeSlotWeekView}from"./time-slot-week-view/time-slot-week-view.js";export{Timeline}from"./timeline/timeline.js";export{Timepicker}from"./timepicker/timepicker.js";export{TimeTable}from"./timetable/timetable.js";export{Toast}from"./toast/toast.js";export{Toggle}from"./toggle/toggle.js";export{Tooltip}from"./tooltip/tooltip.js";export{withTooltip}from"./tooltip/tooltip-hoc.js";export{Typography}from"./typography/typography.js";export{UneditableSection}from"./uneditable-section/index.js";export{UnitNumberInput}from"./unit-number/unit-number-input.js";export{V2_Color}from"./v2_color/color.js";export{V2_DesignToken}from"./v2_design-token/design-token.js";export{V2_Layout}from"./v2_layout/index.js";export{V2_MediaQuery,V2_MediaWidths}from"./v2_media/media.js";export{V2_TextStyleHelper}from"./v2_text/helper.js";export{V2_TextStyle}from"./v2_text/text-style.js";export{V2_Text}from"./v2_text/text.js";export{RedirectScope}from"./v2_text/types.js";export{V2_TextList}from"./v2_text-list/index.js";export{V2_BaseTheme,V2_BookingSGTheme,V2_CCubeTheme,V2_MyLegacyTheme,V2_OneServiceTheme,V2_RBSTheme}from"./v2_theme/index.js";export{V2_Transition}from"./v2_transition/index.js";export{DSThemeProvider}from"./theme/ds-theme-provider.js";export{V2_ThemeContextKeys}from"./v2_theme/types.js";export{createThemeWithColourMode,getSystemColourMode,useDSTheme}from"./theme/use-theme-mode.js";
|
|
1
|
+
export{Accordion}from"./accordion/accordion.js";export{Alert}from"./alert/alert.js";export{LoadingSpinner}from"./animations/loading-spinner/loading-spinner.js";export{LoadingDots}from"./animations/loading-dots/loading-dots.js";export{LoadingDotsSpinner}from"./animations/loading-dots-spinner/loading-dots-spinner.js";export{ThemedLoadingSpinner}from"./animations/themed-loading-spinner/themed-loading-spinner.js";export{Avatar}from"./avatar/avatar.js";export{Badge}from"./badge/badge.js";export{BoxContainer}from"./box-container/box-container.js";export{Breadcrumb}from"./breadcrumb/breadcrumb.js";export{Button}from"./button/button.js";export{ButtonWithIcon}from"./button-with-icon/button-with-icon.js";export{Calendar}from"./calendar/calendar.js";export{Card}from"./card/card.js";export{Checkbox}from"./checkbox/checkbox.js";export{CountdownTimer}from"./countdown-timer/countdown-timer.js";export{DataTable}from"./data-table/data-table.js";export{DateInput}from"./date-input/date-input.js";export{DateNavigator}from"./date-navigator/date-navigator.js";export{DateRangeInput}from"./date-range-input/date-range-input.js";export{Divider}from"./divider/divider.js";export{Drawer}from"./drawer/drawer.js";export{ESignature}from"./e-signature/e-signature.js";export{ErrorDisplay}from"./error-display/error-display.js";export{ErrorDisplayHelper}from"./error-display/helper.js";export{FeedbackRating}from"./feedback-rating/feedback-rating.js";export{FileDownload}from"./file-download/file-download.js";export{FileUpload}from"./file-upload/file-upload.js";export{Filter}from"./filter/filter.js";export{Footer}from"./footer/footer.js";export{Form}from"./form/index.js";export{Component,FullscreenImageCarousel}from"./fullscreen-image-carousel/fullscreen-image-carousel.js";export{HistogramSlider}from"./histogram-slider/histogram-slider.js";export{IconButton}from"./icon-button/icon-button.js";export{ImageButton}from"./image-button/image-button.js";export{Input}from"./input/input.js";export{InputGroup}from"./input-group/input-group.js";export{InputMultiSelect}from"./input-multi-select/input-multi-select.js";export{InputNestedMultiSelect}from"./input-nested-multi-select/input-nested-multi-select.js";export{InputNestedSelect}from"./input-nested-select/input-nested-select.js";export{InputRangeSelect}from"./input-range-select/input-range-select.js";export{InputRangeSlider}from"./input-range-slider/input-range-slider.js";export{InputSelect}from"./input-select/input-select.js";export{InputSlider}from"./input-slider/input-slider.js";export{Textarea}from"./input-textarea/textarea.js";export{LanguageSwitcher}from"./language-switcher/language-switcher.js";export{Layout}from"./layout/index.js";export{LinkList}from"./link-list/link-list.js";export{Markup}from"./markup/markup.js";export{MaskedInput}from"./masked-input/masked-input.js";export{Masonry}from"./masonry/masonry.js";export{Masthead}from"./masthead/masthead.js";export{Menu,MenuTrigger}from"./menu/menu.js";export{Modal}from"./modal/index.js";export{ModalV2}from"./modal-v2/index.js";export{Navbar}from"./navbar/navbar.js";export{NBComponent,NotificationBanner}from"./notification-banner/notification-banner.js";export{withNotificationBanner}from"./notification-banner/notification-banner-hoc.js";export{OtpInput}from"./otp-input/otp-input.js";export{Overlay}from"./overlay/overlay.js";export{Pagination}from"./pagination/pagination.js";export{PhoneNumberInput}from"./phone-number-input/phone-number-input.js";export{Pill}from"./pill/pill.js";export{withPopover}from"./popover/popover-hoc.js";export{Popover}from"./popover/popover.js";export{PopoverV2}from"./popover-v2/popover.js";export{PopoverInline}from"./popover-v2/popover-inline/popover-inline.js";export{PopoverTrigger}from"./popover-v2/popover-trigger.js";export{PredictiveTextInput}from"./predictive-text-input/predictive-text-input.js";export{ProgressIndicator}from"./progress-indicator/progress-indicator.js";export{RadioButton}from"./radio-button/radio-button.js";export{SelectHistogram}from"./select-histogram/select-histogram.js";export{Sidenav}from"./sidenav/sidenav.js";export{SingpassButton}from"./singpass-button/singpass-button.js";export{SmartAppBanner}from"./smart-app-banner/smart-app-banner.js";export{Tab}from"./tab/tab.js";export{Table}from"./table/table.js";export{Tag}from"./tag/tag.js";export{TextList}from"./text-list/index.js";export{A11yPlaygroundTheme,BookingSGTheme,Border,Breakpoint,CCubeTheme,CareerCompassTheme,Colour,Font,IMDATheme,LifeSGTheme,MediaQuery,Motion,MyLegacyTheme,OneServiceTheme,PATheme,RBSTheme,Radius,SGWDigitalLobbyTheme,SGWDigitalLobbyThemeBase,SMGSTheme,SPFTheme,Shadow,Spacing,SupportGoWhereTheme,SupportGoWhereThemeBase,ThemeComponent}from"./theme/index.js";export{TimeRangePicker}from"./time-range-picker/time-range-picker.js";export{TimeSlotBar}from"./time-slot-bar/time-slot-bar.js";export{TimeSlotBarWeek}from"./time-slot-bar-week/time-slot-bar-week.js";export{TimeSlotWeekView}from"./time-slot-week-view/time-slot-week-view.js";export{Timeline}from"./timeline/timeline.js";export{Timepicker}from"./timepicker/timepicker.js";export{TimeTable}from"./timetable/timetable.js";export{Toast}from"./toast/toast.js";export{Toggle}from"./toggle/toggle.js";export{Tooltip}from"./tooltip/tooltip.js";export{withTooltip}from"./tooltip/tooltip-hoc.js";export{Typography}from"./typography/typography.js";export{UneditableSection}from"./uneditable-section/index.js";export{UnitNumberInput}from"./unit-number/unit-number-input.js";export{V2_Color}from"./v2_color/color.js";export{V2_DesignToken}from"./v2_design-token/design-token.js";export{V2_Layout}from"./v2_layout/index.js";export{V2_MediaQuery,V2_MediaWidths}from"./v2_media/media.js";export{V2_TextStyleHelper}from"./v2_text/helper.js";export{V2_TextStyle}from"./v2_text/text-style.js";export{V2_Text}from"./v2_text/text.js";export{RedirectScope}from"./v2_text/types.js";export{V2_TextList}from"./v2_text-list/index.js";export{V2_BaseTheme,V2_BookingSGTheme,V2_CCubeTheme,V2_MyLegacyTheme,V2_OneServiceTheme,V2_RBSTheme}from"./v2_theme/index.js";export{V2_Transition}from"./v2_transition/index.js";export{DSThemeProvider}from"./theme/ds-theme-provider.js";export{V2_ThemeContextKeys}from"./v2_theme/types.js";export{createThemeWithColourMode,getSystemColourMode,useDSTheme}from"./theme/use-theme-mode.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifesg/react-design-system",
|
|
3
|
-
"version": "3.4.0-canary.
|
|
3
|
+
"version": "3.4.0-canary.7",
|
|
4
4
|
"description": "A component design system for LifeSG web apps",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design-system"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/LifeSG/react-design-system#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/LifeSG/react-design-system/issues"
|
|
11
|
+
},
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/LifeSG/react-design-system.git"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"npm": ">=11.10.0",
|
|
19
|
+
"node": ">=22.0.0"
|
|
20
|
+
},
|
|
5
21
|
"main": "./cjs/index.js",
|
|
6
22
|
"module": "./index.js",
|
|
7
23
|
"types": "./index.d.ts",
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import e,{css as t}from"styled-components";import{Colour as
|
|
1
|
+
import e,{css as t}from"styled-components";import{Colour as r,Font as i}from"../../theme/index.js";import{lineClampCss as l}from"../styles/index.js";const o=e.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
width: 100%;
|
|
4
|
-
${e=>{const
|
|
5
|
-
min-height: ${
|
|
6
|
-
height: ${
|
|
4
|
+
${e=>{const r="small"===e.$variant?2.5:3;return t`
|
|
5
|
+
min-height: ${r}rem;
|
|
6
|
+
height: ${r}rem; // Need this to persist the height when expanding or collapsing list
|
|
7
7
|
`}}
|
|
8
8
|
`,d=e.div`
|
|
9
9
|
display: flex;
|
|
10
10
|
flex: 1;
|
|
11
11
|
word-break: break-all;
|
|
12
12
|
${e=>{if(e.$disabled)return t`
|
|
13
|
-
color: ${
|
|
13
|
+
color: ${r["text-disabled"]};
|
|
14
14
|
`}}
|
|
15
15
|
`,n=e.div`
|
|
16
|
-
${e=>"small"===e.$variant?
|
|
16
|
+
${e=>"small"===e.$variant?i["body-md-regular"]:i["body-baseline-regular"]}
|
|
17
|
+
color: ${r.text};
|
|
17
18
|
text-align: left;
|
|
18
19
|
${e=>{if("middle"!==e.$truncateType)return t`
|
|
19
20
|
${l(1)}
|
|
20
21
|
`}}
|
|
21
22
|
overflow: hidden;
|
|
22
23
|
`,s=e(n)`
|
|
23
|
-
color: ${
|
|
24
|
+
color: ${r["text-subtler"]};
|
|
24
25
|
`;export{d as LabelContainer,s as PlaceholderLabel,n as ValueLabel,o as Wrapper};
|
|
25
26
|
//# sourceMappingURL=dropdown-wrapper.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-wrapper.styles.js","sources":["../../../src/shared/dropdown-wrapper/dropdown-wrapper.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Colour, Font } from \"../../theme\";\nimport { DropdownVariantType, TruncateType } from \"../dropdown-list/types\";\nimport { lineClampCss } from \"../styles\";\n\n// =============================================================================\n// STYLE INTERFACE\n// =============================================================================\nexport interface DropdownWrapperStyleProps {\n $disabled?: boolean;\n $readOnly?: boolean;\n $error?: boolean;\n $expanded?: boolean;\n}\n\nexport interface ValueLabelStyleProps {\n $truncateType?: TruncateType;\n $variant?: DropdownVariantType | undefined;\n}\n\nexport interface SelectorStyleProps {\n $variant?: DropdownVariantType | undefined;\n}\n\nexport interface LabelContainerStyleProps {\n $disabled?: boolean | undefined;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\nconst getHeight = (variant?: DropdownVariantType | undefined) => {\n return variant === \"small\" ? 2.5 : 3;\n};\n\nexport const Wrapper = styled.div<SelectorStyleProps>`\n position: relative;\n width: 100%;\n ${(props) => {\n const height = getHeight(props.$variant);\n return css`\n min-height: ${height}rem;\n height: ${height}rem; // Need this to persist the height when expanding or collapsing list\n `;\n }}\n`;\n\nexport const LabelContainer = styled.div<LabelContainerStyleProps>`\n display: flex;\n flex: 1;\n word-break: break-all;\n ${(props) => {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n }}\n`;\n\nexport const ValueLabel = styled.div<ValueLabelStyleProps>`\n ${(props) =>\n props.$variant === \"small\"\n ? Font[\"body-md-regular\"]\n : Font[\"body-baseline-regular\"]}\n text-align: left;\n ${(props) => {\n switch (props.$truncateType) {\n case \"middle\":\n break;\n case \"end\":\n default:\n return css`\n ${lineClampCss(1)}\n `;\n }\n }}\n overflow: hidden;\n`;\n\nexport const PlaceholderLabel = styled(ValueLabel)`\n color: ${Colour[\"text-subtler\"]};\n`;\n"],"names":["Wrapper","styled","div","props","height","$variant","css","LabelContainer","$disabled","Colour","ValueLabel","Font","$truncateType","lineClampCss","PlaceholderLabel"],"mappings":"qJA+BA,MAIaA,EAAUC,EAAOC,GAAuB;;;MAG9CC,IACC,MAAMC,EAPS,UAOUD,EAAME,SAPN,IAAM,EAQ/B,OAAOC,CAAG;0BACQF;sBACJA;SACb;EAIIG,EAAiBN,EAAOC,GAA6B;;;;MAI3DC,IACC,GAAIA,EAAMK,UACN,OAAOF,CAAG;yBACGG,EAAO;aAExB;EAIKC,EAAaT,EAAOC,GAAyB;MACnDC,GACoB,UAAnBA,EAAME,SACAM,EAAK,mBACLA,EAAK;;
|
|
1
|
+
{"version":3,"file":"dropdown-wrapper.styles.js","sources":["../../../src/shared/dropdown-wrapper/dropdown-wrapper.styles.tsx"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Colour, Font } from \"../../theme\";\nimport { DropdownVariantType, TruncateType } from \"../dropdown-list/types\";\nimport { lineClampCss } from \"../styles\";\n\n// =============================================================================\n// STYLE INTERFACE\n// =============================================================================\nexport interface DropdownWrapperStyleProps {\n $disabled?: boolean;\n $readOnly?: boolean;\n $error?: boolean;\n $expanded?: boolean;\n}\n\nexport interface ValueLabelStyleProps {\n $truncateType?: TruncateType;\n $variant?: DropdownVariantType | undefined;\n}\n\nexport interface SelectorStyleProps {\n $variant?: DropdownVariantType | undefined;\n}\n\nexport interface LabelContainerStyleProps {\n $disabled?: boolean | undefined;\n}\n\n// =============================================================================\n// STYLING\n// =============================================================================\nconst getHeight = (variant?: DropdownVariantType | undefined) => {\n return variant === \"small\" ? 2.5 : 3;\n};\n\nexport const Wrapper = styled.div<SelectorStyleProps>`\n position: relative;\n width: 100%;\n ${(props) => {\n const height = getHeight(props.$variant);\n return css`\n min-height: ${height}rem;\n height: ${height}rem; // Need this to persist the height when expanding or collapsing list\n `;\n }}\n`;\n\nexport const LabelContainer = styled.div<LabelContainerStyleProps>`\n display: flex;\n flex: 1;\n word-break: break-all;\n ${(props) => {\n if (props.$disabled) {\n return css`\n color: ${Colour[\"text-disabled\"]};\n `;\n }\n }}\n`;\n\nexport const ValueLabel = styled.div<ValueLabelStyleProps>`\n ${(props) =>\n props.$variant === \"small\"\n ? Font[\"body-md-regular\"]\n : Font[\"body-baseline-regular\"]}\n color: ${Colour[\"text\"]};\n text-align: left;\n ${(props) => {\n switch (props.$truncateType) {\n case \"middle\":\n break;\n case \"end\":\n default:\n return css`\n ${lineClampCss(1)}\n `;\n }\n }}\n overflow: hidden;\n`;\n\nexport const PlaceholderLabel = styled(ValueLabel)`\n color: ${Colour[\"text-subtler\"]};\n`;\n"],"names":["Wrapper","styled","div","props","height","$variant","css","LabelContainer","$disabled","Colour","ValueLabel","Font","$truncateType","lineClampCss","PlaceholderLabel"],"mappings":"qJA+BA,MAIaA,EAAUC,EAAOC,GAAuB;;;MAG9CC,IACC,MAAMC,EAPS,UAOUD,EAAME,SAPN,IAAM,EAQ/B,OAAOC,CAAG;0BACQF;sBACJA;SACb;EAIIG,EAAiBN,EAAOC,GAA6B;;;;MAI3DC,IACC,GAAIA,EAAMK,UACN,OAAOF,CAAG;yBACGG,EAAO;aAExB;EAIKC,EAAaT,EAAOC,GAAyB;MACnDC,GACoB,UAAnBA,EAAME,SACAM,EAAK,mBACLA,EAAK;aACNF,EAAa;;MAEnBN,IACC,GACS,WADDA,EAAMS,cAKN,OAAON,CAAG;sBACJO,EAAa;;;EAOtBC,EAAmBb,EAAOS,EAAW;aACrCD,EAAO;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import t from"../../../external/dayjs/dayjs.min.js";import{CalendarHelper as r}from"../../../util/calendar-helper.js";import"../../../util/date-helper.js";import"../../../util/date-input-helper.js";import"react";import"../../../util/simple-id-generator.js";import"../../../util/string-helper.js";import"@react-aria/live-announcer";import{DayCell as a}from"../day-cell/day-cell.js";const o=({date:o,calendarDate:l,selectedDate:i,hoverDate:n,focusDate:c,minDate:s,maxDate:d,disabledDates:u,allowDisabledSelection:m,showActiveMonthDaysOnly:p,onSelect:y,onHover:D,onFocus:h,setFocusCell:f,tabIndex:b})=>{const v=r.isDisabledDay(o,u,s,d),Y=!v||m,j=()=>{y(o,!Y)},w={date:o,calendarDate:l,disabled:v,interactive:Y,currentDateIndicator:!0,onSelect:j,onHover:()=>{D(o.format("YYYY-MM-DD"),!Y)},onFocus:()=>{h(o.format("YYYY-MM-DD"))},onKeyDown:e=>{const t=e.key;if("Enter"===t||" "===t)return e.preventDefault(),void(Y&&j());(e=>{let t;const r={ArrowLeft:()=>o.subtract(1,"day"),ArrowRight:()=>o.add(1,"day"),ArrowUp:()=>o.subtract(7,"day"),ArrowDown:()=>o.add(7,"day"),Home:()=>o.startOf("week"),End:()=>o.endOf("week"),PageUp:()=>e.shiftKey?o.subtract(1,"year"):o.subtract(1,"month"),PageDown:()=>e.shiftKey?o.add(1,"year"):o.add(1,"month")}[e.key];r&&(e.preventDefault(),t=r(),f(t.format("YYYY-MM-DD")))})(e)},role:"gridcell",focusDate:t(c),tabIndex:b};return e(a,Object.assign({},w,(()=>{const e={};l.month()!==o.month()?e.labelType=p?"hidden":"unavailable":t().isSame(o,"day")&&!v&&(e.labelType="current");const r=o.isSame(i,"day"),a=o.isSame(n,"day");return r&&a?(e.labelType="selected-hover",e.circleLeft="selected-hover-outline",e.circleRight="selected-hover-outline"):r?(e.labelType="selected",e.circleLeft="selected-outline",e.circleRight="selected-outline"):a&&(e.labelType="hover",e.circleLeft="hover-subtle",e.circleRight="hover-subtle"),e})()))};export{o as SingleCell};
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"../../../external/dayjs/dayjs.min.js";import{CalendarHelper as r}from"../../../util/calendar-helper.js";import"../../../util/date-helper.js";import"../../../util/date-input-helper.js";import"react";import"../../../util/simple-id-generator.js";import"../../../util/string-helper.js";import"@react-aria/live-announcer";import{DayCell as a}from"../day-cell/day-cell.js";const o=({date:o,calendarDate:l,selectedDate:i,hoverDate:n,focusDate:c,minDate:s,maxDate:d,disabledDates:u,allowDisabledSelection:m,showActiveMonthDaysOnly:p,onSelect:y,onHover:D,onFocus:h,setFocusCell:f,tabIndex:b})=>{const v=r.isDisabledDay(o,u,s,d),Y=!v||m,j=()=>{y(o,!Y)},w={date:o,calendarDate:l,disabled:v,interactive:Y,currentDateIndicator:!0,onSelect:j,onHover:()=>{D(o.format("YYYY-MM-DD"),!Y)},onFocus:()=>{h(o.format("YYYY-MM-DD"))},onKeyDown:e=>{const t=e.key;if("Enter"===t||" "===t)return e.preventDefault(),void(Y&&j());(e=>{let t;const r={ArrowLeft:()=>o.subtract(1,"day"),ArrowRight:()=>o.add(1,"day"),ArrowUp:()=>o.subtract(7,"day"),ArrowDown:()=>o.add(7,"day"),Home:()=>o.startOf("week"),End:()=>o.endOf("week"),PageUp:()=>e.shiftKey?o.subtract(1,"year"):o.subtract(1,"month"),PageDown:()=>e.shiftKey?o.add(1,"year"):o.add(1,"month")}[e.key];r&&(e.preventDefault(),t=r(),f(t.format("YYYY-MM-DD")))})(e)},role:"gridcell",focusDate:t(c),tabIndex:b};return e(a,Object.assign({},w,(()=>{const e={};l.month()!==o.month()?e.labelType=p?"hidden":"unavailable":t().isSame(o,"day")&&!v&&(e.labelType="current");const r=i&&o.isSame(i,"day"),a=o.isSame(n,"day");return r&&a?(e.labelType="selected-hover",e.circleLeft="selected-hover-outline",e.circleRight="selected-hover-outline"):r?(e.labelType="selected",e.circleLeft="selected-outline",e.circleRight="selected-outline"):a&&(e.labelType="hover",e.circleLeft="hover-subtle",e.circleRight="hover-subtle"),e})()))};export{o as SingleCell};
|
|
2
2
|
//# sourceMappingURL=single-cell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-cell.js","sources":["../../../../src/shared/internal-calendar/single/single-cell.tsx"],"sourcesContent":["import dayjs, { Dayjs } from \"dayjs\";\nimport { CalendarHelper } from \"../../../util\";\nimport { CellStyleProps, DayCell, DayCellProps } from \"../day-cell\";\n\ninterface Props {\n date: Dayjs;\n calendarDate: Dayjs;\n selectedDate: string | undefined;\n hoverDate: string | undefined;\n focusDate: string;\n minDate?: string | undefined;\n maxDate?: string | undefined;\n disabledDates?: string[] | undefined;\n allowDisabledSelection?: boolean | undefined;\n showActiveMonthDaysOnly?: boolean | undefined;\n onSelect: (value: Dayjs, disabled: boolean) => void;\n onHover: (value: string, disabled: boolean) => void;\n onFocus: (value: string) => void;\n setFocusCell: (value: string) => void;\n tabIndex: number;\n}\n\nexport const SingleCell = ({\n date,\n calendarDate,\n selectedDate,\n hoverDate,\n focusDate,\n minDate,\n maxDate,\n disabledDates,\n allowDisabledSelection,\n showActiveMonthDaysOnly,\n onSelect,\n onHover,\n onFocus,\n setFocusCell,\n tabIndex,\n}: Props) => {\n // =========================================================================\n // CONSTS\n // =========================================================================\n const disabled = CalendarHelper.isDisabledDay(\n date,\n disabledDates,\n minDate,\n maxDate\n );\n const interactive = !disabled || allowDisabledSelection;\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleSelect = () => {\n onSelect(date, !interactive);\n };\n\n const handleHover = () => {\n onHover(date.format(\"YYYY-MM-DD\"), !interactive);\n };\n\n const handleFocus = () => {\n onFocus(date.format(\"YYYY-MM-DD\"));\n };\n\n const handleKeyNavigation = (event: React.KeyboardEvent) => {\n let newFocusSelection: Dayjs | undefined;\n\n const keyActions: Record<string, () => dayjs.Dayjs> = {\n ArrowLeft: () => date.subtract(1, \"day\"),\n ArrowRight: () => date.add(1, \"day\"),\n ArrowUp: () => date.subtract(7, \"day\"),\n ArrowDown: () => date.add(7, \"day\"),\n Home: () => date.startOf(\"week\"),\n End: () => date.endOf(\"week\"),\n PageUp: () => {\n return event.shiftKey\n ? date.subtract(1, \"year\")\n : date.subtract(1, \"month\");\n },\n PageDown: () => {\n return event.shiftKey\n ? date.add(1, \"year\")\n : date.add(1, \"month\");\n },\n };\n\n const action = keyActions[event.key];\n if (action) {\n event.preventDefault();\n newFocusSelection = action();\n setFocusCell(newFocusSelection.format(\"YYYY-MM-DD\"));\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n const keyboardEvent = event as React.KeyboardEvent<HTMLInputElement>;\n const selectedKey = keyboardEvent.key;\n\n if (selectedKey === \"Enter\" || selectedKey === \" \") {\n event.preventDefault();\n if (interactive) {\n handleSelect();\n }\n return;\n }\n\n handleKeyNavigation(event);\n };\n\n // =========================================================================\n // HELPERS\n // =========================================================================\n const getCellStyle = () => {\n const props: CellStyleProps = {};\n\n if (calendarDate.month() !== date.month()) {\n props.labelType = showActiveMonthDaysOnly\n ? \"hidden\"\n : \"unavailable\";\n } else if (dayjs().isSame(date, \"day\") && !disabled) {\n props.labelType = \"current\";\n }\n\n const isSelected = date.isSame(selectedDate, \"day\");\n const isHover = date.isSame(hoverDate, \"day\");\n\n if (isSelected && isHover) {\n props.labelType = \"selected-hover\";\n props.circleLeft = \"selected-hover-outline\";\n props.circleRight = \"selected-hover-outline\";\n } else if (isSelected) {\n props.labelType = \"selected\";\n props.circleLeft = \"selected-outline\";\n props.circleRight = \"selected-outline\";\n } else if (isHover) {\n props.labelType = \"hover\";\n props.circleLeft = \"hover-subtle\";\n props.circleRight = \"hover-subtle\";\n }\n\n return props;\n };\n\n // =============================================================================\n // RENDER FUNCTION\n // =============================================================================\n\n const commonProps: DayCellProps = {\n date,\n calendarDate,\n disabled,\n interactive,\n currentDateIndicator: true,\n onSelect: handleSelect,\n onHover: handleHover,\n onFocus: handleFocus,\n onKeyDown: handleKeyDown,\n role: \"gridcell\",\n focusDate: dayjs(focusDate),\n tabIndex,\n };\n\n return <DayCell {...commonProps} {...getCellStyle()} />;\n};\n"],"names":["SingleCell","date","calendarDate","selectedDate","hoverDate","focusDate","minDate","maxDate","disabledDates","allowDisabledSelection","showActiveMonthDaysOnly","onSelect","onHover","onFocus","setFocusCell","tabIndex","disabled","CalendarHelper","isDisabledDay","interactive","handleSelect","commonProps","currentDateIndicator","format","onKeyDown","event","selectedKey","key","preventDefault","newFocusSelection","action","ArrowLeft","subtract","ArrowRight","add","ArrowUp","ArrowDown","Home","startOf","End","endOf","PageUp","shiftKey","PageDown","handleKeyNavigation","role","dayjs","_jsx","DayCell","Object","assign","props","month","labelType","isSame","isSelected","isHover","circleLeft","circleRight","getCellStyle"],"mappings":"qaAsBO,MAAMA,EAAa,EACtBC,OACAC,eACAC,eACAC,YACAC,YACAC,UACAC,UACAC,gBACAC,yBACAC,0BACAC,WACAC,UACAC,UACAC,eACAC,eAKA,MAAMC,EAAWC,EAAeC,cAC5BjB,EACAO,EACAF,EACAC,GAEEY,GAAeH,GAAYP,EAK3BW,EAAe,KACjBT,EAASV,GAAOkB,EAAY,EA8F1BE,EAA4B,CAC9BpB,OACAC,eACAc,WACAG,cACAG,sBAAsB,EACtBX,SAAUS,EACVR,QAlGgB,KAChBA,EAAQX,EAAKsB,OAAO,eAAgBJ,EAAY,EAkGhDN,QA/FgB,KAChBA,EAAQZ,EAAKsB,OAAO,cAAc,EA+FlCC,UA9DmBC,IACnB,MACMC,EADgBD,EACYE,IAElC,GAAoB,UAAhBD,GAA2C,MAAhBA,EAK3B,OAJAD,EAAMG,sBACFT,GACAC,KArCgB,CAACK,IACzB,IAAII,EAEJ,MAmBMC,EAnBgD,CAClDC,UAAW,IAAM9B,EAAK+B,SAAS,EAAG,OAClCC,WAAY,IAAMhC,EAAKiC,IAAI,EAAG,OAC9BC,QAAS,IAAMlC,EAAK+B,SAAS,EAAG,OAChCI,UAAW,IAAMnC,EAAKiC,IAAI,EAAG,OAC7BG,KAAM,IAAMpC,EAAKqC,QAAQ,QACzBC,IAAK,IAAMtC,EAAKuC,MAAM,QACtBC,OAAQ,IACGhB,EAAMiB,SACPzC,EAAK+B,SAAS,EAAG,QACjB/B,EAAK+B,SAAS,EAAG,SAE3BW,SAAU,IACClB,EAAMiB,SACPzC,EAAKiC,IAAI,EAAG,QACZjC,EAAKiC,IAAI,EAAG,UAIAT,EAAME,KAC5BG,IACAL,EAAMG,iBACNC,EAAoBC,IACpBhB,EAAae,EAAkBN,OAAO,eAC1C,EAeAqB,CAAoBnB,EAAM,EAmD1BoB,KAAM,WACNxC,UAAWyC,EAAMzC,GACjBU,YAGJ,OAAOgC,EAACC,EAAOC,OAAAC,OAAA,CAAA,EAAK7B,EAlDC,MACjB,MAAM8B,EAAwB,CAAA,EAE1BjD,EAAakD,UAAYnD,EAAKmD,QAC9BD,EAAME,UAAY3C,EACZ,SACA,cACCoC,IAAQQ,OAAOrD,EAAM,SAAWe,IACvCmC,EAAME,UAAY,WAGtB,MAAME,
|
|
1
|
+
{"version":3,"file":"single-cell.js","sources":["../../../../src/shared/internal-calendar/single/single-cell.tsx"],"sourcesContent":["import dayjs, { Dayjs } from \"dayjs\";\nimport { CalendarHelper } from \"../../../util\";\nimport { CellStyleProps, DayCell, DayCellProps } from \"../day-cell\";\n\ninterface Props {\n date: Dayjs;\n calendarDate: Dayjs;\n selectedDate: string | undefined;\n hoverDate: string | undefined;\n focusDate: string;\n minDate?: string | undefined;\n maxDate?: string | undefined;\n disabledDates?: string[] | undefined;\n allowDisabledSelection?: boolean | undefined;\n showActiveMonthDaysOnly?: boolean | undefined;\n onSelect: (value: Dayjs, disabled: boolean) => void;\n onHover: (value: string, disabled: boolean) => void;\n onFocus: (value: string) => void;\n setFocusCell: (value: string) => void;\n tabIndex: number;\n}\n\nexport const SingleCell = ({\n date,\n calendarDate,\n selectedDate,\n hoverDate,\n focusDate,\n minDate,\n maxDate,\n disabledDates,\n allowDisabledSelection,\n showActiveMonthDaysOnly,\n onSelect,\n onHover,\n onFocus,\n setFocusCell,\n tabIndex,\n}: Props) => {\n // =========================================================================\n // CONSTS\n // =========================================================================\n const disabled = CalendarHelper.isDisabledDay(\n date,\n disabledDates,\n minDate,\n maxDate\n );\n const interactive = !disabled || allowDisabledSelection;\n\n // =========================================================================\n // EVENT HANDLERS\n // =========================================================================\n const handleSelect = () => {\n onSelect(date, !interactive);\n };\n\n const handleHover = () => {\n onHover(date.format(\"YYYY-MM-DD\"), !interactive);\n };\n\n const handleFocus = () => {\n onFocus(date.format(\"YYYY-MM-DD\"));\n };\n\n const handleKeyNavigation = (event: React.KeyboardEvent) => {\n let newFocusSelection: Dayjs | undefined;\n\n const keyActions: Record<string, () => dayjs.Dayjs> = {\n ArrowLeft: () => date.subtract(1, \"day\"),\n ArrowRight: () => date.add(1, \"day\"),\n ArrowUp: () => date.subtract(7, \"day\"),\n ArrowDown: () => date.add(7, \"day\"),\n Home: () => date.startOf(\"week\"),\n End: () => date.endOf(\"week\"),\n PageUp: () => {\n return event.shiftKey\n ? date.subtract(1, \"year\")\n : date.subtract(1, \"month\");\n },\n PageDown: () => {\n return event.shiftKey\n ? date.add(1, \"year\")\n : date.add(1, \"month\");\n },\n };\n\n const action = keyActions[event.key];\n if (action) {\n event.preventDefault();\n newFocusSelection = action();\n setFocusCell(newFocusSelection.format(\"YYYY-MM-DD\"));\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n const keyboardEvent = event as React.KeyboardEvent<HTMLInputElement>;\n const selectedKey = keyboardEvent.key;\n\n if (selectedKey === \"Enter\" || selectedKey === \" \") {\n event.preventDefault();\n if (interactive) {\n handleSelect();\n }\n return;\n }\n\n handleKeyNavigation(event);\n };\n\n // =========================================================================\n // HELPERS\n // =========================================================================\n const getCellStyle = () => {\n const props: CellStyleProps = {};\n\n if (calendarDate.month() !== date.month()) {\n props.labelType = showActiveMonthDaysOnly\n ? \"hidden\"\n : \"unavailable\";\n } else if (dayjs().isSame(date, \"day\") && !disabled) {\n props.labelType = \"current\";\n }\n\n const isSelected = selectedDate && date.isSame(selectedDate, \"day\");\n const isHover = date.isSame(hoverDate, \"day\");\n\n if (isSelected && isHover) {\n props.labelType = \"selected-hover\";\n props.circleLeft = \"selected-hover-outline\";\n props.circleRight = \"selected-hover-outline\";\n } else if (isSelected) {\n props.labelType = \"selected\";\n props.circleLeft = \"selected-outline\";\n props.circleRight = \"selected-outline\";\n } else if (isHover) {\n props.labelType = \"hover\";\n props.circleLeft = \"hover-subtle\";\n props.circleRight = \"hover-subtle\";\n }\n\n return props;\n };\n\n // =============================================================================\n // RENDER FUNCTION\n // =============================================================================\n\n const commonProps: DayCellProps = {\n date,\n calendarDate,\n disabled,\n interactive,\n currentDateIndicator: true,\n onSelect: handleSelect,\n onHover: handleHover,\n onFocus: handleFocus,\n onKeyDown: handleKeyDown,\n role: \"gridcell\",\n focusDate: dayjs(focusDate),\n tabIndex,\n };\n\n return <DayCell {...commonProps} {...getCellStyle()} />;\n};\n"],"names":["SingleCell","date","calendarDate","selectedDate","hoverDate","focusDate","minDate","maxDate","disabledDates","allowDisabledSelection","showActiveMonthDaysOnly","onSelect","onHover","onFocus","setFocusCell","tabIndex","disabled","CalendarHelper","isDisabledDay","interactive","handleSelect","commonProps","currentDateIndicator","format","onKeyDown","event","selectedKey","key","preventDefault","newFocusSelection","action","ArrowLeft","subtract","ArrowRight","add","ArrowUp","ArrowDown","Home","startOf","End","endOf","PageUp","shiftKey","PageDown","handleKeyNavigation","role","dayjs","_jsx","DayCell","Object","assign","props","month","labelType","isSame","isSelected","isHover","circleLeft","circleRight","getCellStyle"],"mappings":"qaAsBO,MAAMA,EAAa,EACtBC,OACAC,eACAC,eACAC,YACAC,YACAC,UACAC,UACAC,gBACAC,yBACAC,0BACAC,WACAC,UACAC,UACAC,eACAC,eAKA,MAAMC,EAAWC,EAAeC,cAC5BjB,EACAO,EACAF,EACAC,GAEEY,GAAeH,GAAYP,EAK3BW,EAAe,KACjBT,EAASV,GAAOkB,EAAY,EA8F1BE,EAA4B,CAC9BpB,OACAC,eACAc,WACAG,cACAG,sBAAsB,EACtBX,SAAUS,EACVR,QAlGgB,KAChBA,EAAQX,EAAKsB,OAAO,eAAgBJ,EAAY,EAkGhDN,QA/FgB,KAChBA,EAAQZ,EAAKsB,OAAO,cAAc,EA+FlCC,UA9DmB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nBN,EAAMO,YAAc,gBAGjBP,CAAK,EAsBqBQ,IAAkB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import n from"../../external/dayjs/dayjs.min.js";import r from"../../external/dayjs/plugin/customParseFormat.js";import a,{useState as o,useRef as l,useEffect as u,useImperativeHandle as i}from"react";import"../../util/calendar-helper.js";import"../../util/date-helper.js";import{DateInputHelper as c}from"../../util/date-input-helper.js";import"../../util/simple-id-generator.js";import{StringHelper as d}from"../../util/string-helper.js";import"@react-aria/live-announcer";import{useStateRef as s}from"../../util/use-state-ref.js";import{InputSection as p,InputContainer as m,DayInputSizer as h,DayInput as f,Divider as v,MonthInputSizer as g,MonthInput as y,YearInputSizer as b,YearInput as Y,Placeholder as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import n from"../../external/dayjs/dayjs.min.js";import r from"../../external/dayjs/plugin/customParseFormat.js";import a,{useState as o,useRef as l,useEffect as u,useImperativeHandle as i}from"react";import"../../util/calendar-helper.js";import"../../util/date-helper.js";import{DateInputHelper as c}from"../../util/date-input-helper.js";import"../../util/simple-id-generator.js";import{StringHelper as d}from"../../util/string-helper.js";import"@react-aria/live-announcer";import{useStateRef as s}from"../../util/use-state-ref.js";import{InputSection as p,InputContainer as m,DayInputSizer as h,DayInput as f,Divider as v,MonthInputSizer as g,MonthInput as y,YearInputSizer as b,YearInput as Y,Placeholder as $}from"./standalone-date-input.style.js";n.extend(r);const x=({disabled:r,readOnly:a,names:x,value:j,focused:D,hoverValue:M,placeholder:C,label:k,onChange:w,onFocus:B,onBlur:F,hideInputKeyboard:I,inputLabels:V=["Date","Month","Year"]},L)=>{const O=I?"none":"numeric",[E,K,S]=s(""),[P,R,z]=s(""),[T,q,A]=s(""),[G,H]=o("none"),[J,N]=o(!1),Q=l(null),U=l(null),W=l(null),X=l(null),[Z,_,ee]=le(M);u((()=>{var e;const[t="",n="",r=""]=le(j);K(t),R(n),q(r),t||n||r||!Q.current||!Q.current.contains(document.activeElement)||null===(e=U.current)||void 0===e||e.focus()}),[j]),u((()=>{var e;D||H("none"),D&&(N(!0),Q.current&&!Q.current.contains(document.activeElement)&&(null===(e=U.current)||void 0===e||e.focus()))}),[D]),i(L,(()=>({ref:Q,resetPlaceholder(){N(!1)},resetInput(){const[e="",t="",n=""]=le(j);K(e),R(t),q(n)},focusYearRef(){var e;null===(e=X.current)||void 0===e||e.focus()}})),[K,R,q,j]);const te=e=>{var t;e.preventDefault(),null===(t=U.current)||void 0===t||t.focus()},ne=e=>{e.target.select();const t=e.target.name;H(t)},re=e=>{const[t,r,a]=x,o={[t]:S.current,[r]:z.current,[a]:A.current},l=e.target.name,u=o[l],i=l!==a?d.padValue(u,!0):u;switch(l){case t:o[t]=i,K(i);break;case r:o[r]=i,R(i)}const c=`${o[a]}-${o[r]}-${o[t]}`,s=n(c,"YYYY-MM-DD",!0).isValid(),p=!o[t]&&!o[r]&&!o[a];s&&u!==i&&w(c),Q.current&&!Q.current.contains(e.relatedTarget)&&(H("none"),null==F||F(p||s))},ae=e=>{var t,r;if(M)return;const a=e.target.name,o=e.target.value.replace(/[^0-9]/g,""),l={day:E,month:P,year:T};switch(a){case x[0]:l.day=o,K(o),2===o.length&&(null===(t=W.current)||void 0===t||t.focus());break;case x[1]:l.month=o,R(o),2===o.length&&(null===(r=X.current)||void 0===r||r.focus());break;case x[2]:l.year=o,q(o)}if(!l.day&&!l.month&&!l.year)return void w("");const u=`${l.year}-${l.month}-${l.day}`;n(u,"YYYY-MM-DD",!0).isValid()&&w(u)},oe=e=>{var t,n;"Backspace"!==e.code&&"Backspace"!==e.key||(G===x[1]&&0===P.length&&(null===(t=U.current)||void 0===t||t.focus()),G===x[2]&&0===T.length&&(null===(n=W.current)||void 0===n||n.focus()))};function le(e){if(e){const t=c.sanitizeInput(e);if(!t)return[void 0,void 0,void 0];const r=n(t,"YYYY-MM-DD",!0);return[d.padValue(r.date().toString()),d.padValue((r.month()+1).toString()),r.year().toString()]}return[void 0,void 0,void 0]}return e(p,{role:"group","aria-label":k,onClick:()=>{var e;r||a||(N(!0),Q.current&&!Q.current.contains(document.activeElement)&&(null===(e=U.current)||void 0===e||e.focus()))},onFocus:e=>{r||(N(!0),D||null==B||B(e))},children:[e(m,{ref:Q,$hover:!!M,children:[t(h,{children:t(f,{ref:U,name:x[0],maxLength:2,value:null!=Z?Z:E,onFocus:ne,onBlur:re,onChange:ae,type:"text",inputMode:O,pattern:"[0-9]{2}","data-testid":`${x[0]}-input`,"aria-label":V[0],disabled:r,readOnly:a,tabIndex:a?-1:0,autoComplete:"off",placeholder:G!==x[0]||a?"DD":""})}),t(v,{$inactive:0===E.length,$disabled:r,children:"/"}),t(g,{children:t(y,{ref:W,name:x[1],maxLength:2,value:null!=_?_:P,onFocus:ne,onBlur:re,onChange:ae,onKeyDown:oe,type:"text",inputMode:O,pattern:"[0-9]{2}","data-testid":`${x[1]}-input`,"aria-label":V[1],disabled:r,readOnly:a,tabIndex:a?-1:0,autoComplete:"off",placeholder:G!==x[1]||a?"MM":""})}),t(v,{$inactive:0===P.length,$disabled:r,children:"/"}),t(b,{children:t(Y,{ref:X,name:x[2],maxLength:4,value:null!=ee?ee:T,onFocus:ne,onBlur:re,onChange:ae,onKeyDown:oe,type:"text",inputMode:O,pattern:"[0-9]{4}","data-testid":`${x[2]}-input`,"aria-label":V[2],disabled:r,readOnly:a,tabIndex:a?-1:0,autoComplete:"off",placeholder:G!==x[2]||a?"YYYY":""})})]}),(()=>{if(!j&&!a&&C)return t($,{$hide:J,$disabled:r,onMouseDown:te,children:C})})()]})},j=a.forwardRef(x);export{x as Component,j as StandaloneDateInput};
|
|
2
2
|
//# sourceMappingURL=standalone-date-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone-date-input.js","sources":["../../../src/shared/standalone-date-input/standalone-date-input.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\nimport React, { useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport { DateInputHelper, StringHelper, useStateRef } from \"../../util\";\nimport {\n DayInput,\n DayInputSizer,\n Divider,\n InputContainer,\n InputSection,\n MonthInput,\n MonthInputSizer,\n Placeholder,\n YearInput,\n YearInputSizer,\n} from \"./standalone-date-input.style\";\n\ndayjs.extend(customParseFormat);\n\ntype StartInputNames = [\"start-day\", \"start-month\", \"start-year\"];\ntype EndInputNames = [\"end-day\", \"end-month\", \"end-year\"];\n\nexport type FieldType =\n | StartInputNames[number]\n | EndInputNames[number]\n | \"none\";\n\ninterface Props {\n disabled?: boolean | undefined;\n readOnly?: boolean | undefined;\n hideInputKeyboard?: boolean | undefined;\n names: StartInputNames | EndInputNames;\n value: string | undefined;\n hoverValue?: string | undefined;\n focused: boolean;\n placeholder?: string | undefined;\n label?: string | undefined;\n inputLabels?: string[] | undefined;\n onChange: (value: string) => void;\n onFocus?: ((event: React.FocusEvent) => void) | undefined;\n onBlur?: ((valid: boolean) => void) | undefined;\n}\n\nexport interface StandaloneDateInputRef {\n ref: React.RefObject<HTMLDivElement>;\n resetPlaceholder: () => void;\n resetInput: () => void;\n focusYearRef: () => void;\n}\n\nexport const Component = (\n {\n disabled,\n readOnly,\n names,\n value,\n focused,\n hoverValue,\n placeholder,\n label,\n onChange,\n onFocus,\n onBlur,\n hideInputKeyboard,\n inputLabels = [\"Date\", \"Month\", \"Year\"],\n }: Props,\n ref: React.ForwardedRef<StandaloneDateInputRef>\n) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const inputMode = hideInputKeyboard ? \"none\" : \"numeric\";\n\n const [dayValue, setDayValue, dayValueRef] = useStateRef<string>(\"\");\n const [monthValue, setMonthValue, monthValueRef] = useStateRef<string>(\"\");\n const [yearValue, setYearValue, yearValueRef] = useStateRef<string>(\"\");\n const [currentFocus, setCurrentFocus] = useState<FieldType>(\"none\");\n const [hidePlaceholder, setHidePlaceholder] = useState<boolean>(false);\n\n const nodeRef = useRef<HTMLDivElement>(null);\n const dayInputRef = useRef<HTMLInputElement>(null);\n const monthInputRef = useRef<HTMLInputElement>(null);\n const yearInputRef = useRef<HTMLInputElement>(null);\n\n const [hoverDayValue, hoverMonthValue, hoverYearValue] =\n parseToInputValues(hoverValue);\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n const [day = \"\", month = \"\", year = \"\"] = parseToInputValues(value);\n setDayValue(day);\n setMonthValue(month);\n setYearValue(year);\n\n // re-focus on day input if all 3 inputs get cleared while typing\n if (\n !day &&\n !month &&\n !year &&\n nodeRef.current &&\n nodeRef.current.contains(document.activeElement)\n )\n dayInputRef.current?.focus();\n }, [value]);\n\n useEffect(() => {\n // clear internal focus state\n if (!focused) {\n setCurrentFocus(\"none\");\n }\n\n // ensure at least one input is focused\n if (focused) {\n setHidePlaceholder(true);\n\n if (\n nodeRef.current &&\n !nodeRef.current.contains(document.activeElement)\n ) {\n dayInputRef.current?.focus();\n }\n }\n }, [focused]);\n\n useImperativeHandle(\n ref,\n () => ({\n ref: nodeRef,\n resetPlaceholder() {\n setHidePlaceholder(false);\n },\n resetInput() {\n const [day = \"\", month = \"\", year = \"\"] =\n parseToInputValues(value);\n setDayValue(day);\n setMonthValue(month);\n setYearValue(year);\n },\n focusYearRef() {\n yearInputRef.current?.focus();\n },\n }),\n [setDayValue, setMonthValue, setYearValue, value]\n );\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleSectionClick = () => {\n if (disabled || readOnly) {\n return;\n }\n\n setHidePlaceholder(true);\n\n if (\n nodeRef.current &&\n !nodeRef.current.contains(document.activeElement)\n ) {\n dayInputRef.current?.focus();\n }\n };\n\n const handleSectionFocus = (event: React.FocusEvent) => {\n if (disabled) {\n return;\n }\n\n setHidePlaceholder(true);\n\n if (!focused) {\n onFocus?.(event);\n }\n };\n\n const handlePlaceholderClick = (event: React.MouseEvent) => {\n event.preventDefault();\n dayInputRef.current?.focus();\n };\n\n const handleInputFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n event.target.select();\n const targetName = event.target.name as FieldType;\n setCurrentFocus(targetName);\n };\n\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n const [dayName, monthName, yearName] = names;\n const date = {\n [dayName]: dayValueRef.current,\n [monthName]: monthValueRef.current,\n [yearName]: yearValueRef.current,\n };\n\n const targetName = event.target.name as FieldType;\n const targetValue = date[targetName];\n\n // pad single digits for day and month inputs\n\n const paddedValue =\n targetName !== yearName\n ? StringHelper.padValue(targetValue, true)\n : targetValue;\n\n switch (targetName) {\n case dayName:\n date[dayName] = paddedValue;\n setDayValue(paddedValue);\n break;\n case monthName:\n date[monthName] = paddedValue;\n setMonthValue(paddedValue);\n break;\n case yearName:\n default:\n break;\n }\n\n const value = `${date[yearName]}-${date[monthName]}-${date[dayName]}`;\n const isValid = dayjs(value, \"YYYY-MM-DD\", true).isValid();\n const isEmpty = !date[dayName] && !date[monthName] && !date[yearName];\n const isPadded = targetValue !== paddedValue;\n\n if (isValid && isPadded) {\n onChange(value);\n }\n\n if (nodeRef.current && !nodeRef.current.contains(event.relatedTarget)) {\n // entire field was blurred\n setCurrentFocus(\"none\");\n onBlur?.(isEmpty || isValid);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (hoverValue) {\n // do not modify inputs when selecting date from another source\n return;\n }\n\n const targetName = event.target.name as FieldType;\n const targetValue = event.target.value.replace(/[^0-9]/g, \"\");\n\n const date = {\n day: dayValue,\n month: monthValue,\n year: yearValue,\n };\n\n switch (targetName) {\n case names[0]:\n date.day = targetValue;\n setDayValue(targetValue);\n // auto focus the next input once filled in\n if (targetValue.length === 2) {\n monthInputRef.current?.focus();\n }\n break;\n case names[1]:\n date.month = targetValue;\n setMonthValue(targetValue);\n // auto focus the next input once filled in\n if (targetValue.length === 2) {\n yearInputRef.current?.focus();\n }\n break;\n case names[2]:\n date.year = targetValue;\n setYearValue(targetValue);\n break;\n default:\n break;\n }\n\n if (!date.day && !date.month && !date.year) {\n onChange(\"\");\n return;\n }\n\n const value = `${date.year}-${date.month}-${date.day}`;\n const isValid = dayjs(value, \"YYYY-MM-DD\", true).isValid();\n\n if (isValid) {\n onChange(value);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n /**\n * Allow going to the field before if user presses Backspace\n * on an empty field\n */\n if (event.code === \"Backspace\" || event.key === \"Backspace\") {\n if (currentFocus === names[1] && monthValue.length === 0) {\n dayInputRef.current?.focus();\n }\n\n if (currentFocus === names[2] && yearValue.length === 0) {\n monthInputRef.current?.focus();\n }\n }\n };\n\n // =============================================================================\n // HELPERS\n // =============================================================================\n function parseToInputValues(stringVal: string | undefined) {\n if (!stringVal) {\n return [undefined, undefined, undefined];\n } else {\n const sanitized = DateInputHelper.sanitizeInput(stringVal);\n\n if (!sanitized) {\n return [undefined, undefined, undefined];\n }\n\n const day = dayjs(sanitized, \"YYYY-MM-DD\", true);\n\n return [\n StringHelper.padValue(day.date().toString()),\n StringHelper.padValue((day.month() + 1).toString()),\n day.year().toString(),\n ];\n }\n }\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderPlaceholder = () => {\n if (value || readOnly || !placeholder) {\n return;\n }\n\n return (\n <Placeholder\n $hide={hidePlaceholder}\n $disabled={disabled}\n onMouseDown={handlePlaceholderClick}\n >\n {placeholder}\n </Placeholder>\n );\n };\n\n return (\n <InputSection\n role=\"group\"\n aria-label={label}\n onClick={handleSectionClick}\n onFocus={handleSectionFocus}\n >\n <InputContainer ref={nodeRef} $hover={!!hoverValue}>\n <DayInputSizer>\n <DayInput\n ref={dayInputRef}\n name={names[0]}\n maxLength={2}\n value={hoverDayValue ?? dayValue}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n type=\"text\"\n inputMode={inputMode}\n pattern=\"[0-9]{2}\"\n data-testid={`${names[0]}-input`}\n aria-label={inputLabels[0]}\n disabled={disabled}\n readOnly={readOnly}\n tabIndex={readOnly ? -1 : 0}\n autoComplete=\"off\"\n placeholder={\n currentFocus === names[0] && !readOnly ? \"\" : \"DD\"\n }\n />\n </DayInputSizer>\n <Divider $inactive={dayValue.length === 0}>/</Divider>\n <MonthInputSizer>\n <MonthInput\n ref={monthInputRef}\n name={names[1]}\n maxLength={2}\n value={hoverMonthValue ?? monthValue}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n type=\"text\"\n inputMode={inputMode}\n pattern=\"[0-9]{2}\"\n data-testid={`${names[1]}-input`}\n aria-label={inputLabels[1]}\n disabled={disabled}\n readOnly={readOnly}\n tabIndex={readOnly ? -1 : 0}\n autoComplete=\"off\"\n placeholder={\n currentFocus === names[1] && !readOnly ? \"\" : \"MM\"\n }\n />\n </MonthInputSizer>\n <Divider $inactive={monthValue.length === 0}>/</Divider>\n <YearInputSizer>\n <YearInput\n ref={yearInputRef}\n name={names[2]}\n maxLength={4}\n value={hoverYearValue ?? yearValue}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n type=\"text\"\n inputMode={inputMode}\n pattern=\"[0-9]{4}\"\n data-testid={`${names[2]}-input`}\n aria-label={inputLabels[2]}\n disabled={disabled}\n readOnly={readOnly}\n tabIndex={readOnly ? -1 : 0}\n autoComplete=\"off\"\n placeholder={\n currentFocus === names[2] && !readOnly ? \"\" : \"YYYY\"\n }\n />\n </YearInputSizer>\n </InputContainer>\n {renderPlaceholder()}\n </InputSection>\n );\n};\n\nexport const StandaloneDateInput = React.forwardRef(Component);\n"],"names":["dayjs","extend","customParseFormat","Component","disabled","readOnly","names","value","focused","hoverValue","placeholder","label","onChange","onFocus","onBlur","hideInputKeyboard","inputLabels","ref","inputMode","dayValue","setDayValue","dayValueRef","useStateRef","monthValue","setMonthValue","monthValueRef","yearValue","setYearValue","yearValueRef","currentFocus","setCurrentFocus","useState","hidePlaceholder","setHidePlaceholder","nodeRef","useRef","dayInputRef","monthInputRef","yearInputRef","hoverDayValue","hoverMonthValue","hoverYearValue","parseToInputValues","useEffect","day","month","year","current","contains","document","activeElement","_a","focus","useImperativeHandle","resetPlaceholder","resetInput","focusYearRef","handlePlaceholderClick","event","preventDefault","handleInputFocus","target","select","targetName","name","handleInputBlur","dayName","monthName","yearName","date","targetValue","paddedValue","StringHelper","padValue","isValid","isEmpty","relatedTarget","handleInputChange","replace","length","_b","handleKeyDown","code","key","stringVal","sanitized","DateInputHelper","sanitizeInput","undefined","toString","_jsxs","InputSection","role","onClick","children","InputContainer","$hover","_jsx","DayInputSizer","DayInput","maxLength","type","pattern","tabIndex","autoComplete","Divider","$inactive","MonthInputSizer","MonthInput","onKeyDown","YearInputSizer","YearInput","Placeholder","$hide","$disabled","onMouseDown","renderPlaceholder","StandaloneDateInput","React","forwardRef"],"mappings":"kyBAiBAA,EAAMC,OAAOC,GAiCN,MAAMC,EAAY,EAEjBC,WACAC,WACAC,QACAC,QACAC,UACAC,aACAC,cACAC,QACAC,WACAC,UACAC,SACAC,oBACAC,cAAc,CAAC,OAAQ,QAAS,SAEpCC,KAKA,MAAMC,EAAYH,EAAoB,OAAS,WAExCI,EAAUC,EAAaC,GAAeC,EAAoB,KAC1DC,EAAYC,EAAeC,GAAiBH,EAAoB,KAChEI,EAAWC,EAAcC,GAAgBN,EAAoB,KAC7DO,EAAcC,GAAmBC,EAAoB,SACrDC,EAAiBC,GAAsBF,GAAkB,GAE1DG,EAAUC,EAAuB,MACjCC,EAAcD,EAAyB,MACvCE,EAAgBF,EAAyB,MACzCG,EAAeH,EAAyB,OAEvCI,EAAeC,EAAiBC,IACnCC,GAAmBjC,GAKvBkC,GAAU,WACN,MAAOC,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAMJ,GAAmBnC,GAC7Da,EAAYwB,GACZpB,EAAcqB,GACdlB,EAAamB,GAIRF,GACAC,GACAC,IACDZ,EAAQa,UACRb,EAAQa,QAAQC,SA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AACU,EAAe,CAAAb,SACZG,EAACW,EAAU,CACP3F,IAAKoB,EACL2B,KAAM1D,EAAM,GACZ8F,UAAW,EACX7F,MAAOiC,QAAAA,EAAmBjB,EAC1BV,QAAS+C,GACT9C,OAAQmD,GACRrD,SAAUiE,GACVgC,UAAW5B,GACXoB,KAAK,OACLnF,UAAWA,EACXoF,QAAQ,yBACK,GAAGhG,EAAM,WAAU,aACpBU,EAAY,GACxBZ,SAAUA,EACVC,SAAUA,EACVkG,SAAUlG,GAAW,EAAK,EAC1BmG,aAAa,MACb9F,YACImB,IAAiBvB,EAAM,IAAOD,EAAgB,KAAL,OAIrD4F,EAACQ,EAAO,CAAAC,UAAkC,IAAtBnF,EAAWwD,OAAYe,SAAA,MAC3CG,EAACa,EAAc,CAAAhB,SACXG,EAACc,EAAS,CACN9F,IAAKqB,EACL0B,KAAM1D,EAAM,GACZ8F,UAAW,EACX7F,MAAOkC,SAAAA,GAAkBf,EACzBb,QAAS+C,GACT9C,OAAQmD,GACRrD,SAAUiE,GACVgC,UAAW5B,GACXoB,KAAK,OACLnF,UAAWA,EACXoF,QAAQ,WAAU,cACL,GAAGhG,EAAM,WAAU,aACpBU,EAAY,GACxBZ,SAAUA,EACVC,SAAUA,EACVkG,SAAUlG,GAAW,EAAK,EAC1BmG,aAAa,MACb9F,YACImB,IAAiBvB,EAAM,IAAOD,EAAgB,OAAL,UA7FvC,MACtB,IAAIE,IAASF,GAAaK,EAI1B,OACIuF,EAACe,EAAW,CAAAC,MACDjF,EAAekF,UACX9G,EACX+G,YAAa1D,GAAsBqC,SAElCpF,GACS,EAsFb0G,KACU,EAIVC,EAAsBC,EAAMC,WAAWpH"}
|
|
1
|
+
{"version":3,"file":"standalone-date-input.js","sources":["../../../src/shared/standalone-date-input/standalone-date-input.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\nimport React, { useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport { DateInputHelper, StringHelper, useStateRef } from \"../../util\";\nimport {\n DayInput,\n DayInputSizer,\n Divider,\n InputContainer,\n InputSection,\n MonthInput,\n MonthInputSizer,\n Placeholder,\n YearInput,\n YearInputSizer,\n} from \"./standalone-date-input.style\";\n\ndayjs.extend(customParseFormat);\n\ntype StartInputNames = [\"start-day\", \"start-month\", \"start-year\"];\ntype EndInputNames = [\"end-day\", \"end-month\", \"end-year\"];\n\nexport type FieldType =\n | StartInputNames[number]\n | EndInputNames[number]\n | \"none\";\n\ninterface Props {\n disabled?: boolean | undefined;\n readOnly?: boolean | undefined;\n hideInputKeyboard?: boolean | undefined;\n names: StartInputNames | EndInputNames;\n value: string | undefined;\n hoverValue?: string | undefined;\n focused: boolean;\n placeholder?: string | undefined;\n label?: string | undefined;\n inputLabels?: string[] | undefined;\n onChange: (value: string) => void;\n onFocus?: ((event: React.FocusEvent) => void) | undefined;\n onBlur?: ((valid: boolean) => void) | undefined;\n}\n\nexport interface StandaloneDateInputRef {\n ref: React.RefObject<HTMLDivElement>;\n resetPlaceholder: () => void;\n resetInput: () => void;\n focusYearRef: () => void;\n}\n\nexport const Component = (\n {\n disabled,\n readOnly,\n names,\n value,\n focused,\n hoverValue,\n placeholder,\n label,\n onChange,\n onFocus,\n onBlur,\n hideInputKeyboard,\n inputLabels = [\"Date\", \"Month\", \"Year\"],\n }: Props,\n ref: React.ForwardedRef<StandaloneDateInputRef>\n) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const inputMode = hideInputKeyboard ? \"none\" : \"numeric\";\n\n const [dayValue, setDayValue, dayValueRef] = useStateRef<string>(\"\");\n const [monthValue, setMonthValue, monthValueRef] = useStateRef<string>(\"\");\n const [yearValue, setYearValue, yearValueRef] = useStateRef<string>(\"\");\n const [currentFocus, setCurrentFocus] = useState<FieldType>(\"none\");\n const [hidePlaceholder, setHidePlaceholder] = useState<boolean>(false);\n\n const nodeRef = useRef<HTMLDivElement>(null);\n const dayInputRef = useRef<HTMLInputElement>(null);\n const monthInputRef = useRef<HTMLInputElement>(null);\n const yearInputRef = useRef<HTMLInputElement>(null);\n\n const [hoverDayValue, hoverMonthValue, hoverYearValue] =\n parseToInputValues(hoverValue);\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n const [day = \"\", month = \"\", year = \"\"] = parseToInputValues(value);\n setDayValue(day);\n setMonthValue(month);\n setYearValue(year);\n\n // re-focus on day input if all 3 inputs get cleared while typing\n if (\n !day &&\n !month &&\n !year &&\n nodeRef.current &&\n nodeRef.current.contains(document.activeElement)\n )\n dayInputRef.current?.focus();\n }, [value]);\n\n useEffect(() => {\n // clear internal focus state\n if (!focused) {\n setCurrentFocus(\"none\");\n }\n\n // ensure at least one input is focused\n if (focused) {\n setHidePlaceholder(true);\n\n if (\n nodeRef.current &&\n !nodeRef.current.contains(document.activeElement)\n ) {\n dayInputRef.current?.focus();\n }\n }\n }, [focused]);\n\n useImperativeHandle(\n ref,\n () => ({\n ref: nodeRef,\n resetPlaceholder() {\n setHidePlaceholder(false);\n },\n resetInput() {\n const [day = \"\", month = \"\", year = \"\"] =\n parseToInputValues(value);\n setDayValue(day);\n setMonthValue(month);\n setYearValue(year);\n },\n focusYearRef() {\n yearInputRef.current?.focus();\n },\n }),\n [setDayValue, setMonthValue, setYearValue, value]\n );\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleSectionClick = () => {\n if (disabled || readOnly) {\n return;\n }\n\n setHidePlaceholder(true);\n\n if (\n nodeRef.current &&\n !nodeRef.current.contains(document.activeElement)\n ) {\n dayInputRef.current?.focus();\n }\n };\n\n const handleSectionFocus = (event: React.FocusEvent) => {\n if (disabled) {\n return;\n }\n\n setHidePlaceholder(true);\n\n if (!focused) {\n onFocus?.(event);\n }\n };\n\n const handlePlaceholderClick = (event: React.MouseEvent) => {\n event.preventDefault();\n dayInputRef.current?.focus();\n };\n\n const handleInputFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n event.target.select();\n const targetName = event.target.name as FieldType;\n setCurrentFocus(targetName);\n };\n\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n const [dayName, monthName, yearName] = names;\n const date = {\n [dayName]: dayValueRef.current,\n [monthName]: monthValueRef.current,\n [yearName]: yearValueRef.current,\n };\n\n const targetName = event.target.name as FieldType;\n const targetValue = date[targetName];\n\n // pad single digits for day and month inputs\n\n const paddedValue =\n targetName !== yearName\n ? StringHelper.padValue(targetValue, true)\n : targetValue;\n\n switch (targetName) {\n case dayName:\n date[dayName] = paddedValue;\n setDayValue(paddedValue);\n break;\n case monthName:\n date[monthName] = paddedValue;\n setMonthValue(paddedValue);\n break;\n case yearName:\n default:\n break;\n }\n\n const value = `${date[yearName]}-${date[monthName]}-${date[dayName]}`;\n const isValid = dayjs(value, \"YYYY-MM-DD\", true).isValid();\n const isEmpty = !date[dayName] && !date[monthName] && !date[yearName];\n const isPadded = targetValue !== paddedValue;\n\n if (isValid && isPadded) {\n onChange(value);\n }\n\n if (nodeRef.current && !nodeRef.current.contains(event.relatedTarget)) {\n // entire field was blurred\n setCurrentFocus(\"none\");\n onBlur?.(isEmpty || isValid);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (hoverValue) {\n // do not modify inputs when selecting date from another source\n return;\n }\n\n const targetName = event.target.name as FieldType;\n const targetValue = event.target.value.replace(/[^0-9]/g, \"\");\n\n const date = {\n day: dayValue,\n month: monthValue,\n year: yearValue,\n };\n\n switch (targetName) {\n case names[0]:\n date.day = targetValue;\n setDayValue(targetValue);\n // auto focus the next input once filled in\n if (targetValue.length === 2) {\n monthInputRef.current?.focus();\n }\n break;\n case names[1]:\n date.month = targetValue;\n setMonthValue(targetValue);\n // auto focus the next input once filled in\n if (targetValue.length === 2) {\n yearInputRef.current?.focus();\n }\n break;\n case names[2]:\n date.year = targetValue;\n setYearValue(targetValue);\n break;\n default:\n break;\n }\n\n if (!date.day && !date.month && !date.year) {\n onChange(\"\");\n return;\n }\n\n const value = `${date.year}-${date.month}-${date.day}`;\n const isValid = dayjs(value, \"YYYY-MM-DD\", true).isValid();\n\n if (isValid) {\n onChange(value);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n /**\n * Allow going to the field before if user presses Backspace\n * on an empty field\n */\n if (event.code === \"Backspace\" || event.key === \"Backspace\") {\n if (currentFocus === names[1] && monthValue.length === 0) {\n dayInputRef.current?.focus();\n }\n\n if (currentFocus === names[2] && yearValue.length === 0) {\n monthInputRef.current?.focus();\n }\n }\n };\n\n // =============================================================================\n // HELPERS\n // =============================================================================\n function parseToInputValues(stringVal: string | undefined) {\n if (!stringVal) {\n return [undefined, undefined, undefined];\n } else {\n const sanitized = DateInputHelper.sanitizeInput(stringVal);\n\n if (!sanitized) {\n return [undefined, undefined, undefined];\n }\n\n const day = dayjs(sanitized, \"YYYY-MM-DD\", true);\n\n return [\n StringHelper.padValue(day.date().toString()),\n StringHelper.padValue((day.month() + 1).toString()),\n day.year().toString(),\n ];\n }\n }\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderPlaceholder = () => {\n if (value || readOnly || !placeholder) {\n return;\n }\n\n return (\n <Placeholder\n $hide={hidePlaceholder}\n $disabled={disabled}\n onMouseDown={handlePlaceholderClick}\n >\n {placeholder}\n </Placeholder>\n );\n };\n\n return (\n <InputSection\n role=\"group\"\n aria-label={label}\n onClick={handleSectionClick}\n onFocus={handleSectionFocus}\n >\n <InputContainer ref={nodeRef} $hover={!!hoverValue}>\n <DayInputSizer>\n <DayInput\n ref={dayInputRef}\n name={names[0]}\n maxLength={2}\n value={hoverDayValue ?? dayValue}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n type=\"text\"\n inputMode={inputMode}\n pattern=\"[0-9]{2}\"\n data-testid={`${names[0]}-input`}\n aria-label={inputLabels[0]}\n disabled={disabled}\n readOnly={readOnly}\n tabIndex={readOnly ? -1 : 0}\n autoComplete=\"off\"\n placeholder={\n currentFocus === names[0] && !readOnly ? \"\" : \"DD\"\n }\n />\n </DayInputSizer>\n <Divider $inactive={dayValue.length === 0} $disabled={disabled}>\n /\n </Divider>\n <MonthInputSizer>\n <MonthInput\n ref={monthInputRef}\n name={names[1]}\n maxLength={2}\n value={hoverMonthValue ?? monthValue}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n type=\"text\"\n inputMode={inputMode}\n pattern=\"[0-9]{2}\"\n data-testid={`${names[1]}-input`}\n aria-label={inputLabels[1]}\n disabled={disabled}\n readOnly={readOnly}\n tabIndex={readOnly ? -1 : 0}\n autoComplete=\"off\"\n placeholder={\n currentFocus === names[1] && !readOnly ? \"\" : \"MM\"\n }\n />\n </MonthInputSizer>\n <Divider\n $inactive={monthValue.length === 0}\n $disabled={disabled}\n >\n /\n </Divider>\n <YearInputSizer>\n <YearInput\n ref={yearInputRef}\n name={names[2]}\n maxLength={4}\n value={hoverYearValue ?? yearValue}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n type=\"text\"\n inputMode={inputMode}\n pattern=\"[0-9]{4}\"\n data-testid={`${names[2]}-input`}\n aria-label={inputLabels[2]}\n disabled={disabled}\n readOnly={readOnly}\n tabIndex={readOnly ? -1 : 0}\n autoComplete=\"off\"\n placeholder={\n currentFocus === names[2] && !readOnly ? \"\" : \"YYYY\"\n }\n />\n </YearInputSizer>\n </InputContainer>\n {renderPlaceholder()}\n </InputSection>\n );\n};\n\nexport const StandaloneDateInput = React.forwardRef(Component);\n"],"names":["dayjs","extend","customParseFormat","Component","disabled","readOnly","names","value","focused","hoverValue","placeholder","label","onChange","onFocus","onBlur","hideInputKeyboard","inputLabels","ref","inputMode","dayValue","setDayValue","dayValueRef","useStateRef","monthValue","setMonthValue","monthValueRef","yearValue","setYearValue","yearValueRef","currentFocus","setCurrentFocus","useState","hidePlaceholder","setHidePlaceholder","nodeRef","useRef","dayInputRef","monthInputRef","yearInputRef","hoverDayValue","hoverMonthValue","hoverYearValue","parseToInputValues","useEffect","day","month","year","current","contains","document","activeElement","_a","focus","useImperativeHandle","resetPlaceholder","resetInput","focusYearRef","handlePlaceholderClick","event","preventDefault","handleInputFocus","target","select","targetName","name","handleInputBlur","dayName","monthName","yearName","date","targetValue","paddedValue","StringHelper","padValue","isValid","isEmpty","relatedTarget","handleInputChange","replace","length","_b","handleKeyDown","code","key","stringVal","sanitized","DateInputHelper","sanitizeInput","undefined","toString","_jsxs","InputSection","role","onClick","children","InputContainer","$hover","_jsx","DayInputSizer","DayInput","maxLength","type","pattern","tabIndex","autoComplete","Divider","$disabled","MonthInputSizer","MonthInput","onKeyDown","$inactive","YearInputSizer","YearInput","Placeholder","$hide","onMouseDown","renderPlaceholder","StandaloneDateInput","React","forwardRef"],"mappings":"kyBAiBAA,EAAMC,OAAOC,GAiCN,MAAMC,EAAY,EAEjBC,WACAC,WACAC,QACAC,QACAC,UACAC,aACAC,cACAC,QACAC,WACAC,UACAC,SACAC,oBACAC,cAAc,CAAC,OAAQ,QAAS,SAEpCC,KAKA,MAAMC,EAAYH,EAAoB,OAAS,WAExCI,EAAUC,EAAaC,GAAeC,EAAoB,KAC1DC,EAAYC,EAAeC,GAAiBH,EAAoB,KAChEI,EAAWC,EAAcC,GAAgBN,EAAoB,KAC7DO,EAAcC,GAAmBC,EAAoB,SACrDC,EAAiBC,GAAsBF,GAAkB,GAE1DG,EAAUC,EAAuB,MACjCC,EAAcD,EAAyB,MACvCE,EAAgBF,EAAyB,MACzCG,EAAeH,EAAyB,OAEvCI,EAAeC,EAAiBC,IACnCC,GAAmBjC,GAKvBkC,GAAU,WACN,MAAOC,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAMJ,GAAmBnC,GAC7Da,EAAYwB,GACZpB,EAAcqB,GACdlB,EAAamB,GAIRF,GACAC,GACAC,IACDZ,EAAQa,UACRb,EAAQa,QAAQC,SAASC,SAASC,gBAEf,QAA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EAACU,EAAe,CAAAb,SACZG,EAACW,EAAU,CACP3F,IAAKoB,EACL2B,KAAM1D,EAAM,GACZ8F,UAAW,EACX7F,MAAOiC,QAAAA,EAAmBjB,EAC1BV,QAAS+C,GACT9C,OAAQmD,GACRrD,SAAUiE,GACVgC,UAAW5B,GACXoB,KAAK,OACLnF,UAAWA,EACXoF,QAAQ,yBACK,GAAGhG,EAAM,WAAU,aACpBU,EAAY,GACxBZ,SAAUA,EACVC,SAAUA,EACVkG,SAAUlG,GAAW,EAAK,EAC1BmG,aAAa,MACb9F,YACImB,IAAiBvB,EAAM,IAAOD,EAAgB,KAAL,OAIrD4F,EAACQ,EAAO,CAAAK,UAC6B,IAAtBvF,EAAWwD,iBACX3E,EAAQ0F,SAAA,MAIvBG,EAACc,YACGd,EAACe,EAAS,CACN/F,IAAKqB,EACL0B,KAAM1D,EAAM,GACZ8F,UAAW,EACX7F,MAAOkC,SAAAA,GAAkBf,EACzBb,QAAS+C,GACT9C,OAAQmD,GACRrD,SAAUiE,GACVgC,UAAW5B,GACXoB,KAAK,OACLnF,UAAWA,EACXoF,QAAQ,WAAU,cACL,GAAGhG,EAAM,WAAU,aACpBU,EAAY,GACxBZ,SAAUA,EACVC,SAAUA,EACVkG,SAAUlG,GAAW,EAAK,EAC1BmG,aAAa,MACb9F,YACImB,IAAiBvB,EAAM,IAAOD,EAAgB,OAAL,UApGvC,MACtB,IAAIE,IAASF,GAAaK,EAI1B,OACIuF,EAACgB,EAAW,CAAAC,MACDlF,EAAe0E,UACXtG,EACX+G,YAAa1D,GAAsBqC,SAElCpF,GACS,EA6Fb0G,KACU,EAIVC,EAAsBC,EAAMC,WAAWpH"}
|
|
@@ -4,6 +4,7 @@ interface PlaceholderStyleProps {
|
|
|
4
4
|
}
|
|
5
5
|
interface DividerStyleProps {
|
|
6
6
|
$inactive?: boolean;
|
|
7
|
+
$disabled?: boolean | undefined;
|
|
7
8
|
}
|
|
8
9
|
interface InputContainerStyleProps {
|
|
9
10
|
$hover?: boolean;
|
|
@@ -124,6 +125,6 @@ export declare const YearInput: import("styled-components/dist/types").IStyledCo
|
|
|
124
125
|
as?: import("styled-components").WebTarget | undefined;
|
|
125
126
|
forwardedAs?: import("styled-components").WebTarget | undefined;
|
|
126
127
|
}, never>>> & string;
|
|
127
|
-
export declare const Divider: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>,
|
|
128
|
+
export declare const Divider: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof DividerStyleProps> & DividerStyleProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, keyof DividerStyleProps> & DividerStyleProps, never>>> & string;
|
|
128
129
|
export declare const Placeholder: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof PlaceholderStyleProps> & PlaceholderStyleProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof PlaceholderStyleProps> & PlaceholderStyleProps, never>>> & string;
|
|
129
130
|
export {};
|