@sentry/scraps 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +0 -2
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +242 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +354 -0
- package/dist/compactSelect/fzf.d.ts +8 -0
- package/dist/compactSelect/fzf.js +151 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +268 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- package/dist/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +24 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +103 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +136 -0
- package/dist/dropdownMenu/item.js +182 -0
- package/dist/dropdownMenu/list.d.ts +59 -0
- package/dist/dropdownMenu/list.js +410 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
- package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +57 -0
- package/dist/form/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +2 -0
- package/dist/link/linkBehaviorContext.js +17 -10
- package/dist/menu/index.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/menu.d.ts +14 -6
- package/dist/menu/menu.js +160 -56
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- package/dist/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/splitPanel/splitPanel.d.ts +3 -1
- package/dist/splitPanel/splitPanel.js +2 -1
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/index.d.ts +4 -0
- package/dist/tabs/index.js +3 -0
- package/dist/tabs/item.d.ts +13 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +205 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +256 -0
- package/dist/tabs/tabPanels.d.ts +14 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +38 -0
- package/dist/tabs/tabs.js +56 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- package/package.json +115 -16
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { InputGroup } from "../../input/index.js";
|
|
3
|
+
import { BaseField } from "./baseField.js";
|
|
4
|
+
function InputField({ onChange, disabled, leadingItems, trailingItems, ref, ...props }) {
|
|
5
|
+
return /*#__PURE__*/ jsx(BaseField, {
|
|
6
|
+
disabled: disabled,
|
|
7
|
+
ref: ref,
|
|
8
|
+
children: (fieldProps, { indicator })=>/*#__PURE__*/ jsxs(InputGroup, {
|
|
9
|
+
style: {
|
|
10
|
+
flex: 1
|
|
11
|
+
},
|
|
12
|
+
children: [
|
|
13
|
+
leadingItems && /*#__PURE__*/ jsx(InputGroup.LeadingItems, {
|
|
14
|
+
children: leadingItems
|
|
15
|
+
}),
|
|
16
|
+
/*#__PURE__*/ jsx(InputGroup.Input, {
|
|
17
|
+
...fieldProps,
|
|
18
|
+
...props,
|
|
19
|
+
onChange: onChange ? (e)=>onChange(e.target.value) : void 0
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ jsxs(InputGroup.TrailingItems, {
|
|
22
|
+
children: [
|
|
23
|
+
trailingItems,
|
|
24
|
+
indicator
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { InputField };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { useFieldContext } from "../formContext.js";
|
|
4
|
+
import { RequiredIndicator, Warning } from "../icons.js";
|
|
5
|
+
import { DisabledTip, InfoText } from "../../info/index.js";
|
|
6
|
+
import { Container, Flex } from "../../layout/index.js";
|
|
7
|
+
import { Text } from "../../text/index.js";
|
|
8
|
+
import { Tooltip } from "../../tooltip/index.js";
|
|
7
9
|
import { useFieldId, useHintTextId, useLabelId } from "./fieldIds.js";
|
|
8
|
-
import { useFieldContext } from "./formContext.js";
|
|
9
10
|
import { useGroupContext } from "./groupContext.js";
|
|
10
|
-
import { RequiredIndicator, Warning } from "./icons.js";
|
|
11
11
|
function HintText(props) {
|
|
12
12
|
const id = useHintTextId();
|
|
13
13
|
return /*#__PURE__*/ jsx(Container, {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InputFieldProps } from './inputField.js';
|
|
2
|
+
export declare function NumberField(props: Omit<InputFieldProps, 'type' | 'value' | 'onChange'> & {
|
|
3
|
+
onChange: (value: number | null) => void;
|
|
4
|
+
value: number | null;
|
|
5
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { InputField } from "./inputField.js";
|
|
3
|
+
function NumberField(props) {
|
|
4
|
+
return /*#__PURE__*/ jsx(InputField, {
|
|
5
|
+
...props,
|
|
6
|
+
value: null === props.value ? '' : String(props.value),
|
|
7
|
+
onChange: (value)=>props.onChange('' === value ? null : Number(value)),
|
|
8
|
+
type: "number"
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { NumberField };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { IconHide } from "@sentry/icons/hide";
|
|
4
|
+
import { IconShow } from "@sentry/icons/show";
|
|
5
|
+
import { Button } from "../../button/index.js";
|
|
6
|
+
import { InputField } from "./inputField.js";
|
|
7
|
+
import { useTranslation } from "../../translation/useTranslation.js";
|
|
8
|
+
function PasswordField(props) {
|
|
9
|
+
const [isFieldVisible, setisFieldVisible] = useState(false);
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
return /*#__PURE__*/ jsx(InputField, {
|
|
12
|
+
...props,
|
|
13
|
+
type: isFieldVisible ? 'text' : 'password',
|
|
14
|
+
trailingItems: /*#__PURE__*/ jsx(Button, {
|
|
15
|
+
size: "xs",
|
|
16
|
+
variant: "transparent",
|
|
17
|
+
icon: isFieldVisible ? /*#__PURE__*/ jsx(IconShow, {
|
|
18
|
+
size: "xs"
|
|
19
|
+
}) : /*#__PURE__*/ jsx(IconHide, {
|
|
20
|
+
size: "xs"
|
|
21
|
+
}),
|
|
22
|
+
"aria-label": isFieldVisible ? t('Hide password') : t('Show password'),
|
|
23
|
+
onClick: ()=>setisFieldVisible((v)=>!v)
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { PasswordField };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface RadioGroupProps<T extends string> {
|
|
3
|
+
children: (components: {
|
|
4
|
+
Item: (props: RadioItemProps<NoInfer<T>>) => React.JSX.Element;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
onChange: (value: NoInfer<T>) => void;
|
|
7
|
+
value: T;
|
|
8
|
+
disabled?: boolean | string;
|
|
9
|
+
}
|
|
10
|
+
interface RadioItemProps<T extends string> {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
value: T;
|
|
13
|
+
description?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const RadioGroupField: <T extends string>(props: RadioGroupProps<T>) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { useAutoSaveContext } from "../autoSaveContext.js";
|
|
4
|
+
import { useLabelId } from "./fieldIds.js";
|
|
5
|
+
import { GroupProvider, useGroupItemContext } from "./groupContext.js";
|
|
6
|
+
import { FieldMeta } from "./meta.js";
|
|
7
|
+
import { useFieldContext } from "../formContext.js";
|
|
8
|
+
import { Flex, Stack } from "../../layout/index.js";
|
|
9
|
+
import { Radio } from "../../radio/index.js";
|
|
10
|
+
import { Text } from "../../text/index.js";
|
|
11
|
+
import { useAutoSaveIndicator } from "./baseField.js";
|
|
12
|
+
function RadioGroup({ children, value, onChange, disabled }) {
|
|
13
|
+
const field = useFieldContext();
|
|
14
|
+
const labelId = useLabelId();
|
|
15
|
+
const autoSaveContext = useAutoSaveContext();
|
|
16
|
+
const indicator = useAutoSaveIndicator();
|
|
17
|
+
const isDisabled = !!disabled || autoSaveContext?.status === 'pending';
|
|
18
|
+
const contextValue = {
|
|
19
|
+
name: field.name,
|
|
20
|
+
isChecked: (itemValue)=>itemValue === value,
|
|
21
|
+
onChange: (newValue)=>{
|
|
22
|
+
onChange(newValue);
|
|
23
|
+
if (autoSaveContext) {
|
|
24
|
+
autoSaveContext.resetOnErrorRef.current = true;
|
|
25
|
+
field.handleBlur();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
onBlur: field.handleBlur,
|
|
29
|
+
disabled: isDisabled,
|
|
30
|
+
'aria-invalid': !field.state.meta.isValid
|
|
31
|
+
};
|
|
32
|
+
return /*#__PURE__*/ jsx(GroupProvider, {
|
|
33
|
+
value: contextValue,
|
|
34
|
+
children: /*#__PURE__*/ jsxs(Flex, {
|
|
35
|
+
role: "radiogroup",
|
|
36
|
+
"aria-labelledby": labelId,
|
|
37
|
+
gap: "sm",
|
|
38
|
+
align: "center",
|
|
39
|
+
children: [
|
|
40
|
+
children(radioGroupComponents),
|
|
41
|
+
indicator ?? (autoSaveContext ? /*#__PURE__*/ jsx(Flex, {
|
|
42
|
+
width: "14px",
|
|
43
|
+
flexShrink: 0
|
|
44
|
+
}) : null),
|
|
45
|
+
/*#__PURE__*/ jsx(FieldMeta.Status, {
|
|
46
|
+
disabled: disabled
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function RadioItem({ children, value, description }) {
|
|
53
|
+
const { checked, onChange, ...fieldProps } = useGroupItemContext(value);
|
|
54
|
+
const descriptionId = useId();
|
|
55
|
+
return /*#__PURE__*/ jsxs(Flex, {
|
|
56
|
+
as: "label",
|
|
57
|
+
gap: "sm",
|
|
58
|
+
align: "start",
|
|
59
|
+
margin: "0",
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
62
|
+
...fieldProps,
|
|
63
|
+
"aria-describedby": description ? descriptionId : void 0,
|
|
64
|
+
value: value,
|
|
65
|
+
checked: checked,
|
|
66
|
+
onChange: ()=>onChange(value, true)
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ jsxs(Stack, {
|
|
69
|
+
gap: "xs",
|
|
70
|
+
paddingTop: "xs",
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ jsx(Text, {
|
|
73
|
+
bold: false,
|
|
74
|
+
children: children
|
|
75
|
+
}),
|
|
76
|
+
description && /*#__PURE__*/ jsx(Text, {
|
|
77
|
+
bold: false,
|
|
78
|
+
size: "sm",
|
|
79
|
+
variant: "muted",
|
|
80
|
+
id: descriptionId,
|
|
81
|
+
children: description
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const radioGroupComponents = {
|
|
89
|
+
Item: RadioItem
|
|
90
|
+
};
|
|
91
|
+
const RadioGroupField = RadioGroup;
|
|
92
|
+
export { RadioGroupField };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DistributedOmit } from 'type-fest';
|
|
2
|
+
import { type SliderProps } from '../../slider/index.js';
|
|
3
|
+
import { type BaseFieldProps } from './baseField.js';
|
|
4
|
+
export declare function RangeField({ onChange, disabled, value, ref, ...props }: BaseFieldProps<HTMLInputElement> & DistributedOmit<SliderProps, 'value' | 'onChange' | 'onBlur' | 'disabled' | 'id'> & {
|
|
5
|
+
onChange: (value: number) => void;
|
|
6
|
+
value: number;
|
|
7
|
+
disabled?: boolean | string;
|
|
8
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { useAutoSaveContext } from "../autoSaveContext.js";
|
|
4
|
+
import { useLabelId } from "./fieldIds.js";
|
|
5
|
+
import { Flex } from "../../layout/index.js";
|
|
6
|
+
import { Slider } from "../../slider/index.js";
|
|
7
|
+
import { BaseField } from "./baseField.js";
|
|
8
|
+
function RangeField({ onChange, disabled, value, ref, ...props }) {
|
|
9
|
+
const autoSaveContext = useAutoSaveContext();
|
|
10
|
+
const labelId = useLabelId();
|
|
11
|
+
return /*#__PURE__*/ jsx(BaseField, {
|
|
12
|
+
disabled: disabled,
|
|
13
|
+
ref: ref,
|
|
14
|
+
children: (fieldProps, { indicator })=>/*#__PURE__*/ jsxs(Fragment, {
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ jsx(Slider, {
|
|
17
|
+
...fieldProps,
|
|
18
|
+
"aria-labelledby": labelId,
|
|
19
|
+
...props,
|
|
20
|
+
value: value,
|
|
21
|
+
onChange: onChange,
|
|
22
|
+
onChangeEnd: ()=>{
|
|
23
|
+
if (autoSaveContext) fieldProps.onBlur();
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
indicator ?? (autoSaveContext ? /*#__PURE__*/ jsx(Flex, {
|
|
27
|
+
width: "14px",
|
|
28
|
+
flexShrink: 0
|
|
29
|
+
}) : null)
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export { RangeField };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { DistributedOmit } from 'type-fest';
|
|
3
|
+
import type { SelectValue } from '../../select/index.js';
|
|
4
|
+
import { type BaseFieldProps } from './baseField.js';
|
|
5
|
+
import { type SelectFieldProps } from './selectField.js';
|
|
6
|
+
type SelectAsyncFieldProps<TData, TValue, TOption extends SelectValue<TValue>> = BaseFieldProps<HTMLInputElement> & DistributedOmit<SelectFieldProps<TValue, TOption>, 'options' | 'isLoading' | 'onInputChange'> & {
|
|
7
|
+
/**
|
|
8
|
+
* Query configuration - function receives debounced input, returns query options.
|
|
9
|
+
* Use `select` to transform API data to options with full object as value.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* queryOptions={(debouncedInput) => {
|
|
13
|
+
* const baseOptions = apiOptions.as<MyType[]>()(path, {
|
|
14
|
+
* path: {...},
|
|
15
|
+
* query: {query: debouncedInput},
|
|
16
|
+
* staleTime: 30_000,
|
|
17
|
+
* });
|
|
18
|
+
* return {
|
|
19
|
+
* ...baseOptions,
|
|
20
|
+
* select: raw => baseOptions.select(raw).map(item => ({
|
|
21
|
+
* value: item,
|
|
22
|
+
* label: item.name,
|
|
23
|
+
* details: item.description,
|
|
24
|
+
* })),
|
|
25
|
+
* };
|
|
26
|
+
* }}
|
|
27
|
+
*/
|
|
28
|
+
queryOptions: (debouncedInput: string) => UseQueryOptions<TData, Error, ReadonlyArray<TOption & SelectValue<TValue>>, any>;
|
|
29
|
+
};
|
|
30
|
+
export declare function SelectAsyncField<TData, TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>>({ queryOptions, ...props }: SelectAsyncFieldProps<TData, TValue, TOption>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useDebouncedValue } from "@tanstack/react-pacer";
|
|
4
|
+
import { useQuery } from "@tanstack/react-query";
|
|
5
|
+
import { SelectField } from "./selectField.js";
|
|
6
|
+
const DEBOUNCE_MS = 250;
|
|
7
|
+
function SelectAsyncField({ queryOptions, ...props }) {
|
|
8
|
+
const [inputValue, setInputValue] = useState('');
|
|
9
|
+
const [debouncedInput] = useDebouncedValue(inputValue, {
|
|
10
|
+
wait: DEBOUNCE_MS
|
|
11
|
+
});
|
|
12
|
+
const { data: options = [], isPending } = useQuery(queryOptions(debouncedInput));
|
|
13
|
+
return /*#__PURE__*/ jsx(SelectField, {
|
|
14
|
+
...props,
|
|
15
|
+
options: options,
|
|
16
|
+
isLoading: isPending || inputValue !== debouncedInput,
|
|
17
|
+
onInputChange: (input, reason)=>{
|
|
18
|
+
if ('input' === reason) setInputValue(input);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export { SelectAsyncField };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BaseSelectProps, SelectComponents, SelectSelectionProps, SelectValue } from '../../select/index.js';
|
|
2
|
+
import { type BaseFieldProps } from './baseField.js';
|
|
3
|
+
type BaseSelectFieldProps<TValue, TOption extends SelectValue<TValue>> = Omit<BaseSelectProps<TValue, TOption>, 'onBlur' | 'disabled' | 'ref' | 'inputRef' | 'components' | 'id' | 'options'> & BaseFieldProps<HTMLInputElement> & {
|
|
4
|
+
options: ReadonlyArray<TOption & SelectValue<TValue>>;
|
|
5
|
+
components?: Omit<SelectComponents<TOption>, 'Indicators'>;
|
|
6
|
+
};
|
|
7
|
+
export type SelectFieldProps<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>> = BaseSelectFieldProps<TValue, TOption> & SelectSelectionProps<TValue>;
|
|
8
|
+
export declare function SelectField<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>>({ onChange, disabled, multiple, clearable, value, ref, ...props }: SelectFieldProps<TValue, TOption>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { useAutoSaveContext } from "../autoSaveContext.js";
|
|
4
|
+
import { Container, Flex } from "../../layout/index.js";
|
|
5
|
+
import { Select } from "../../select/index.js";
|
|
6
|
+
import { BaseField, useAutoSaveIndicator } from "./baseField.js";
|
|
7
|
+
function SelectIndicatorsContainer({ children }) {
|
|
8
|
+
const indicator = useAutoSaveIndicator();
|
|
9
|
+
return /*#__PURE__*/ jsxs(Flex, {
|
|
10
|
+
padding: "0 sm",
|
|
11
|
+
gap: "sm",
|
|
12
|
+
align: "center",
|
|
13
|
+
children: [
|
|
14
|
+
indicator,
|
|
15
|
+
children
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function SelectField({ onChange, disabled, multiple, clearable, value, ref, ...props }) {
|
|
20
|
+
const autoSaveContext = useAutoSaveContext();
|
|
21
|
+
const selectVariantProps = multiple ? {
|
|
22
|
+
multiple: true,
|
|
23
|
+
clearable,
|
|
24
|
+
value
|
|
25
|
+
} : clearable ? {
|
|
26
|
+
clearable: true,
|
|
27
|
+
value
|
|
28
|
+
} : {
|
|
29
|
+
value
|
|
30
|
+
};
|
|
31
|
+
const isMenuOpenRef = useRef(false);
|
|
32
|
+
return /*#__PURE__*/ jsx(BaseField, {
|
|
33
|
+
disabled: disabled,
|
|
34
|
+
ref: ref,
|
|
35
|
+
children: ({ id, ref: fieldRef, ...fieldProps })=>/*#__PURE__*/ jsx(Container, {
|
|
36
|
+
flex: 1,
|
|
37
|
+
minWidth: 0,
|
|
38
|
+
children: /*#__PURE__*/ jsx(Select, {
|
|
39
|
+
...fieldProps,
|
|
40
|
+
...props,
|
|
41
|
+
...selectVariantProps,
|
|
42
|
+
id: id,
|
|
43
|
+
inputRef: fieldRef,
|
|
44
|
+
blurInputOnSelect: false,
|
|
45
|
+
components: {
|
|
46
|
+
...props.components,
|
|
47
|
+
Indicators: SelectIndicatorsContainer
|
|
48
|
+
},
|
|
49
|
+
onOpenChange: (isOpen)=>{
|
|
50
|
+
isMenuOpenRef.current = isOpen;
|
|
51
|
+
props.onOpenChange?.(isOpen);
|
|
52
|
+
if (!isOpen && multiple && autoSaveContext) fieldProps.onBlur();
|
|
53
|
+
},
|
|
54
|
+
onChange: (option)=>{
|
|
55
|
+
if (multiple) {
|
|
56
|
+
onChange(Array.isArray(option) ? option.map((o)=>o.value) : []);
|
|
57
|
+
if (autoSaveContext && !isMenuOpenRef.current) fieldProps.onBlur();
|
|
58
|
+
} else {
|
|
59
|
+
if (!option) {
|
|
60
|
+
onChange(null);
|
|
61
|
+
if (autoSaveContext) fieldProps.onBlur();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
onChange(option.value);
|
|
65
|
+
fieldProps.onBlur();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export { SelectField };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SwitchProps } from '../../switch/index.js';
|
|
2
|
+
import { type BaseFieldProps } from './baseField.js';
|
|
3
|
+
export declare function SwitchField({ onChange, disabled, ref, ...props }: BaseFieldProps<HTMLInputElement> & Omit<SwitchProps, 'checked' | 'onChange' | 'onBlur' | 'disabled' | 'id'> & {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
onChange: (value: boolean) => void;
|
|
6
|
+
disabled?: boolean | string;
|
|
7
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useAutoSaveContext } from "../autoSaveContext.js";
|
|
3
|
+
import { Flex } from "../../layout/index.js";
|
|
4
|
+
import { Switch } from "../../switch/index.js";
|
|
5
|
+
import { BaseField } from "./baseField.js";
|
|
6
|
+
function SwitchField({ onChange, disabled, ref, ...props }) {
|
|
7
|
+
const autoSaveContext = useAutoSaveContext();
|
|
8
|
+
return /*#__PURE__*/ jsx(BaseField, {
|
|
9
|
+
disabled: disabled,
|
|
10
|
+
ref: ref,
|
|
11
|
+
children: (fieldProps, { indicator })=>/*#__PURE__*/ jsxs(Flex, {
|
|
12
|
+
gap: "sm",
|
|
13
|
+
align: "center",
|
|
14
|
+
justify: "between",
|
|
15
|
+
flexGrow: 1,
|
|
16
|
+
children: [
|
|
17
|
+
/*#__PURE__*/ jsx(Switch, {
|
|
18
|
+
size: "lg",
|
|
19
|
+
...fieldProps,
|
|
20
|
+
...props,
|
|
21
|
+
onChange: (e)=>{
|
|
22
|
+
onChange(e.target.checked);
|
|
23
|
+
if (autoSaveContext) {
|
|
24
|
+
autoSaveContext.resetOnErrorRef.current = true;
|
|
25
|
+
fieldProps.onBlur();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
indicator ?? (autoSaveContext ? /*#__PURE__*/ jsx(Flex, {
|
|
30
|
+
width: "14px",
|
|
31
|
+
flexShrink: 0
|
|
32
|
+
}) : null)
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { SwitchField };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type TextAreaProps } from '../../textarea/index.js';
|
|
2
|
+
import { type BaseFieldProps } from './baseField.js';
|
|
3
|
+
export declare function TextAreaField({ onChange, disabled, ref, ...props }: BaseFieldProps<HTMLTextAreaElement> & Omit<TextAreaProps, 'value' | 'onChange' | 'onBlur' | 'disabled'> & {
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
value: string;
|
|
6
|
+
disabled?: boolean | string;
|
|
7
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { InputGroup } from "../../input/index.js";
|
|
3
|
+
import { BaseField } from "./baseField.js";
|
|
4
|
+
function TextAreaField({ onChange, disabled, ref, ...props }) {
|
|
5
|
+
return /*#__PURE__*/ jsx(BaseField, {
|
|
6
|
+
disabled: disabled,
|
|
7
|
+
ref: ref,
|
|
8
|
+
children: (fieldProps, { indicator })=>/*#__PURE__*/ jsxs(InputGroup, {
|
|
9
|
+
style: {
|
|
10
|
+
flex: 1
|
|
11
|
+
},
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ jsx(InputGroup.TextArea, {
|
|
14
|
+
...fieldProps,
|
|
15
|
+
...props,
|
|
16
|
+
onChange: (e)=>onChange(e.target.value)
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ jsx(InputGroup.TrailingItems, {
|
|
19
|
+
children: indicator
|
|
20
|
+
})
|
|
21
|
+
]
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { TextAreaField };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { createFormHookContexts } from "@tanstack/react-form";
|
|
3
|
-
const { fieldContext
|
|
3
|
+
const { fieldContext, formContext, useFormContext, useFieldContext } = createFormHookContexts();
|
|
4
4
|
const FormElementContext = createContext(false);
|
|
5
5
|
const useIsInsideFormElement = ()=>useContext(FormElementContext);
|
|
6
6
|
export { FormElementContext, fieldContext, formContext, useFieldContext, useFormContext, useIsInsideFormElement };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FieldErrors } from '../scrapsForm.js';
|
|
2
|
+
export type MappedFormError<TFormData> = {
|
|
3
|
+
fieldErrors: FieldErrors<TFormData>;
|
|
4
|
+
} | {
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export type FormErrorMapper = <TFormData>(error: Error, formValues: TFormData, fallbackMessage: string) => MappedFormError<TFormData> | undefined;
|
|
8
|
+
export declare const FormErrorContextProvider: import("react").Provider<FormErrorMapper>;
|
|
9
|
+
export declare function useFormErrorMapper(): FormErrorMapper;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const FormErrorContext = /*#__PURE__*/ createContext(()=>{});
|
|
3
|
+
const FormErrorContextProvider = FormErrorContext.Provider;
|
|
4
|
+
function useFormErrorMapper() {
|
|
5
|
+
return useContext(FormErrorContext);
|
|
6
|
+
}
|
|
7
|
+
export { FormErrorContextProvider, useFormErrorMapper };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export { formOptions, useScrapsForm, defaultFormOptions, setFieldErrors, type FieldErrors, withFieldGroup, withForm, } from './scrapsForm.js';
|
|
3
|
+
export { AutoSaveForm } from './autoSaveForm.js';
|
|
4
|
+
export { AutoSaveContextProvider } from './autoSaveContext.js';
|
|
5
|
+
export { FieldGroup } from './layout/fieldGroup.js';
|
|
6
|
+
export { DisplayField } from './displayField.js';
|
|
7
|
+
export { useStackedLayout } from './layout/useStackedLayout.js';
|
|
8
|
+
export { FormSearch } from './FormSearch.js';
|
|
9
|
+
export { useStore } from '@tanstack/react-form';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { defaultFormOptions, formOptions, setFieldErrors, useScrapsForm, withFieldGroup, withForm } from "./scrapsForm.js";
|
|
2
|
+
export { AutoSaveForm } from "./autoSaveForm.js";
|
|
3
|
+
export { AutoSaveContextProvider } from "./autoSaveContext.js";
|
|
4
|
+
export { FieldGroup } from "./layout/fieldGroup.js";
|
|
5
|
+
export { DisplayField } from "./displayField.js";
|
|
6
|
+
export { useStackedLayout } from "./layout/useStackedLayout.js";
|
|
7
|
+
export { FormSearch } from "./FormSearch.js";
|
|
8
|
+
export { useStore } from "@tanstack/react-form";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { keyframes } from "@emotion/react";
|
|
3
3
|
import styled from "@emotion/styled";
|
|
4
|
-
import { Flex, Stack } from "
|
|
4
|
+
import { Flex, Stack } from "../../layout/index.js";
|
|
5
5
|
function BaseLayout({ stacked, ...props }) {
|
|
6
6
|
return /*#__PURE__*/ jsx(HighlightableFlex, {
|
|
7
7
|
direction: stacked ? 'column' : 'row',
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Container } from "../../layout/index.js";
|
|
4
|
+
import { PanelProvider } from "../../panelProvider.js";
|
|
5
|
+
function FieldGroup({ title, children, hasButtons }) {
|
|
6
|
+
return /*#__PURE__*/ jsx(Panel, {
|
|
7
|
+
children: /*#__PURE__*/ jsxs(PanelProvider, {
|
|
8
|
+
children: [
|
|
9
|
+
title ? /*#__PURE__*/ jsx(PanelHeader, {
|
|
10
|
+
hasButtons: hasButtons,
|
|
11
|
+
children: title
|
|
12
|
+
}) : null,
|
|
13
|
+
/*#__PURE__*/ jsx(PanelBody, {
|
|
14
|
+
children: children
|
|
15
|
+
})
|
|
16
|
+
]
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const Panel = styled('div')`
|
|
21
|
+
background: ${(p)=>p.theme.tokens.background.primary};
|
|
22
|
+
border-radius: ${(p)=>p.theme.radius.md};
|
|
23
|
+
border: 1px solid ${(p)=>p.theme.tokens.border.primary};
|
|
24
|
+
margin-bottom: ${(p)=>p.theme.space.xl};
|
|
25
|
+
position: relative;
|
|
26
|
+
`;
|
|
27
|
+
const PanelHeader = styled('div')`
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
|
|
32
|
+
/* Do not apply text styles to overlay elements such as dropdowns */
|
|
33
|
+
> *:not(:has([data-overlay], button, a[role='button']), button, a[role='button']),
|
|
34
|
+
&:not(:has(> *)) {
|
|
35
|
+
color: ${(p)=>p.theme.tokens.content.primary};
|
|
36
|
+
font-size: ${(p)=>p.theme.font.size.sm};
|
|
37
|
+
font-weight: ${(p)=>p.theme.font.weight.sans.medium};
|
|
38
|
+
text-transform: uppercase;
|
|
39
|
+
line-height: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
border-bottom: 1px solid ${(p)=>p.theme.tokens.border.primary};
|
|
43
|
+
border-radius: calc(${(p)=>p.theme.radius.md} + 1px)
|
|
44
|
+
calc(${(p)=>p.theme.radius.md} + 1px) 0 0;
|
|
45
|
+
background: ${(p)=>p.theme.tokens.background.secondary};
|
|
46
|
+
position: relative;
|
|
47
|
+
padding: ${(p)=>p.hasButtons ? p.theme.space.md : p.theme.space.xl}
|
|
48
|
+
${(p)=>p.theme.space.xl};
|
|
49
|
+
`;
|
|
50
|
+
const PanelBody = styled(Container)`
|
|
51
|
+
> * {
|
|
52
|
+
padding: ${(p)=>p.theme.space.xl};
|
|
53
|
+
border-bottom: 1px solid ${(p)=>p.theme.tokens.border.primary};
|
|
54
|
+
|
|
55
|
+
&:last-child {
|
|
56
|
+
border-bottom: none;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
export { FieldGroup };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { FieldMeta } from "../field/meta.js";
|
|
3
|
+
import { useFieldContext } from "../formContext.js";
|
|
4
|
+
import { Container, Flex } from "../../layout/index.js";
|
|
3
5
|
import { BaseLayout, LayoutLabel } from "./base.js";
|
|
4
|
-
import { useFieldContext } from "./formContext.js";
|
|
5
|
-
import { FieldMeta } from "./meta.js";
|
|
6
6
|
import { useStackedLayout } from "./useStackedLayout.js";
|
|
7
7
|
function RowLayout(props) {
|
|
8
8
|
const isStackLayout = useStackedLayout();
|