@danske/sapphire-react-lab 0.77.4 → 0.79.1
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/build/cjs/index.js +20 -7
- package/build/cjs/index.js.map +1 -1
- package/build/esm/DateField/src/DateField.js +4 -1
- package/build/esm/DateField/src/DateField.js.map +1 -1
- package/build/esm/DateField/src/DateRangeField.js +4 -1
- package/build/esm/DateField/src/DateRangeField.js.map +1 -1
- package/build/esm/Fieldset/src/Fieldset.js +8 -4
- package/build/esm/Fieldset/src/Fieldset.js.map +1 -1
- package/build/esm/Toast/src/ToastRegion.js +5 -2
- package/build/esm/Toast/src/ToastRegion.js.map +1 -1
- package/build/index.d.ts +26 -1
- package/package.json +6 -5
|
@@ -53,6 +53,7 @@ function _DateField(_a, ref) {
|
|
|
53
53
|
noClearButton = false,
|
|
54
54
|
showWeekNumbers,
|
|
55
55
|
size = "large",
|
|
56
|
+
labelPlacement = "above",
|
|
56
57
|
necessityIndicator = false
|
|
57
58
|
} = _b, otherProps = __objRest(_b, [
|
|
58
59
|
"error",
|
|
@@ -61,6 +62,7 @@ function _DateField(_a, ref) {
|
|
|
61
62
|
"noClearButton",
|
|
62
63
|
"showWeekNumbers",
|
|
63
64
|
"size",
|
|
65
|
+
"labelPlacement",
|
|
64
66
|
"necessityIndicator"
|
|
65
67
|
]);
|
|
66
68
|
useThemeCheck();
|
|
@@ -87,7 +89,8 @@ function _DateField(_a, ref) {
|
|
|
87
89
|
isDisabled: otherProps.isDisabled,
|
|
88
90
|
error: state.validationState === "invalid",
|
|
89
91
|
size,
|
|
90
|
-
ref
|
|
92
|
+
ref,
|
|
93
|
+
labelPlacement
|
|
91
94
|
}), otherProps.label && /* @__PURE__ */ React.createElement(Field.Label, null, /* @__PURE__ */ React.createElement(Label, __spreadProps(__spreadValues({}, labelProps), {
|
|
92
95
|
size,
|
|
93
96
|
necessityIndicator: otherProps.isRequired && necessityIndicator ? "required" : !otherProps.isRequired && necessityIndicator ? "optional" : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.js","sources":["../../../../src/DateField/src/DateField.tsx"],"sourcesContent":["import React, {\n ForwardedRef,\n forwardRef,\n ReactNode,\n RefObject,\n useRef,\n} from 'react';\nimport { Validation } from '@react-types/shared';\nimport {\n AriaDatePickerProps,\n DateValue,\n useDatePicker,\n} from '@react-aria/datepicker';\nimport { useDatePickerState } from '@react-stately/datepicker';\nimport {\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n Icon,\n Popover,\n tokens,\n View,\n Field,\n Label,\n} from '@danske/sapphire-react';\nimport clsx from 'clsx';\nimport styles from '@danske/sapphire-css/components/dateField/dateField.module.css';\nimport { Calendar as CalendarIcon } from '@danske/sapphire-icons/react';\nimport { DateInput } from './DateInput';\nimport { Calendar } from '../../Calendar';\nimport { DateFieldButton } from './DateFieldButton';\nimport { PressResponder } from '@react-aria/interactions';\nimport { useDialog } from '@react-aria/dialog';\n\nexport type DateFieldProps<T extends DateValue> = Omit<\n AriaDatePickerProps<T>,\n | keyof Omit<Validation<unknown>, 'isRequired'>\n | 'errorMessage'\n | 'description'\n // excluding some props about time input. We don't support that yet.\n | 'granularity'\n | 'hourCycle'\n | 'hideTimeZone'\n> &\n SapphireStyleProps & {\n /**\n * Whether week numbers are visible as a first column\n */\n showWeekNumbers?: boolean;\n /**\n * Whether the input should render as having an error and an error message.\n * This also sets the appropriate `aria` attributes on the input.\n *\n * A `boolean` sets the error state.\n * A `string` sets the error state with an additional error message.\n \n * **An error message is strongly recommended because an error should\n * always have an explanation about how to fix it.**\n */\n error?: boolean | string;\n /**\n * A note to show below the input.\n * If the input has an error message, this note will be replaced by that.\n */\n note?: ReactNode;\n /**\n * A ContextualHelp to render next to the label.\n */\n contextualHelp?: ReactNode;\n /**\n * If it should hide the \"clear\" button when input is not empty.\n *\n * @default false\n */\n noClearButton?: boolean;\n /**\n * @default 'large'\n */\n size?: 'large' | 'medium';\n /**\n * To visually indicate if this field is required or optional.\n * @default false\n */\n necessityIndicator?: boolean;\n };\n\nfunction _DateField<T extends DateValue>(\n {\n error,\n note,\n contextualHelp,\n noClearButton = false,\n showWeekNumbers,\n size = 'large',\n necessityIndicator = false,\n ...otherProps\n }: DateFieldProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n useThemeCheck();\n\n const groupRef = useRef(null);\n const dialogRef = useRef(null);\n\n const { styleProps } = useSapphireStyleProps(otherProps);\n\n const { dialogProps } = useDialog({}, dialogRef);\n\n const state = useDatePickerState({\n ...otherProps,\n ...(error ? { validationState: 'invalid' } : {}),\n });\n\n const {\n groupProps,\n labelProps,\n fieldProps,\n buttonProps,\n dialogProps: dialogPropsFromDatePicker,\n calendarProps,\n descriptionProps,\n errorMessageProps,\n } = useDatePicker(\n {\n ...otherProps,\n description: note,\n },\n state,\n groupRef\n );\n\n const isMedium = size === 'medium';\n\n return (\n <Field\n {...otherProps}\n noShrink\n isDisabled={otherProps.isDisabled}\n error={state.validationState === 'invalid'}\n size={size}\n ref={ref}\n >\n {otherProps.label && (\n <Field.Label>\n <Label\n {...labelProps}\n size={size}\n necessityIndicator={\n otherProps.isRequired && necessityIndicator\n ? 'required'\n : !otherProps.isRequired && necessityIndicator\n ? 'optional'\n : undefined\n }\n contextualHelp={contextualHelp}\n >\n {otherProps.label}\n </Label>\n </Field.Label>\n )}\n <Field.Control>\n <div\n {...groupProps}\n ref={groupRef}\n className={clsx(styles['sapphire-date-field'], {\n [styles['sapphire-date-field--error']]:\n state.validationState === 'invalid',\n [styles['sapphire-date-field--medium']]: isMedium,\n })}\n {...(styleProps.style.width\n ? { style: { width: styleProps.style.width } }\n : {})}\n >\n <PressResponder {...buttonProps} isPressed={state.isOpen}>\n <DateFieldButton\n isDisabled={otherProps.isDisabled || otherProps.isReadOnly}\n >\n <Icon size={isMedium ? 'm' : 'l'}>\n <CalendarIcon />\n </Icon>\n </DateFieldButton>\n </PressResponder>\n <DateInput\n {...fieldProps}\n noClearButton={noClearButton}\n size={size}\n />\n </div>\n </Field.Control>\n {((typeof error === 'string' && error !== '') || note) && (\n <Field.Footer>\n {error ? (\n <Field.Note {...errorMessageProps}>{error}</Field.Note>\n ) : note ? (\n <Field.Note {...descriptionProps}>{note}</Field.Note>\n ) : (\n <></>\n )}\n </Field.Footer>\n )}\n {state.isOpen && (\n <Popover state={state} triggerRef={groupRef} placement=\"bottom start\">\n <div ref={dialogRef} {...dialogProps} {...dialogPropsFromDatePicker}>\n <View padding={tokens.size.spacing50}>\n <Calendar\n {...calendarProps}\n defaultFocusedValue={state.dateValue}\n showWeekNumbers={showWeekNumbers}\n />\n </View>\n </div>\n </Popover>\n )}\n </Field>\n );\n}\n\n/**\n * A date field allows users to enter or edit date values using the keyboard\n * and/or mouse.\n */\nexport const DateField = forwardRef(_DateField) as <T extends DateValue>(\n props: DateFieldProps<T> & { ref?: RefObject<HTMLDivElement> }\n) => React.ReactElement;\n"],"names":["CalendarIcon","Calendar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,SAAA,UAAA,CACE,IAUA,GACA,EAAA;AAXA,EACE,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAgB,GAAA,KAAA;AAAA,IAChB,eAAA;AAAA,IACA,IAAO,GAAA,OAAA;AAAA,IACP,kBAAqB,GAAA,KAAA;AAAA,GAPvB,GAAA,EAAA,EAQK,uBARL,EAQK,EAAA;AAAA,IAPH,OAAA;AAAA,IACA,MAAA;AAAA,IACA,gBAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAA;AAAA,IACA,MAAA;AAAA,IACA,oBAAA;AAAA,GAAA,CAAA,CAAA;AAKF,EAAA,aAAA,EAAA,CAAA;AAEA,EAAA,MAAM,WAAW,MAAO,CAAA,IAAA,CAAA,CAAA;AACxB,EAAA,MAAM,YAAY,MAAO,CAAA,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A,CAAA,KAAA,CAAM,MAAP,EAAA,IAAA,EACG,KACC,mBAAA,KAAA,CAAA,aAAA,CAAC,KAAM,CAAA,IAAA,EAAP,cAAgB,CAAA,EAAA,EAAA,iBAAA,CAAA,EAAoB,KAClC,CAAA,GAAA,IAAA,mBACD,KAAA,CAAA,aAAA,CAAA,KAAA,CAAM,IAAP,EAAA,cAAA,CAAA,EAAA,EAAgB,gBAAmB,CAAA,EAAA,IAAA,CAAA,mBAMxC,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAM,MACL,oBAAA,KAAA,CAAA,aAAA,CAAC,OAAD,EAAA;AAAA,IAAS,KAAA;AAAA,IAAc,UAAY,EAAA,QAAA;AAAA,IAAU,SAAU,EAAA,cAAA;AAAA,GAAA,sCACpD,KAAD,EAAA,cAAA,CAAA,cAAA,CAAA;AAAA,IAAK,GAAK,EAAA,SAAA;AAAA,GAAe,EAAA,WAAA,CAAA,EAAiB,yBACxC,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAD,EAAA;AAAA,IAAM,OAAA,EAAS,OAAO,IAAK,CAAA,SAAA;AAAA,GACzB,kBAAA,KAAA,CAAA,aAAA,CAACC,UAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,aADN,CAAA,EAAA;AAAA,IAEE,qBAAqB,KAAM,CAAA,SAAA;AAAA,IAC3B,eAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;AAcT,MAAM,YAAY,UAAW,CAAA,UAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"DateField.js","sources":["../../../../src/DateField/src/DateField.tsx"],"sourcesContent":["import React, {\n ForwardedRef,\n forwardRef,\n ReactNode,\n RefObject,\n useRef,\n} from 'react';\nimport { Validation } from '@react-types/shared';\nimport {\n AriaDatePickerProps,\n DateValue,\n useDatePicker,\n} from '@react-aria/datepicker';\nimport { useDatePickerState } from '@react-stately/datepicker';\nimport {\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n Icon,\n Popover,\n tokens,\n View,\n Field,\n Label,\n} from '@danske/sapphire-react';\nimport clsx from 'clsx';\nimport styles from '@danske/sapphire-css/components/dateField/dateField.module.css';\nimport { Calendar as CalendarIcon } from '@danske/sapphire-icons/react';\nimport { DateInput } from './DateInput';\nimport { Calendar } from '../../Calendar';\nimport { DateFieldButton } from './DateFieldButton';\nimport { PressResponder } from '@react-aria/interactions';\nimport { useDialog } from '@react-aria/dialog';\n\nexport type DateFieldProps<T extends DateValue> = Omit<\n AriaDatePickerProps<T>,\n | keyof Omit<Validation<unknown>, 'isRequired'>\n | 'errorMessage'\n | 'description'\n // excluding some props about time input. We don't support that yet.\n | 'granularity'\n | 'hourCycle'\n | 'hideTimeZone'\n> &\n SapphireStyleProps & {\n /**\n * Whether week numbers are visible as a first column\n */\n showWeekNumbers?: boolean;\n /**\n * Whether the input should render as having an error and an error message.\n * This also sets the appropriate `aria` attributes on the input.\n *\n * A `boolean` sets the error state.\n * A `string` sets the error state with an additional error message.\n \n * **An error message is strongly recommended because an error should\n * always have an explanation about how to fix it.**\n */\n error?: boolean | string;\n /**\n * A note to show below the input.\n * If the input has an error message, this note will be replaced by that.\n */\n note?: ReactNode;\n /**\n * A ContextualHelp to render next to the label.\n */\n contextualHelp?: ReactNode;\n /**\n * If it should hide the \"clear\" button when input is not empty.\n *\n * @default false\n */\n noClearButton?: boolean;\n /**\n * @default 'large'\n */\n size?: 'large' | 'medium';\n /**\n * To visually indicate if this field is required or optional.\n * @default false\n */\n necessityIndicator?: boolean;\n /**\n * Places the label either above (default) or on the side of the control.\n * @default 'above'\n */\n labelPlacement?: 'side' | 'above';\n };\n\nfunction _DateField<T extends DateValue>(\n {\n error,\n note,\n contextualHelp,\n noClearButton = false,\n showWeekNumbers,\n size = 'large',\n labelPlacement = 'above',\n necessityIndicator = false,\n ...otherProps\n }: DateFieldProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n useThemeCheck();\n\n const groupRef = useRef(null);\n const dialogRef = useRef(null);\n\n const { styleProps } = useSapphireStyleProps(otherProps);\n\n const { dialogProps } = useDialog({}, dialogRef);\n\n const state = useDatePickerState({\n ...otherProps,\n ...(error ? { validationState: 'invalid' } : {}),\n });\n\n const {\n groupProps,\n labelProps,\n fieldProps,\n buttonProps,\n dialogProps: dialogPropsFromDatePicker,\n calendarProps,\n descriptionProps,\n errorMessageProps,\n } = useDatePicker(\n {\n ...otherProps,\n description: note,\n },\n state,\n groupRef\n );\n\n const isMedium = size === 'medium';\n\n return (\n <Field\n {...otherProps}\n noShrink\n isDisabled={otherProps.isDisabled}\n error={state.validationState === 'invalid'}\n size={size}\n ref={ref}\n labelPlacement={labelPlacement}\n >\n {otherProps.label && (\n <Field.Label>\n <Label\n {...labelProps}\n size={size}\n necessityIndicator={\n otherProps.isRequired && necessityIndicator\n ? 'required'\n : !otherProps.isRequired && necessityIndicator\n ? 'optional'\n : undefined\n }\n contextualHelp={contextualHelp}\n >\n {otherProps.label}\n </Label>\n </Field.Label>\n )}\n <Field.Control>\n <div\n {...groupProps}\n ref={groupRef}\n className={clsx(styles['sapphire-date-field'], {\n [styles['sapphire-date-field--error']]:\n state.validationState === 'invalid',\n [styles['sapphire-date-field--medium']]: isMedium,\n })}\n {...(styleProps.style.width\n ? { style: { width: styleProps.style.width } }\n : {})}\n >\n <PressResponder {...buttonProps} isPressed={state.isOpen}>\n <DateFieldButton\n isDisabled={otherProps.isDisabled || otherProps.isReadOnly}\n >\n <Icon size={isMedium ? 'm' : 'l'}>\n <CalendarIcon />\n </Icon>\n </DateFieldButton>\n </PressResponder>\n <DateInput\n {...fieldProps}\n noClearButton={noClearButton}\n size={size}\n />\n </div>\n </Field.Control>\n {((typeof error === 'string' && error !== '') || note) && (\n <Field.Footer>\n {error ? (\n <Field.Note {...errorMessageProps}>{error}</Field.Note>\n ) : note ? (\n <Field.Note {...descriptionProps}>{note}</Field.Note>\n ) : (\n <></>\n )}\n </Field.Footer>\n )}\n {state.isOpen && (\n <Popover state={state} triggerRef={groupRef} placement=\"bottom start\">\n <div ref={dialogRef} {...dialogProps} {...dialogPropsFromDatePicker}>\n <View padding={tokens.size.spacing50}>\n <Calendar\n {...calendarProps}\n defaultFocusedValue={state.dateValue}\n showWeekNumbers={showWeekNumbers}\n />\n </View>\n </div>\n </Popover>\n )}\n </Field>\n );\n}\n\n/**\n * A date field allows users to enter or edit date values using the keyboard\n * and/or mouse.\n */\nexport const DateField = forwardRef(_DateField) as <T extends DateValue>(\n props: DateFieldProps<T> & { ref?: RefObject<HTMLDivElement> }\n) => React.ReactElement;\n"],"names":["CalendarIcon","Calendar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAA,UAAA,CACE,IAWA,GACA,EAAA;AAZA,EACE,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAgB,GAAA,KAAA;AAAA,IAChB,eAAA;AAAA,IACA,IAAO,GAAA,OAAA;AAAA,IACP,cAAiB,GAAA,OAAA;AAAA,IACjB,kBAAqB,GAAA,KAAA;AAAA,GARvB,GAAA,EAAA,EASK,uBATL,EASK,EAAA;AAAA,IARH,OAAA;AAAA,IACA,MAAA;AAAA,IACA,gBAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAA;AAAA,IACA,MAAA;AAAA,IACA,gBAAA;AAAA,IACA,oBAAA;AAAA,GAAA,CAAA,CAAA;AAKF,EAAA,aAAA,EAAA,CAAA;AAEA,EAAA,MAAM,WAAW,MAAO,CAAA,IAAA,CAAA,CAAA;AACxB,EAAA,MAAM,YAAY,MAAO,CAAA,IAAA,CAAA,CAAA;AAEzB,EAAM,MAAA,EAAE,eAAe,qBAAsB,CAAA,UAAA,CAAA,CAAA;AAE7C,EAAM,MAAA,EAAE,WAAgB,EAAA,GAA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gB,CAAA,EAAA,EAAA,iBAAA,CAAA,EAAoB,KAClC,CAAA,GAAA,IAAA,mBACD,KAAA,CAAA,aAAA,CAAA,KAAA,CAAM,IAAP,EAAA,cAAA,CAAA,EAAA,EAAgB,gBAAmB,CAAA,EAAA,IAAA,CAAA,mBAMxC,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,CAAA,CAAA,EAAA,KAAA,CAAM,MACL,oBAAA,KAAA,CAAA,aAAA,CAAC,OAAD,EAAA;AAAA,IAAS,KAAA;AAAA,IAAc,UAAY,EAAA,QAAA;AAAA,IAAU,SAAU,EAAA,cAAA;AAAA,GAAA,sCACpD,KAAD,EAAA,cAAA,CAAA,cAAA,CAAA;AAAA,IAAK,GAAK,EAAA,SAAA;AAAA,GAAe,EAAA,WAAA,CAAA,EAAiB,yBACxC,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAD,EAAA;AAAA,IAAM,OAAA,EAAS,OAAO,IAAK,CAAA,SAAA;AAAA,GACzB,kBAAA,KAAA,CAAA,aAAA,CAACC,UAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,aADN,CAAA,EAAA;AAAA,IAEE,qBAAqB,KAAM,CAAA,SAAA;AAAA,IAC3B,eAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;AAcT,MAAM,YAAY,UAAW,CAAA,UAAA;;;;"}
|
|
@@ -63,6 +63,7 @@ function _DateRangeField(_a, ref) {
|
|
|
63
63
|
allowUnavailableDatesWithinRange,
|
|
64
64
|
predefinedRanges,
|
|
65
65
|
size = "large",
|
|
66
|
+
labelPlacement = "above",
|
|
66
67
|
necessityIndicator = false
|
|
67
68
|
} = _b, otherProps = __objRest(_b, [
|
|
68
69
|
"error",
|
|
@@ -75,6 +76,7 @@ function _DateRangeField(_a, ref) {
|
|
|
75
76
|
"allowUnavailableDatesWithinRange",
|
|
76
77
|
"predefinedRanges",
|
|
77
78
|
"size",
|
|
79
|
+
"labelPlacement",
|
|
78
80
|
"necessityIndicator"
|
|
79
81
|
]);
|
|
80
82
|
useThemeCheck();
|
|
@@ -105,7 +107,8 @@ function _DateRangeField(_a, ref) {
|
|
|
105
107
|
isDisabled: otherProps.isDisabled,
|
|
106
108
|
error: state.validationState === "invalid",
|
|
107
109
|
size,
|
|
108
|
-
ref
|
|
110
|
+
ref,
|
|
111
|
+
labelPlacement
|
|
109
112
|
}), /* @__PURE__ */ React.createElement(I18nProvider, {
|
|
110
113
|
locale: preferredLocale
|
|
111
114
|
}, otherProps.label && /* @__PURE__ */ React.createElement(Field.Label, null, /* @__PURE__ */ React.createElement(Label, __spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeField.js","sources":["../../../../src/DateField/src/DateRangeField.tsx"],"sourcesContent":["import React, {\n ForwardedRef,\n forwardRef,\n ReactNode,\n RefObject,\n useRef,\n} from 'react';\nimport { Validation } from '@react-types/shared';\nimport {\n AriaDateRangePickerProps,\n DateValue,\n useDateRangePicker,\n} from '@react-aria/datepicker';\nimport {\n DateRangePickerStateOptions,\n useDateRangePickerState,\n} from './useDateRangePickerState';\nimport {\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n Icon,\n Popover,\n tokens,\n View,\n Field,\n Label,\n} from '@danske/sapphire-react';\nimport clsx from 'clsx';\nimport styles from '@danske/sapphire-css/components/dateField/dateField.module.css';\nimport { Calendar } from '@danske/sapphire-icons/react';\nimport { DateRangeInput } from './DateRangeInput';\nimport { RangeCalendar, PredefinedDateRange } from '../../Calendar';\nimport { DateFieldButton } from './DateFieldButton';\nimport { PressResponder } from '@react-aria/interactions';\nimport { I18nProvider, useLocale } from '@react-aria/i18n';\nimport { useDialog } from '@react-aria/dialog';\n\nexport type DateRangeFieldProps<T extends DateValue, P extends string> = Omit<\n AriaDateRangePickerProps<T>,\n | keyof Omit<Validation<unknown>, 'isRequired'>\n | 'errorMessage'\n | 'description'\n // excluding some props about time input. We don't support that yet.\n | 'granularity'\n | 'hourCycle'\n | 'hideTimeZone'\n | 'allowsNonContiguousRanges'\n | 'onChange'\n> &\n SapphireStyleProps & {\n /**\n * Handler that is called when the value changes.\n */\n onChange?: DateRangePickerStateOptions<DateValue, P>['onChange'];\n /**\n * Whether week numbers are visible as a first column\n */\n showWeekNumbers?: boolean;\n /**\n * Whether to show two months at the same time.\n */\n showTwoMonths?: boolean;\n /**\n * A set of predefined date ranges the user can more conveniently select.\n */\n predefinedRanges?: Record<P, PredefinedDateRange>;\n /**\n * Whether range is allowed to span unavailable dates.\n */\n allowUnavailableDatesWithinRange?: boolean;\n /**\n * Whether the input should render as having an error and an error message.\n * This also sets the appropriate `aria` attributes on the input.\n *\n * A `boolean` sets the error state.\n * A `string` sets the error state with an additional error message.\n \n * **An error message is strongly recommended because an error should\n * always have an explanation about how to fix it.**\n */\n error?: boolean | string;\n /**\n * A note to show below the input.\n * If the input has an error message, this note will be replaced by that.\n */\n note?: ReactNode;\n /**\n * A ContextualHelp to render next to the label.\n */\n contextualHelp?: ReactNode;\n /**\n * If it should hide the \"clear\" button when input is not empty.\n *\n * @default false\n */\n noClearButton?: boolean;\n /**\n * Locale (eg. \"da-DK\", \"en-US\", \"sv-SE\" etc.)\n *\n * THIS IS A TEMPORARY SOLUTION FOR THE INTERFACE OF LOCALIZATION. THIS API\n * MAY CHANGE OR EVEN BE REPLACED WITH SOMETHING DIFFERENT IN A FUTURE VERSION.\n */\n locale?: string;\n /**\n * @default 'large'\n */\n size?: 'large' | 'medium';\n /**\n * To visually indicate if this field is required or optional.\n * @default false\n */\n necessityIndicator?: boolean;\n };\n\nfunction _DateRangeField<T extends DateValue, P extends string>(\n {\n error,\n note,\n contextualHelp,\n noClearButton = false,\n locale,\n showWeekNumbers,\n showTwoMonths,\n allowUnavailableDatesWithinRange,\n predefinedRanges,\n size = 'large',\n necessityIndicator = false,\n ...otherProps\n }: DateRangeFieldProps<T, P>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n useThemeCheck();\n\n const groupRef = useRef(null);\n const dialogRef = useRef(null);\n\n const { locale: existingLocale } = useLocale();\n\n const preferredLocale = locale || existingLocale;\n\n const { styleProps } = useSapphireStyleProps(otherProps);\n\n const { dialogProps } = useDialog({}, dialogRef);\n\n const state = useDateRangePickerState({\n ...otherProps,\n ...(error ? { validationState: 'invalid' } : {}),\n ...(allowUnavailableDatesWithinRange\n ? { allowsNonContiguousRanges: allowUnavailableDatesWithinRange }\n : {}),\n });\n\n const {\n groupProps,\n labelProps,\n startFieldProps,\n endFieldProps,\n buttonProps,\n dialogProps: dialogPropsFromDatePicker,\n calendarProps,\n descriptionProps,\n errorMessageProps,\n } = useDateRangePicker(\n {\n ...otherProps,\n description: note,\n allowsNonContiguousRanges: allowUnavailableDatesWithinRange,\n },\n state,\n groupRef\n );\n\n const isMedium = size === 'medium';\n\n return (\n <Field\n {...otherProps}\n noShrink\n isDisabled={otherProps.isDisabled}\n error={state.validationState === 'invalid'}\n size={size}\n ref={ref}\n >\n <I18nProvider locale={preferredLocale}>\n {otherProps.label && (\n <Field.Label>\n <Label\n {...labelProps}\n size={size}\n necessityIndicator={\n otherProps.isRequired && necessityIndicator\n ? 'required'\n : !otherProps.isRequired && necessityIndicator\n ? 'optional'\n : undefined\n }\n contextualHelp={contextualHelp}\n >\n {otherProps.label}\n </Label>\n </Field.Label>\n )}\n <Field.Control>\n <div\n {...groupProps}\n ref={groupRef}\n className={clsx(\n styles['sapphire-date-field'],\n styles['sapphire-date-field--range'],\n {\n [styles['sapphire-date-field--error']]:\n state.validationState === 'invalid',\n [styles['sapphire-date-field--medium']]: isMedium,\n }\n )}\n {...(styleProps.style.width\n ? { style: { width: styleProps.style.width } }\n : {})}\n >\n <PressResponder {...buttonProps} isPressed={state.isOpen}>\n <DateFieldButton\n isDisabled={otherProps.isDisabled || otherProps.isReadOnly}\n >\n <Icon size={isMedium ? 'm' : 'l'}>\n <Calendar />\n </Icon>\n </DateFieldButton>\n </PressResponder>\n <DateRangeInput\n dateRangePickerState={state}\n startFieldProps={startFieldProps}\n endFieldProps={endFieldProps}\n noClearButton={noClearButton}\n size={size}\n />\n </div>\n </Field.Control>\n {error !== false &&\n ((typeof error === 'string' && error !== '') || note) && (\n <Field.Footer>\n {error ? (\n <Field.Note {...errorMessageProps}>{error}</Field.Note>\n ) : note ? (\n <Field.Note {...descriptionProps}>{note}</Field.Note>\n ) : (\n <></>\n )}\n </Field.Footer>\n )}\n {state.isOpen && (\n <Popover state={state} triggerRef={groupRef} placement=\"bottom start\">\n <div\n ref={dialogRef}\n {...dialogProps}\n {...dialogPropsFromDatePicker}\n >\n <View padding={tokens.size.spacing50}>\n <RangeCalendar\n {...calendarProps}\n allowUnavailableDatesWithinRange={\n allowUnavailableDatesWithinRange\n }\n showWeekNumbers={showWeekNumbers}\n showTwoMonths={showTwoMonths}\n predefinedRanges={predefinedRanges}\n />\n </View>\n </div>\n </Popover>\n )}\n </I18nProvider>\n </Field>\n );\n}\n\n/**\n * A date range field allows users to select a range of dates by selecting a to and a from date with keyboard and/or mouse.\n */\nexport const DateRangeField = forwardRef(_DateRangeField) as <\n T extends DateValue,\n P extends string\n>(\n props: DateRangeFieldProps<T, P> & { ref?: RefObject<HTMLDivElement> }\n) => React.ReactElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHA,SAAA,eAAA,CACE,IAcA,GACA,EAAA;AAfA,EACE,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAgB,GAAA,KAAA;AAAA,IAChB,MAAA;AAAA,IACA,eAAA;AAAA,IACA,aAAA;AAAA,IACA,gCAAA;AAAA,IACA,gBAAA;AAAA,IACA,IAAO,GAAA,OAAA;AAAA,IACP,kBAAqB,GAAA,KAAA;AAAA,GAXvB,GAAA,EAAA,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,EAAA,QAAA;AAAA,IAAU,SAAU,EAAA,cAAA;AAAA,GAAA,sCACpD,KAAD,EAAA,cAAA,CAAA,cAAA,CAAA;AAAA,IACE,GAAK,EAAA,SAAA;AAAA,GACD,EAAA,WAAA,CAAA,EACA,yBAEJ,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAD,EAAA;AAAA,IAAM,OAAA,EAAS,OAAO,IAAK,CAAA,SAAA;AAAA,GACzB,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,aADN,CAAA,EAAA;AAAA,IAEE,gCAAA;AAAA,IAGA,eAAA;AAAA,IACA,aAAA;AAAA,IACA,gBAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;AAcX,MAAM,iBAAiB,UAAW,CAAA,eAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"DateRangeField.js","sources":["../../../../src/DateField/src/DateRangeField.tsx"],"sourcesContent":["import React, {\n ForwardedRef,\n forwardRef,\n ReactNode,\n RefObject,\n useRef,\n} from 'react';\nimport { Validation } from '@react-types/shared';\nimport {\n AriaDateRangePickerProps,\n DateValue,\n useDateRangePicker,\n} from '@react-aria/datepicker';\nimport {\n DateRangePickerStateOptions,\n useDateRangePickerState,\n} from './useDateRangePickerState';\nimport {\n SapphireStyleProps,\n useSapphireStyleProps,\n useThemeCheck,\n Icon,\n Popover,\n tokens,\n View,\n Field,\n Label,\n} from '@danske/sapphire-react';\nimport clsx from 'clsx';\nimport styles from '@danske/sapphire-css/components/dateField/dateField.module.css';\nimport { Calendar } from '@danske/sapphire-icons/react';\nimport { DateRangeInput } from './DateRangeInput';\nimport { RangeCalendar, PredefinedDateRange } from '../../Calendar';\nimport { DateFieldButton } from './DateFieldButton';\nimport { PressResponder } from '@react-aria/interactions';\nimport { I18nProvider, useLocale } from '@react-aria/i18n';\nimport { useDialog } from '@react-aria/dialog';\n\nexport type DateRangeFieldProps<T extends DateValue, P extends string> = Omit<\n AriaDateRangePickerProps<T>,\n | keyof Omit<Validation<unknown>, 'isRequired'>\n | 'errorMessage'\n | 'description'\n // excluding some props about time input. We don't support that yet.\n | 'granularity'\n | 'hourCycle'\n | 'hideTimeZone'\n | 'allowsNonContiguousRanges'\n | 'onChange'\n> &\n SapphireStyleProps & {\n /**\n * Handler that is called when the value changes.\n */\n onChange?: DateRangePickerStateOptions<DateValue, P>['onChange'];\n /**\n * Whether week numbers are visible as a first column\n */\n showWeekNumbers?: boolean;\n /**\n * Whether to show two months at the same time.\n */\n showTwoMonths?: boolean;\n /**\n * A set of predefined date ranges the user can more conveniently select.\n */\n predefinedRanges?: Record<P, PredefinedDateRange>;\n /**\n * Whether range is allowed to span unavailable dates.\n */\n allowUnavailableDatesWithinRange?: boolean;\n /**\n * Whether the input should render as having an error and an error message.\n * This also sets the appropriate `aria` attributes on the input.\n *\n * A `boolean` sets the error state.\n * A `string` sets the error state with an additional error message.\n \n * **An error message is strongly recommended because an error should\n * always have an explanation about how to fix it.**\n */\n error?: boolean | string;\n /**\n * A note to show below the input.\n * If the input has an error message, this note will be replaced by that.\n */\n note?: ReactNode;\n /**\n * A ContextualHelp to render next to the label.\n */\n contextualHelp?: ReactNode;\n /**\n * If it should hide the \"clear\" button when input is not empty.\n *\n * @default false\n */\n noClearButton?: boolean;\n /**\n * Locale (eg. \"da-DK\", \"en-US\", \"sv-SE\" etc.)\n *\n * THIS IS A TEMPORARY SOLUTION FOR THE INTERFACE OF LOCALIZATION. THIS API\n * MAY CHANGE OR EVEN BE REPLACED WITH SOMETHING DIFFERENT IN A FUTURE VERSION.\n */\n locale?: string;\n /**\n * @default 'large'\n */\n size?: 'large' | 'medium';\n /**\n * To visually indicate if this field is required or optional.\n * @default false\n */\n necessityIndicator?: boolean;\n\n /**\n * Places the label either above (default) or on the side of the control.\n * @default 'above'\n */\n labelPlacement?: 'side' | 'above';\n };\n\nfunction _DateRangeField<T extends DateValue, P extends string>(\n {\n error,\n note,\n contextualHelp,\n noClearButton = false,\n locale,\n showWeekNumbers,\n showTwoMonths,\n allowUnavailableDatesWithinRange,\n predefinedRanges,\n size = 'large',\n labelPlacement = 'above',\n necessityIndicator = false,\n ...otherProps\n }: DateRangeFieldProps<T, P>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n useThemeCheck();\n\n const groupRef = useRef(null);\n const dialogRef = useRef(null);\n\n const { locale: existingLocale } = useLocale();\n\n const preferredLocale = locale || existingLocale;\n\n const { styleProps } = useSapphireStyleProps(otherProps);\n\n const { dialogProps } = useDialog({}, dialogRef);\n\n const state = useDateRangePickerState({\n ...otherProps,\n ...(error ? { validationState: 'invalid' } : {}),\n ...(allowUnavailableDatesWithinRange\n ? { allowsNonContiguousRanges: allowUnavailableDatesWithinRange }\n : {}),\n });\n\n const {\n groupProps,\n labelProps,\n startFieldProps,\n endFieldProps,\n buttonProps,\n dialogProps: dialogPropsFromDatePicker,\n calendarProps,\n descriptionProps,\n errorMessageProps,\n } = useDateRangePicker(\n {\n ...otherProps,\n description: note,\n allowsNonContiguousRanges: allowUnavailableDatesWithinRange,\n },\n state,\n groupRef\n );\n\n const isMedium = size === 'medium';\n\n return (\n <Field\n {...otherProps}\n noShrink\n isDisabled={otherProps.isDisabled}\n error={state.validationState === 'invalid'}\n size={size}\n ref={ref}\n labelPlacement={labelPlacement}\n >\n <I18nProvider locale={preferredLocale}>\n {otherProps.label && (\n <Field.Label>\n <Label\n {...labelProps}\n size={size}\n necessityIndicator={\n otherProps.isRequired && necessityIndicator\n ? 'required'\n : !otherProps.isRequired && necessityIndicator\n ? 'optional'\n : undefined\n }\n contextualHelp={contextualHelp}\n >\n {otherProps.label}\n </Label>\n </Field.Label>\n )}\n <Field.Control>\n <div\n {...groupProps}\n ref={groupRef}\n className={clsx(\n styles['sapphire-date-field'],\n styles['sapphire-date-field--range'],\n {\n [styles['sapphire-date-field--error']]:\n state.validationState === 'invalid',\n [styles['sapphire-date-field--medium']]: isMedium,\n }\n )}\n {...(styleProps.style.width\n ? { style: { width: styleProps.style.width } }\n : {})}\n >\n <PressResponder {...buttonProps} isPressed={state.isOpen}>\n <DateFieldButton\n isDisabled={otherProps.isDisabled || otherProps.isReadOnly}\n >\n <Icon size={isMedium ? 'm' : 'l'}>\n <Calendar />\n </Icon>\n </DateFieldButton>\n </PressResponder>\n <DateRangeInput\n dateRangePickerState={state}\n startFieldProps={startFieldProps}\n endFieldProps={endFieldProps}\n noClearButton={noClearButton}\n size={size}\n />\n </div>\n </Field.Control>\n {error !== false &&\n ((typeof error === 'string' && error !== '') || note) && (\n <Field.Footer>\n {error ? (\n <Field.Note {...errorMessageProps}>{error}</Field.Note>\n ) : note ? (\n <Field.Note {...descriptionProps}>{note}</Field.Note>\n ) : (\n <></>\n )}\n </Field.Footer>\n )}\n {state.isOpen && (\n <Popover state={state} triggerRef={groupRef} placement=\"bottom start\">\n <div\n ref={dialogRef}\n {...dialogProps}\n {...dialogPropsFromDatePicker}\n >\n <View padding={tokens.size.spacing50}>\n <RangeCalendar\n {...calendarProps}\n allowUnavailableDatesWithinRange={\n allowUnavailableDatesWithinRange\n }\n showWeekNumbers={showWeekNumbers}\n showTwoMonths={showTwoMonths}\n predefinedRanges={predefinedRanges}\n />\n </View>\n </div>\n </Popover>\n )}\n </I18nProvider>\n </Field>\n );\n}\n\n/**\n * A date range field allows users to select a range of dates by selecting a to and a from date with keyboard and/or mouse.\n */\nexport const DateRangeField = forwardRef(_DateRangeField) as <\n T extends DateValue,\n P extends string\n>(\n props: DateRangeFieldProps<T, P> & { ref?: RefObject<HTMLDivElement> }\n) => React.ReactElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,SAAA,eAAA,CACE,IAeA,GACA,EAAA;AAhBA,EACE,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,cAAA;AAAA,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AAA,KAAA,CAAA,aAAA,CAAC,KAAM,CAAA,IAAA,EAAP,cAAgB,CAAA,EAAA,EAAA,gBAAA,CAAA,EAAmB,IAEnC,CAAA,mBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,CAAA,CAAA,EAIP,KAAM,CAAA,MAAA,wCACJ,OAAD,EAAA;AAAA,IAAS,KAAA;AAAA,IAAc,UAAY,EAAA,QAAA;AAAA,IAAU,SAAU,EAAA,cAAA;AAAA,GAAA,sCACpD,KAAD,EAAA,cAAA,CAAA,cAAA,CAAA;AAAA,IACE,GAAK,EAAA,SAAA;AAAA,GACD,EAAA,WAAA,CAAA,EACA,yBAEJ,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAD,EAAA;AAAA,IAAM,OAAA,EAAS,OAAO,IAAK,CAAA,SAAA;AAAA,GACzB,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,aADN,CAAA,EAAA;AAAA,IAEE,gCAAA;AAAA,IAGA,eAAA;AAAA,IACA,aAAA;AAAA,IACA,gBAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;AAcX,MAAM,iBAAiB,UAAW,CAAA,eAAA;;;;"}
|
|
@@ -41,7 +41,8 @@ const Fieldset = (_a) => {
|
|
|
41
41
|
isRequired,
|
|
42
42
|
necessityIndicator,
|
|
43
43
|
children,
|
|
44
|
-
size = "large"
|
|
44
|
+
size = "large",
|
|
45
|
+
labelPlacement = "above"
|
|
45
46
|
} = _b, props = __objRest(_b, [
|
|
46
47
|
"label",
|
|
47
48
|
"contextualHelp",
|
|
@@ -51,17 +52,20 @@ const Fieldset = (_a) => {
|
|
|
51
52
|
"isRequired",
|
|
52
53
|
"necessityIndicator",
|
|
53
54
|
"children",
|
|
54
|
-
"size"
|
|
55
|
+
"size",
|
|
56
|
+
"labelPlacement"
|
|
55
57
|
]);
|
|
56
58
|
useThemeCheck();
|
|
57
59
|
const { fieldProps, descriptionProps, errorMessageProps } = useField({
|
|
58
|
-
isInvalid: !!error
|
|
60
|
+
isInvalid: !!error,
|
|
61
|
+
label
|
|
59
62
|
});
|
|
60
63
|
return /* @__PURE__ */ React.createElement(Field, __spreadValues({
|
|
61
64
|
elementType: "fieldset",
|
|
62
65
|
error: !!error,
|
|
63
66
|
isDisabled,
|
|
64
|
-
size
|
|
67
|
+
size,
|
|
68
|
+
labelPlacement
|
|
65
69
|
}, mergeProps(props, fieldProps)), /* @__PURE__ */ React.createElement(Field.Label, {
|
|
66
70
|
elementType: "legend"
|
|
67
71
|
}, /* @__PURE__ */ React.createElement(Label, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fieldset.js","sources":["../../../../src/Fieldset/src/Fieldset.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\n\nimport {\n SapphireStyleProps,\n useThemeCheck,\n Field,\n Label,\n} from '@danske/sapphire-react';\nimport { useField } from '@react-aria/label';\nimport { mergeProps } from '@react-aria/utils';\n\nexport type FieldsetProps = SapphireStyleProps & {\n /**\n * A label that describes the groups of fields.\n * The label is required because a fieldset that is not labelled is not\n * better than separate labelled fields.\n */\n label: ReactNode;\n /**\n * Whether the input is disabled.\n * */\n isDisabled?: boolean;\n /**\n * Whether the input is disabled.\n * */\n isRequired?: boolean;\n /**\n * Whether the input should render as having an error and an error message.\n * This also sets the appropriate `aria` attributes on the input.\n *\n * A `boolean` sets the error state.\n * A `string` sets the error state with an additional error message.\n *\n * **An error message is strongly recommended because an error should\n * always have an explanation about how to fix it.**\n */\n error?: boolean | string;\n /**\n * A note to show below the input.\n * If the input has an error message, this note will be replaced by that.\n */\n note?: ReactNode;\n /**\n * A ContextualHelp to render next to the label.\n */\n contextualHelp?: ReactNode;\n /**\n * @default 'large'\n */\n size?: 'large' | 'medium';\n /**\n * To visually indicate if this field is required or optional.\n * @default false\n */\n necessityIndicator?: boolean;\n /**\n * Children should be two or more form controls without labels, notes or\n * error messages.\n *\n * We recommend you only use these fields inside: `<TextField>`, `<Select> `,\n * `<SearchableSelect>`, `<MultiSelect>`, `<SearchableMultiSelect>`,\n * `<DateField>` or `<DateRangeField>`.\n *\n * Example:\n * ```jsx\n * <Fieldset label=\"Phone Number\">\n * <Select aria-label=\"Country code\" placeholder=\"+00\" width={90}>\n * <SelectItem>+40</SelectItem>\n * <SelectItem>+42</SelectItem>\n * <SelectItem>+45</SelectItem>\n * </Select>\n * <TextField\n * aria-label=\"Phone number\"\n * placeholder=\"000-000-0000\"\n * ></TextField>\n * </Fieldset>\n * ```\n */\n children: ReactNode;\n};\n\n/**\n * Sapphire search input field.\n */\nexport const Fieldset = ({\n label,\n contextualHelp,\n note,\n error,\n isDisabled,\n isRequired,\n necessityIndicator,\n children,\n size = 'large',\n ...props\n}: FieldsetProps) => {\n useThemeCheck();\n\n const { fieldProps, descriptionProps, errorMessageProps } = useField({\n isInvalid: !!error,\n });\n\n return (\n <Field\n elementType=\"fieldset\"\n error={!!error}\n isDisabled={isDisabled}\n size={size}\n {...mergeProps(props, fieldProps)}\n >\n <Field.Label elementType=\"legend\">\n <Label\n size={size}\n necessityIndicator={\n isRequired && necessityIndicator\n ? 'required'\n : !isRequired && necessityIndicator\n ? 'optional'\n : undefined\n }\n contextualHelp={contextualHelp}\n >\n {label}\n </Label>\n </Field.Label>\n <Field.Control isGroup>{children}</Field.Control>\n {(error || note) && (\n <Field.Footer>\n {error ? (\n <Field.Note {...errorMessageProps}>{error}</Field.Note>\n ) : note ? (\n <Field.Note {...descriptionProps}>{note}</Field.Note>\n ) : (\n <></>\n )}\n </Field.Footer>\n )}\n </Field>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Fieldset.js","sources":["../../../../src/Fieldset/src/Fieldset.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\n\nimport {\n SapphireStyleProps,\n useThemeCheck,\n Field,\n Label,\n} from '@danske/sapphire-react';\nimport { useField } from '@react-aria/label';\nimport { mergeProps } from '@react-aria/utils';\n\nexport type FieldsetProps = SapphireStyleProps & {\n /**\n * A label that describes the groups of fields.\n * The label is required because a fieldset that is not labelled is not\n * better than separate labelled fields.\n */\n label: ReactNode;\n /**\n * Whether the input is disabled.\n * */\n isDisabled?: boolean;\n /**\n * Whether the input is disabled.\n * */\n isRequired?: boolean;\n /**\n * Whether the input should render as having an error and an error message.\n * This also sets the appropriate `aria` attributes on the input.\n *\n * A `boolean` sets the error state.\n * A `string` sets the error state with an additional error message.\n *\n * **An error message is strongly recommended because an error should\n * always have an explanation about how to fix it.**\n */\n error?: boolean | string;\n /**\n * A note to show below the input.\n * If the input has an error message, this note will be replaced by that.\n */\n note?: ReactNode;\n /**\n * A ContextualHelp to render next to the label.\n */\n contextualHelp?: ReactNode;\n /**\n * @default 'large'\n */\n size?: 'large' | 'medium';\n /**\n * To visually indicate if this field is required or optional.\n * @default false\n */\n necessityIndicator?: boolean;\n /**\n * Children should be two or more form controls without labels, notes or\n * error messages.\n *\n * We recommend you only use these fields inside: `<TextField>`, `<Select> `,\n * `<SearchableSelect>`, `<MultiSelect>`, `<SearchableMultiSelect>`,\n * `<DateField>` or `<DateRangeField>`.\n *\n * Example:\n * ```jsx\n * <Fieldset label=\"Phone Number\">\n * <Select aria-label=\"Country code\" placeholder=\"+00\" width={90}>\n * <SelectItem>+40</SelectItem>\n * <SelectItem>+42</SelectItem>\n * <SelectItem>+45</SelectItem>\n * </Select>\n * <TextField\n * aria-label=\"Phone number\"\n * placeholder=\"000-000-0000\"\n * ></TextField>\n * </Fieldset>\n * ```\n */\n children: ReactNode;\n\n /**\n * Places the label either above (default) or on the side of the control.\n * @default 'above'\n */\n labelPlacement?: 'side' | 'above';\n};\n\n/**\n * Sapphire search input field.\n */\nexport const Fieldset = ({\n label,\n contextualHelp,\n note,\n error,\n isDisabled,\n isRequired,\n necessityIndicator,\n children,\n size = 'large',\n labelPlacement = 'above',\n ...props\n}: FieldsetProps) => {\n useThemeCheck();\n\n const { fieldProps, descriptionProps, errorMessageProps } = useField({\n isInvalid: !!error,\n label,\n });\n\n return (\n <Field\n elementType=\"fieldset\"\n error={!!error}\n isDisabled={isDisabled}\n size={size}\n labelPlacement={labelPlacement}\n {...mergeProps(props, fieldProps)}\n >\n <Field.Label elementType=\"legend\">\n <Label\n size={size}\n necessityIndicator={\n isRequired && necessityIndicator\n ? 'required'\n : !isRequired && necessityIndicator\n ? 'optional'\n : undefined\n }\n contextualHelp={contextualHelp}\n >\n {label}\n </Label>\n </Field.Label>\n <Field.Control isGroup>{children}</Field.Control>\n {(error || note) && (\n <Field.Footer>\n {error ? (\n <Field.Note {...errorMessageProps}>{error}</Field.Note>\n ) : note ? (\n <Field.Note {...descriptionProps}>{note}</Field.Note>\n ) : (\n <></>\n )}\n </Field.Footer>\n )}\n </Field>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Fa,MAAA,QAAA,GAAW,CAAC,EAYJ,KAAA;AAZI,EACvB,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA,KAAA;AAAA,IACA,cAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,kBAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAO,GAAA,OAAA;AAAA,IACP,cAAiB,GAAA,OAAA;AAAA,GAVM,GAAA,EAAA,EAWpB,kBAXoB,EAWpB,EAAA;AAAA,IAVH,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA,oBAAA;AAAA,IACA,UAAA;AAAA,IACA,MAAA;AAAA,IACA,gBAAA;AAAA,GAAA,CAAA,CAAA;AAGA,EAAA,aAAA,EAAA,CAAA;AAEA,EAAA,MAAM,EAAE,UAA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-
import { SapphireOverlayContainer, ThemeRoot } from '@danske/sapphire-react';
|
|
3
|
+
import { useThemeContext, SapphireOverlayContainer, ThemeRoot } from '@danske/sapphire-react';
|
|
4
4
|
import styles from '@danske/sapphire-css/components/toast/toast.module.css';
|
|
5
5
|
import { Toast } from './Toast.js';
|
|
6
6
|
|
|
@@ -39,12 +39,15 @@ const ToastRegion = (_a) => {
|
|
|
39
39
|
var _b = _a, { state } = _b, props = __objRest(_b, ["state"]);
|
|
40
40
|
const ref = useRef(null);
|
|
41
41
|
const { regionProps } = useToastRegion(props, state, ref);
|
|
42
|
+
const { overlayZIndex = 100 } = useThemeContext();
|
|
42
43
|
return /* @__PURE__ */ React.createElement(SapphireOverlayContainer, null, /* @__PURE__ */ React.createElement(ThemeRoot, {
|
|
43
44
|
contrast: true
|
|
44
45
|
}, /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, regionProps), {
|
|
45
46
|
ref,
|
|
46
47
|
className: styles["sapphire-toast-container"],
|
|
47
|
-
style: {
|
|
48
|
+
style: {
|
|
49
|
+
zIndex: overlayZIndex + 200
|
|
50
|
+
}
|
|
48
51
|
}), state.visibleToasts.map((toast) => /* @__PURE__ */ React.createElement(Toast, __spreadProps(__spreadValues({}, props), {
|
|
49
52
|
key: toast.key,
|
|
50
53
|
toast,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastRegion.js","sources":["../../../../src/Toast/src/ToastRegion.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { AriaToastRegionProps, useToastRegion } from '@react-aria/toast';\nimport {\n SapphireOverlayContainer,\n SapphireStyleProps,\n ThemeRoot,\n} from '@danske/sapphire-react';\n\nimport styles from '@danske/sapphire-css/components/toast/toast.module.css';\nimport { ToastState } from '@react-stately/toast';\nimport { Toast } from './Toast';\n\nexport type ToastRegionProps<T> = AriaToastRegionProps &\n SapphireStyleProps & {\n state: ToastState<T>;\n };\n\nexport const ToastRegion = <T,>({ state, ...props }: ToastRegionProps<T>) => {\n const ref = useRef(null);\n const { regionProps } = useToastRegion(props, state, ref);\n\n return (\n <SapphireOverlayContainer>\n <ThemeRoot contrast>\n <div\n {...regionProps}\n ref={ref}\n className={styles['sapphire-toast-container']}\n style={{
|
|
1
|
+
{"version":3,"file":"ToastRegion.js","sources":["../../../../src/Toast/src/ToastRegion.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { AriaToastRegionProps, useToastRegion } from '@react-aria/toast';\nimport {\n SapphireOverlayContainer,\n SapphireStyleProps,\n ThemeRoot,\n useThemeContext,\n} from '@danske/sapphire-react';\n\nimport styles from '@danske/sapphire-css/components/toast/toast.module.css';\nimport { ToastState } from '@react-stately/toast';\nimport { Toast } from './Toast';\n\nexport type ToastRegionProps<T> = AriaToastRegionProps &\n SapphireStyleProps & {\n state: ToastState<T>;\n };\n\nexport const ToastRegion = <T,>({ state, ...props }: ToastRegionProps<T>) => {\n const ref = useRef(null);\n const { regionProps } = useToastRegion(props, state, ref);\n const { overlayZIndex = 100 } = useThemeContext();\n\n return (\n <SapphireOverlayContainer>\n <ThemeRoot contrast>\n <div\n {...regionProps}\n ref={ref}\n className={styles['sapphire-toast-container']}\n style={\n {\n zIndex: overlayZIndex + 200,\n } /* above overlays from @danske/sapphire-react */\n }\n >\n {state.visibleToasts.map((toast) => (\n <Toast {...props} key={toast.key} toast={toast} state={state} />\n ))}\n </div>\n </ThemeRoot>\n </SapphireOverlayContainer>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBa,MAAA,WAAA,GAAc,CAAK,EAA6C,KAAA;AAA7C,EAAA,IAAA,EAAA,GAAA,EAAA,EAAE,EAAF,KAAA,EAAA,GAAA,EAAA,EAAY,KAAZ,GAAA,SAAA,CAAA,EAAA,EAAY,CAAV,OAAA,CAAA,CAAA,CAAA;AAChC,EAAA,MAAM,MAAM,MAAO,CAAA,IAAA,CAAA,CAAA;AACnB,EAAA,MAAM,EAAE,WAAA,EAAA,GAAgB,cAAe,CAAA,KAAA,EAAO,KAAO,EAAA,GAAA,CAAA,CAAA;AACrD,EAAM,MAAA,EAAE,gBAAgB,GAAQ,EAAA,GAAA,eAAA,EAAA,CAAA;AAEhC,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,wBAAA,EAAD,IACE,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAD,EAAA;AAAA,IAAW,QAAQ,EAAA,IAAA;AAAA,GACjB,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,WADN,CAAA,EAAA;AAAA,IAEE,GAAA;AAAA,IACA,WAAW,MAAO,CAAA,0BAAA,CAAA;AAAA,IAClB,KACE,EAAA;AAAA,MACE,QAAQ,aAAgB,GAAA,GAAA;AAAA,KAAA;AAAA,GAI3B,CAAA,EAAA,KAAA,CAAM,cAAc,GAAI,CAAA,CAAC,0BACvB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAD,iCAAW,KAAX,CAAA,EAAA;AAAA,IAAkB,KAAK,KAAM,CAAA,GAAA;AAAA,IAAK,KAAA;AAAA,IAAc,KAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA;;;;"}
|
package/build/index.d.ts
CHANGED
|
@@ -263,6 +263,11 @@ declare type DateFieldProps<T extends DateValue$1> = Omit<AriaDatePickerProps<T>
|
|
|
263
263
|
* @default false
|
|
264
264
|
*/
|
|
265
265
|
necessityIndicator?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Places the label either above (default) or on the side of the control.
|
|
268
|
+
* @default 'above'
|
|
269
|
+
*/
|
|
270
|
+
labelPlacement?: 'side' | 'above';
|
|
266
271
|
};
|
|
267
272
|
/**
|
|
268
273
|
* A date field allows users to enter or edit date values using the keyboard
|
|
@@ -308,6 +313,11 @@ declare const DateField: <T extends DateValue$1>(props: Omit<AriaDatePickerProps
|
|
|
308
313
|
* @default false
|
|
309
314
|
*/
|
|
310
315
|
necessityIndicator?: boolean | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* Places the label either above (default) or on the side of the control.
|
|
318
|
+
* @default 'above'
|
|
319
|
+
*/
|
|
320
|
+
labelPlacement?: "above" | "side" | undefined;
|
|
311
321
|
} & {
|
|
312
322
|
ref?: React__default.RefObject<HTMLDivElement> | undefined;
|
|
313
323
|
}) => React__default.ReactElement;
|
|
@@ -380,6 +390,11 @@ declare type DateRangeFieldProps<T extends DateValue$1, P extends string> = Omit
|
|
|
380
390
|
* @default false
|
|
381
391
|
*/
|
|
382
392
|
necessityIndicator?: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Places the label either above (default) or on the side of the control.
|
|
395
|
+
* @default 'above'
|
|
396
|
+
*/
|
|
397
|
+
labelPlacement?: 'side' | 'above';
|
|
383
398
|
};
|
|
384
399
|
/**
|
|
385
400
|
* A date range field allows users to select a range of dates by selecting a to and a from date with keyboard and/or mouse.
|
|
@@ -447,6 +462,11 @@ declare const DateRangeField: <T extends DateValue$1, P extends string>(props: O
|
|
|
447
462
|
* @default false
|
|
448
463
|
*/
|
|
449
464
|
necessityIndicator?: boolean | undefined;
|
|
465
|
+
/**
|
|
466
|
+
* Places the label either above (default) or on the side of the control.
|
|
467
|
+
* @default 'above'
|
|
468
|
+
*/
|
|
469
|
+
labelPlacement?: "above" | "side" | undefined;
|
|
450
470
|
} & {
|
|
451
471
|
ref?: React__default.RefObject<HTMLDivElement> | undefined;
|
|
452
472
|
}) => React__default.ReactElement;
|
|
@@ -721,11 +741,16 @@ declare type FieldsetProps = SapphireStyleProps & {
|
|
|
721
741
|
* ```
|
|
722
742
|
*/
|
|
723
743
|
children: ReactNode;
|
|
744
|
+
/**
|
|
745
|
+
* Places the label either above (default) or on the side of the control.
|
|
746
|
+
* @default 'above'
|
|
747
|
+
*/
|
|
748
|
+
labelPlacement?: 'side' | 'above';
|
|
724
749
|
};
|
|
725
750
|
/**
|
|
726
751
|
* Sapphire search input field.
|
|
727
752
|
*/
|
|
728
|
-
declare const Fieldset: ({ label, contextualHelp, note, error, isDisabled, isRequired, necessityIndicator, children, size, ...props }: FieldsetProps) => React__default.JSX.Element;
|
|
753
|
+
declare const Fieldset: ({ label, contextualHelp, note, error, isDisabled, isRequired, necessityIndicator, children, size, labelPlacement, ...props }: FieldsetProps) => React__default.JSX.Element;
|
|
729
754
|
|
|
730
755
|
declare type SapphireAvatarProps = SapphireStyleProps & {
|
|
731
756
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danske/sapphire-react-lab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "Experimental React components of the Sapphire Design System from Danske Bank A/S",
|
|
6
6
|
"exports": {
|
|
@@ -19,23 +19,24 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "cross-env ../../node_modules/.bin/rollup --config ../../rollup.config.js",
|
|
22
|
+
"postpublish": "echo bypassing npx -y send-release-notes@latest --to=6d5d8a75.groupsmail.danskebank.com@emea.teams.ms",
|
|
22
23
|
"prepare": "yarn run build",
|
|
23
24
|
"prepublishOnly": "yarn run build"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
27
|
"@danske/sapphire-icons": "^2.1.0",
|
|
27
|
-
"@danske/sapphire-react": "^3.
|
|
28
|
+
"@danske/sapphire-react": "^3.27.0",
|
|
28
29
|
"react": ">=16.8.0",
|
|
29
30
|
"react-dom": ">=16.8.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@danske/sapphire-icons": "^2.1.0",
|
|
33
|
-
"@danske/sapphire-react": "^3.
|
|
34
|
+
"@danske/sapphire-react": "^3.27.0",
|
|
34
35
|
"@types/react-transition-group": "^4.4.5",
|
|
35
36
|
"cross-env": "^7.0.3"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@danske/sapphire-css": "^26.
|
|
39
|
+
"@danske/sapphire-css": "^26.6.0",
|
|
39
40
|
"@internationalized/date": "^3.5.2",
|
|
40
41
|
"@internationalized/string": "^3.2.1",
|
|
41
42
|
"@react-aria/accordion": "^3.0.0-alpha.27",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"clsx": "^1.1.1",
|
|
69
70
|
"react-transition-group": "^4.4.5"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "18d399194b252d505e09222e08996991f1a9d68a"
|
|
72
73
|
}
|