no-frills-ui 0.0.14-alpha.1 → 0.0.14-alpha.11
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 +28 -22
- package/dist/index.js +3418 -2772
- package/dist/index.js.map +1 -1
- package/lib-esm/components/Accordion/Accordion.d.ts +11 -16
- package/lib-esm/components/Accordion/Accordion.js +25 -29
- package/lib-esm/components/Accordion/Accordion.js.map +1 -1
- package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
- package/lib-esm/components/Accordion/AccordionStep.js +111 -109
- package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
- package/lib-esm/components/Badge/Badge.d.ts +13 -16
- package/lib-esm/components/Badge/Badge.js +31 -51
- package/lib-esm/components/Badge/Badge.js.map +1 -1
- package/lib-esm/components/Button/ActionButton.d.ts +9 -5
- package/lib-esm/components/Button/ActionButton.js +18 -38
- package/lib-esm/components/Button/ActionButton.js.map +1 -1
- package/lib-esm/components/Button/Button.d.ts +9 -5
- package/lib-esm/components/Button/Button.js +18 -40
- package/lib-esm/components/Button/Button.js.map +1 -1
- package/lib-esm/components/Button/IconButton.d.ts +9 -5
- package/lib-esm/components/Button/IconButton.js +18 -42
- package/lib-esm/components/Button/IconButton.js.map +1 -1
- package/lib-esm/components/Button/LinkButton.d.ts +9 -5
- package/lib-esm/components/Button/LinkButton.js +18 -32
- package/lib-esm/components/Button/LinkButton.js.map +1 -1
- package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
- package/lib-esm/components/Button/RaisedButton.js +18 -46
- package/lib-esm/components/Button/RaisedButton.js.map +1 -1
- package/lib-esm/components/Card/Card.d.ts +4 -6
- package/lib-esm/components/Card/Card.js +18 -13
- package/lib-esm/components/Card/Card.js.map +1 -1
- package/lib-esm/components/Chip/Chip.d.ts +6 -3
- package/lib-esm/components/Chip/Chip.js +44 -43
- package/lib-esm/components/Chip/Chip.js.map +1 -1
- package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -30
- package/lib-esm/components/ChipInput/ChipInput.js +121 -139
- package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
- package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
- package/lib-esm/components/Dialog/AlertDialog.js +44 -28
- package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
- package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
- package/lib-esm/components/Dialog/ConfirmDialog.js +49 -33
- package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
- package/lib-esm/components/Dialog/Dialog.d.ts +40 -18
- package/lib-esm/components/Dialog/Dialog.js +125 -70
- package/lib-esm/components/Dialog/Dialog.js.map +1 -1
- package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
- package/lib-esm/components/Dialog/PromptDialog.js +78 -49
- package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +43 -41
- package/lib-esm/components/DragAndDrop/DragAndDrop.js +104 -31
- package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
- package/lib-esm/components/DragAndDrop/DragItem.d.ts +5 -1
- package/lib-esm/components/DragAndDrop/DragItem.js +171 -92
- package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
- package/lib-esm/components/DragAndDrop/types.d.ts +22 -3
- package/lib-esm/components/DragAndDrop/types.js +9 -6
- package/lib-esm/components/DragAndDrop/types.js.map +1 -1
- package/lib-esm/components/Drawer/Drawer.d.ts +86 -22
- package/lib-esm/components/Drawer/Drawer.js +176 -97
- package/lib-esm/components/Drawer/Drawer.js.map +1 -1
- package/lib-esm/components/Drawer/index.d.ts +1 -1
- package/lib-esm/components/Groups/Group.d.ts +5 -8
- package/lib-esm/components/Groups/Group.js +34 -79
- package/lib-esm/components/Groups/Group.js.map +1 -1
- package/lib-esm/components/Groups/GroupLabel.js +8 -17
- package/lib-esm/components/Groups/GroupLabel.js.map +1 -1
- package/lib-esm/components/Input/Checkbox.d.ts +12 -15
- package/lib-esm/components/Input/Checkbox.js +51 -118
- package/lib-esm/components/Input/Checkbox.js.map +1 -1
- package/lib-esm/components/Input/Dropdown.d.ts +11 -12
- package/lib-esm/components/Input/Dropdown.js +133 -52
- package/lib-esm/components/Input/Dropdown.js.map +1 -1
- package/lib-esm/components/Input/Input.d.ts +3 -3
- package/lib-esm/components/Input/Input.js +61 -109
- package/lib-esm/components/Input/Input.js.map +1 -1
- package/lib-esm/components/Input/Radio.d.ts +4 -8
- package/lib-esm/components/Input/Radio.js +35 -79
- package/lib-esm/components/Input/Radio.js.map +1 -1
- package/lib-esm/components/Input/RadioButton.d.ts +4 -8
- package/lib-esm/components/Input/RadioButton.js +34 -71
- package/lib-esm/components/Input/RadioButton.js.map +1 -1
- package/lib-esm/components/Input/Select.d.ts +6 -13
- package/lib-esm/components/Input/Select.js +75 -122
- package/lib-esm/components/Input/Select.js.map +1 -1
- package/lib-esm/components/Input/TextArea.d.ts +6 -13
- package/lib-esm/components/Input/TextArea.js +64 -108
- package/lib-esm/components/Input/TextArea.js.map +1 -1
- package/lib-esm/components/Input/Toggle.d.ts +4 -9
- package/lib-esm/components/Input/Toggle.js +31 -80
- package/lib-esm/components/Input/Toggle.js.map +1 -1
- package/lib-esm/components/Menu/Menu.d.ts +8 -6
- package/lib-esm/components/Menu/Menu.js +116 -31
- package/lib-esm/components/Menu/Menu.js.map +1 -1
- package/lib-esm/components/Menu/MenuContext.d.ts +11 -5
- package/lib-esm/components/Menu/MenuContext.js +6 -2
- package/lib-esm/components/Menu/MenuContext.js.map +1 -1
- package/lib-esm/components/Menu/MenuItem.d.ts +7 -4
- package/lib-esm/components/Menu/MenuItem.js +46 -47
- package/lib-esm/components/Menu/MenuItem.js.map +1 -1
- package/lib-esm/components/Modal/Modal.d.ts +75 -16
- package/lib-esm/components/Modal/Modal.js +146 -51
- package/lib-esm/components/Modal/Modal.js.map +1 -1
- package/lib-esm/components/Notification/Notification.d.ts +46 -39
- package/lib-esm/components/Notification/Notification.js +80 -87
- package/lib-esm/components/Notification/Notification.js.map +1 -1
- package/lib-esm/components/Notification/NotificationManager.d.ts +19 -5
- package/lib-esm/components/Notification/NotificationManager.js +177 -79
- package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
- package/lib-esm/components/Notification/style.d.ts +6 -3
- package/lib-esm/components/Notification/style.js +64 -140
- package/lib-esm/components/Notification/style.js.map +1 -1
- package/lib-esm/components/Notification/types.d.ts +2 -0
- package/lib-esm/components/Notification/types.js +9 -10
- package/lib-esm/components/Notification/types.js.map +1 -1
- package/lib-esm/components/Popover/Popover.d.ts +21 -20
- package/lib-esm/components/Popover/Popover.js +159 -126
- package/lib-esm/components/Popover/Popover.js.map +1 -1
- package/lib-esm/components/Spinner/Spinner.d.ts +14 -12
- package/lib-esm/components/Spinner/Spinner.js +22 -27
- package/lib-esm/components/Spinner/Spinner.js.map +1 -1
- package/lib-esm/components/Stepper/Step.d.ts +15 -12
- package/lib-esm/components/Stepper/Step.js +18 -25
- package/lib-esm/components/Stepper/Step.js.map +1 -1
- package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
- package/lib-esm/components/Stepper/Stepper.js +104 -102
- package/lib-esm/components/Stepper/Stepper.js.map +1 -1
- package/lib-esm/components/Tabs/Tab.d.ts +10 -16
- package/lib-esm/components/Tabs/Tab.js +9 -15
- package/lib-esm/components/Tabs/Tab.js.map +1 -1
- package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
- package/lib-esm/components/Tabs/Tabs.js +96 -55
- package/lib-esm/components/Tabs/Tabs.js.map +1 -1
- package/lib-esm/components/Toast/Toast.d.ts +34 -7
- package/lib-esm/components/Toast/Toast.js +200 -109
- package/lib-esm/components/Toast/Toast.js.map +1 -1
- package/lib-esm/components/Toast/ToastStory.d.ts +21 -24
- package/lib-esm/components/Tooltip/Tooltip.d.ts +11 -14
- package/lib-esm/components/Tooltip/Tooltip.js +52 -67
- package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-esm/components/index.d.ts +1 -0
- package/lib-esm/icons/CheckCircle.d.ts +1 -1
- package/lib-esm/icons/CheckCircle.js +22 -4
- package/lib-esm/icons/CheckCircle.js.map +1 -1
- package/lib-esm/icons/Close.d.ts +1 -1
- package/lib-esm/icons/Close.js +22 -4
- package/lib-esm/icons/Close.js.map +1 -1
- package/lib-esm/icons/DragIndicator.d.ts +1 -1
- package/lib-esm/icons/DragIndicator.js +22 -4
- package/lib-esm/icons/DragIndicator.js.map +1 -1
- package/lib-esm/icons/ErrorOutline.d.ts +1 -1
- package/lib-esm/icons/ErrorOutline.js +16 -4
- package/lib-esm/icons/ErrorOutline.js.map +1 -1
- package/lib-esm/icons/ExpandMore.d.ts +1 -1
- package/lib-esm/icons/ExpandMore.js +22 -4
- package/lib-esm/icons/ExpandMore.js.map +1 -1
- package/lib-esm/icons/FiberManualRecord.d.ts +1 -1
- package/lib-esm/icons/FiberManualRecord.js +24 -4
- package/lib-esm/icons/FiberManualRecord.js.map +1 -1
- package/lib-esm/icons/Info.d.ts +1 -1
- package/lib-esm/icons/Info.js +22 -4
- package/lib-esm/icons/Info.js.map +1 -1
- package/lib-esm/icons/ReportProblem.d.ts +1 -1
- package/lib-esm/icons/ReportProblem.js +22 -4
- package/lib-esm/icons/ReportProblem.js.map +1 -1
- package/lib-esm/index.js +43 -2
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/shared/LayerManager.d.ts +34 -4
- package/lib-esm/shared/LayerManager.js +248 -114
- package/lib-esm/shared/LayerManager.js.map +1 -1
- package/lib-esm/shared/constants.d.ts +58 -27
- package/lib-esm/shared/constants.js +62 -26
- package/lib-esm/shared/constants.js.map +1 -1
- package/lib-esm/shared/styles.d.ts +1 -1
- package/lib-esm/shared/styles.js +21 -24
- package/lib-esm/shared/styles.js.map +1 -1
- package/package.json +130 -74
- package/lib-esm/components/Accordion/index.js +0 -3
- package/lib-esm/components/Accordion/index.js.map +0 -1
- package/lib-esm/components/Badge/index.js +0 -2
- package/lib-esm/components/Badge/index.js.map +0 -1
- package/lib-esm/components/Button/index.js +0 -6
- package/lib-esm/components/Button/index.js.map +0 -1
- package/lib-esm/components/Card/index.js +0 -3
- package/lib-esm/components/Card/index.js.map +0 -1
- package/lib-esm/components/Chip/index.js +0 -2
- package/lib-esm/components/Chip/index.js.map +0 -1
- package/lib-esm/components/ChipInput/index.js +0 -2
- package/lib-esm/components/ChipInput/index.js.map +0 -1
- package/lib-esm/components/Dialog/index.js +0 -5
- package/lib-esm/components/Dialog/index.js.map +0 -1
- package/lib-esm/components/DragAndDrop/index.js +0 -3
- package/lib-esm/components/DragAndDrop/index.js.map +0 -1
- package/lib-esm/components/Drawer/index.js +0 -2
- package/lib-esm/components/Drawer/index.js.map +0 -1
- package/lib-esm/components/Groups/index.js +0 -3
- package/lib-esm/components/Groups/index.js.map +0 -1
- package/lib-esm/components/Input/index.js +0 -9
- package/lib-esm/components/Input/index.js.map +0 -1
- package/lib-esm/components/Menu/index.js +0 -3
- package/lib-esm/components/Menu/index.js.map +0 -1
- package/lib-esm/components/Modal/index.js +0 -2
- package/lib-esm/components/Modal/index.js.map +0 -1
- package/lib-esm/components/Notification/index.js +0 -3
- package/lib-esm/components/Notification/index.js.map +0 -1
- package/lib-esm/components/Popover/index.js +0 -2
- package/lib-esm/components/Popover/index.js.map +0 -1
- package/lib-esm/components/Spinner/index.js +0 -2
- package/lib-esm/components/Spinner/index.js.map +0 -1
- package/lib-esm/components/Stepper/index.js +0 -4
- package/lib-esm/components/Stepper/index.js.map +0 -1
- package/lib-esm/components/Tabs/index.js +0 -3
- package/lib-esm/components/Tabs/index.js.map +0 -1
- package/lib-esm/components/Toast/ToastStory.js +0 -35
- package/lib-esm/components/Toast/ToastStory.js.map +0 -1
- package/lib-esm/components/Toast/index.js +0 -2
- package/lib-esm/components/Toast/index.js.map +0 -1
- package/lib-esm/components/Tooltip/index.js +0 -2
- package/lib-esm/components/Tooltip/index.js.map +0 -1
- package/lib-esm/components/index.js +0 -20
- package/lib-esm/components/index.js.map +0 -1
- package/lib-esm/icons/index.js +0 -9
- package/lib-esm/icons/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptDialog.js","
|
|
1
|
+
{"version":3,"file":"PromptDialog.js","sources":["../../../src/components/Dialog/PromptDialog.tsx"],"sourcesContent":["import React, { createRef } from 'react';\nimport styled from '@emotion/styled';\nimport { Button, ActionButton } from '../Button';\nimport { Input } from '../Input';\nimport Dialog, { DialogHeader, DialogBody, DialogFooter } from './Dialog';\n\ntype PromptOption = {\n /** Shown as header of the dialog */\n header: string;\n /** Rendered as the body of the dialog */\n body: string;\n /** Default value for the input. */\n defaultValue?: string;\n /** Submit button text. Default value is 'Submit' */\n submitText?: string;\n /** Cancel button text. Default value is 'Cancel' */\n cancelText?: string;\n /** Props for the input. */\n inputProps?: React.HTMLProps<HTMLInputElement>;\n /** Additional props for the dialog. */\n dialogProps?: React.ComponentProps<typeof Dialog>;\n};\n\nconst BodyText = styled.p`\n margin-top: 0;\n`;\n\nconst InputContainer = styled.div`\n display: flex;\n flex: 1;\n margin-top: 10px;\n\n & > label {\n flex: 1;\n width: 100%;\n padding: 0;\n\n & > input {\n width: 100%;\n padding: 0 8px;\n box-sizing: border-box;\n }\n }\n`;\n\nconst StyledInput = styled(Input)`\n flex: 1;\n padding: 0;\n`;\n\nexport default class PromptDialog extends React.Component<PromptOption, { value?: string }> {\n static defaultProps = {\n cancelText: 'Cancel',\n submitText: 'Submit',\n defaultValue: '',\n };\n\n constructor(props: PromptOption) {\n super(props);\n this.state = {\n value: props.defaultValue,\n };\n }\n\n private dialog = createRef<Dialog>();\n\n private valueChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n this.setState({\n value: e.target.value,\n });\n };\n\n private cancel = () => this.dialog.current?.close();\n\n private submit = (e: React.FormEvent) => {\n e.preventDefault();\n this.dialog.current?.close(this.state.value);\n };\n\n public show = () => {\n return new Promise((resolve, reject) => {\n const onClose = (value: unknown) => {\n if (value) {\n resolve(value);\n } else {\n reject();\n }\n this.setState({\n value: this.props.defaultValue,\n });\n };\n this.dialog.current?.open(onClose);\n });\n };\n\n render() {\n const { header, body, inputProps, submitText, cancelText, dialogProps } = this.props;\n\n return (\n <Dialog\n {...dialogProps}\n ref={this.dialog}\n closeOnEsc={false}\n closeOnOverlayClick={false}\n >\n <form onSubmit={this.submit}>\n {header && <DialogHeader>{header}</DialogHeader>}\n <DialogBody>\n <BodyText>{body}</BodyText>\n <InputContainer>\n <StyledInput\n value={this.state.value}\n onChange={this.valueChange}\n {...inputProps}\n />\n </InputContainer>\n </DialogBody>\n <DialogFooter>\n <Button type=\"button\" onClick={this.cancel}>\n {cancelText}\n </Button>\n <ActionButton>{submitText}</ActionButton>\n </DialogFooter>\n </form>\n </Dialog>\n );\n }\n}\n"],"names":["BodyText","styled","InputContainer","StyledInput","Input","PromptDialog","React","Component","render","header","body","inputProps","submitText","cancelText","dialogProps","props","_jsx","Dialog","ref","dialog","closeOnEsc","closeOnOverlayClick","_jsxs","form","onSubmit","submit","DialogHeader","DialogBody","value","state","onChange","valueChange","DialogFooter","Button","type","onClick","cancel","ActionButton","createRef","e","setState","target","current","close","preventDefault","show","Promise","resolve","reject","onClose","defaultValue","open","defaultProps"],"mappings":";;;;;;;;;AAuBA,MAAMA,QAAAA,iBAAWC,MAAAA,CAAAA,GAAAA,EAAAA;;;;AAIjB,MAAMC,cAAAA,iBAAiBD,MAAAA,CAAAA,KAAAA,EAAAA;;;;AAkBvB,MAAME,4BAAcF,MAAAA,CAAOG,KAAAA,EAAAA;;;;AAKZ,MAAMC,YAAAA,SAAqBC,MAAMC,SAAS,CAAA;IA6CrDC,MAAAA,GAAS;AACL,QAAA,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,UAAU,EAAEC,UAAU,EAAEC,WAAW,EAAE,GAAG,IAAI,CAACC,KAAK;AAEpF,QAAA,qBACIC,GAAA,CAACC,MAAAA,EAAAA;AACI,YAAA,GAAGH,WAAW;YACfI,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A,IAAAA,CAEpClB,MAAAA,GAAS,CAACc,CAAAA,GAAAA;AACdA,YAAAA,CAAAA,CAAEK,cAAc,EAAA;YAChB,IAAI,CAACzB,MAAM,CAACuB,OAAO,EAAEC,MAAM,IAAI,CAACd,KAAK,CAACD,KAAK,CAAA;AAC/C,QAAA,CAAA,EAAA,IAAA,CAEOiB,IAAAA,GAAO,IAAA;YACV,OAAO,IAAIC,OAAAA,CAAQ,CAACC,OAAAA,EAASC,MAAAA,GAAAA;AACzB,gBAAA,MAAMC,UAAU,CAACrB,KAAAA,GAAAA;AACb,oBAAA,IAAIA,KAAAA,EAAO;wBACPmB,OAAAA,CAAQnB,KAAAA,CAAAA;oBACZ,CAAA,MAAO;AACHoB,wBAAAA,MAAAA,EAAAA;AACJ,oBAAA;oBACA,IAAI,CAACR,QAAQ,CAAC;AACVZ,wBAAAA,KAAAA,EAAO,IAAI,CAACb,KAAK,CAACmC;AACtB,qBAAA,CAAA;AACJ,gBAAA,CAAA;AACA,gBAAA,IAAI,CAAC/B,MAAM,CAACuB,OAAO,EAAES,IAAAA,CAAKF,OAAAA,CAAAA;AAC9B,YAAA,CAAA,CAAA;AACJ,QAAA,CAAA;QAlCI,IAAI,CAACpB,KAAK,GAAG;AACTD,YAAAA,KAAAA,EAAOb,MAAMmC;AACjB,SAAA;AACJ,IAAA;AAiEJ;AA7EqB7C,YAAAA,CACV+C,YAAAA,GAAe;IAClBvC,UAAAA,EAAY,QAAA;IACZD,UAAAA,EAAY,QAAA;IACZsC,YAAAA,EAAc;AAClB,CAAA;;;;"}
|
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ORIENTATION } from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
|
|
3
|
+
declare const DragAndDrop: React.ForwardRefExoticComponent<{
|
|
4
|
+
/**
|
|
5
|
+
* Orientation of the list layout
|
|
6
|
+
* @default ORIENTATION.VERTICAL
|
|
7
|
+
*/
|
|
8
|
+
orientation?: ORIENTATION;
|
|
6
9
|
/** Drop event handler */
|
|
7
10
|
onDrop: (start: number, end: number) => void;
|
|
8
|
-
/** Shows drag indicator against each list item
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
11
|
+
/** Shows drag indicator against each list item
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
showIndicator?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* i18n: Template for item aria-label. Placeholders: {:position}, {:grabKey}, {:moveKeys}, {:dropKey}, {:altDropKey}
|
|
17
|
+
* @default 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop'
|
|
18
|
+
*/
|
|
19
|
+
itemAriaLabelTemplate?: string;
|
|
20
|
+
/** i18n: Aria label for drag handle
|
|
21
|
+
* @default 'Drag to reorder'
|
|
22
|
+
*/
|
|
23
|
+
dragHandleAriaLabel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* i18n: Template for grabbed announcement. Placeholders: {:position}, {:moveKeys}, {:dropKey}, {:altDropKey}, {:cancelKey}
|
|
26
|
+
* @default 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel'
|
|
27
|
+
*/
|
|
28
|
+
grabbedAnnouncementTemplate?: string;
|
|
29
|
+
/**
|
|
30
|
+
* i18n: Template for moved announcement. Placeholders: {:position}
|
|
31
|
+
* @default 'Item moved to position {:position}'
|
|
32
|
+
*/
|
|
33
|
+
movedAnnouncementTemplate?: string;
|
|
34
|
+
/**
|
|
35
|
+
* i18n: Template for dropped announcement. Placeholders: {:position}
|
|
36
|
+
* @default 'Item dropped at position {:position}'
|
|
37
|
+
*/
|
|
38
|
+
droppedAnnouncementTemplate?: string;
|
|
39
|
+
/**
|
|
40
|
+
* i18n: Template for cancelled announcement
|
|
41
|
+
* @default 'Drag cancelled, item restored to original position'
|
|
42
|
+
*/
|
|
43
|
+
cancelledAnnouncementTemplate?: string;
|
|
44
|
+
} & {
|
|
45
|
+
children?: React.ReactNode | undefined;
|
|
46
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
45
47
|
export default DragAndDrop;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, Fragment, jsx } from '@emotion/react/jsx-runtime';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
import DragItem from './DragItem';
|
|
5
|
-
import { ORIENTATION, DragContext } from './types';
|
|
6
|
-
|
|
7
|
-
const Container = styled
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
import DragItem from './DragItem.js';
|
|
5
|
+
import { ORIENTATION, DragContext } from './types.js';
|
|
6
|
+
|
|
7
|
+
/** Container Component */ const Container$6 = /*#__PURE__*/ styled("div", {
|
|
8
|
+
target: "ec7q6t50",
|
|
9
|
+
label: "Container"
|
|
10
|
+
})("flex:1;display:flex;position:relative;flex-wrap:wrap;flex-direction:", (props)=>props.orientation === ORIENTATION.HORIZONTAL ? 'row' : 'column', ";");
|
|
11
|
+
/** Visually hidden but accessible to screen readers */ const VisuallyHidden$2 = /*#__PURE__*/ styled("div", {
|
|
12
|
+
target: "ec7q6t51",
|
|
13
|
+
label: "VisuallyHidden"
|
|
14
|
+
})("position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;");
|
|
14
15
|
/**
|
|
15
16
|
* A drag and drop container component that enables reordering of child elements.
|
|
16
17
|
*
|
|
@@ -28,34 +29,106 @@ const Container = styled.div `
|
|
|
28
29
|
* </DragAndDrop>
|
|
29
30
|
* ```
|
|
30
31
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
32
|
+
* @param props - The component props
|
|
33
|
+
* @param props.orientation - Determines the layout direction (horizontal or vertical). Defaults to VERTICAL.
|
|
34
|
+
* @param props.onDrop - Callback fired when an item is dropped, receives the start and end indices
|
|
35
|
+
* @param props.showIndicator - Whether to display drag indicators for each list item. Defaults to false.
|
|
36
|
+
* @param props.children - Child elements to be rendered as draggable items
|
|
36
37
|
*
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
const { orientation, children, onDrop, showIndicator } = props;
|
|
38
|
+
* @returns A draggable container with reorderable items
|
|
39
|
+
*/ function DragAndDropComponent(props, ref) {
|
|
40
|
+
const { orientation = ORIENTATION.VERTICAL, children, onDrop, showIndicator = false, itemAriaLabelTemplate = 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop', dragHandleAriaLabel = 'Drag to reorder', grabbedAnnouncementTemplate = 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel', movedAnnouncementTemplate = 'Item moved to position {:position}', droppedAnnouncementTemplate = 'Item dropped at position {:position}', cancelledAnnouncementTemplate = 'Drag cancelled, item restored to original position', ...rest } = props;
|
|
41
41
|
const [startIndex, setStartIndex] = useState(null);
|
|
42
|
+
const [originalIndex, setOriginalIndex] = useState(null);
|
|
42
43
|
const [isDragging, setIsDragging] = useState(false);
|
|
43
44
|
const [dragOver, setDragOver] = useState(null);
|
|
45
|
+
const [announcement, setAnnouncement] = useState('');
|
|
46
|
+
const childrenArray = React.Children.toArray(children);
|
|
47
|
+
const totalItems = childrenArray.length;
|
|
48
|
+
/**
|
|
49
|
+
* Replace placeholders in i18n templates
|
|
50
|
+
*/ const replacePlaceholders = (template, data)=>{
|
|
51
|
+
return template.replace(/\{:position\}/g, String(data.position ?? '')).replace(/\{:grabKey\}/g, data.grabKey ?? 'Space').replace(/\{:dropKey\}/g, data.dropKey ?? 'Space').replace(/\{:altDropKey\}/g, data.altDropKey ?? 'Enter').replace(/\{:cancelKey\}/g, data.cancelKey ?? 'Escape').replace(/\{:moveKeys\}/g, data.moveKeys ?? (orientation === ORIENTATION.VERTICAL ? 'Arrow Up/Down' : 'Arrow Left/Right'));
|
|
52
|
+
};
|
|
53
|
+
// i18n configuration object
|
|
54
|
+
const i18n = {
|
|
55
|
+
itemAriaLabelTemplate: itemAriaLabelTemplate ?? 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',
|
|
56
|
+
dragHandleAriaLabel: dragHandleAriaLabel ?? 'Drag to reorder',
|
|
57
|
+
grabbedAnnouncementTemplate: grabbedAnnouncementTemplate ?? 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',
|
|
58
|
+
movedAnnouncementTemplate: movedAnnouncementTemplate ?? 'Item moved to position {:position}',
|
|
59
|
+
droppedAnnouncementTemplate: droppedAnnouncementTemplate ?? 'Item dropped at position {:position}',
|
|
60
|
+
cancelledAnnouncementTemplate: cancelledAnnouncementTemplate ?? 'Drag cancelled, item restored to original position',
|
|
61
|
+
replacePlaceholders
|
|
62
|
+
};
|
|
44
63
|
/**
|
|
45
64
|
* Drop handler invoked when a draggable item is released.
|
|
46
65
|
* @param index
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
|
|
66
|
+
*/ const drop = (index)=>{
|
|
67
|
+
if (startIndex !== null && index !== null) {
|
|
68
|
+
onDrop?.(startIndex, index);
|
|
69
|
+
}
|
|
50
70
|
setStartIndex(null);
|
|
71
|
+
setOriginalIndex(null);
|
|
51
72
|
setIsDragging(false);
|
|
52
73
|
};
|
|
53
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Cancel handler to restore item to original position
|
|
76
|
+
*/ const cancel = ()=>{
|
|
77
|
+
if (originalIndex !== null && startIndex !== null && startIndex !== originalIndex) {
|
|
78
|
+
onDrop?.(startIndex, originalIndex);
|
|
79
|
+
}
|
|
80
|
+
setStartIndex(null);
|
|
81
|
+
setOriginalIndex(null);
|
|
82
|
+
setIsDragging(false);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Start grab handler to track original position
|
|
86
|
+
*/ const startGrab = (index)=>{
|
|
87
|
+
setStartIndex(index);
|
|
88
|
+
setOriginalIndex(index);
|
|
89
|
+
setIsDragging(true);
|
|
90
|
+
};
|
|
91
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ jsx(DragContext.Provider, {
|
|
94
|
+
value: {
|
|
95
|
+
startIndex,
|
|
96
|
+
setStartIndex,
|
|
97
|
+
drop,
|
|
98
|
+
onDrop,
|
|
99
|
+
cancel,
|
|
100
|
+
startGrab,
|
|
101
|
+
isDragging,
|
|
102
|
+
setIsDragging,
|
|
103
|
+
setDragOver,
|
|
104
|
+
i18n
|
|
105
|
+
},
|
|
106
|
+
children: /*#__PURE__*/ jsx(Container$6, {
|
|
107
|
+
...rest,
|
|
108
|
+
ref: ref,
|
|
109
|
+
orientation: orientation,
|
|
110
|
+
role: "list",
|
|
111
|
+
children: React.Children.map(childrenArray, (child, index)=>/*#__PURE__*/ jsx(DragItem, {
|
|
112
|
+
index: index,
|
|
113
|
+
orientation: orientation,
|
|
114
|
+
showIndicator: showIndicator,
|
|
115
|
+
dragOver: dragOver,
|
|
116
|
+
totalItems: totalItems,
|
|
117
|
+
setAnnouncement: setAnnouncement,
|
|
118
|
+
children: child
|
|
119
|
+
}))
|
|
120
|
+
})
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsx(VisuallyHidden$2, {
|
|
123
|
+
role: "status",
|
|
124
|
+
"aria-live": "polite",
|
|
125
|
+
"aria-atomic": "true",
|
|
126
|
+
children: announcement
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
});
|
|
54
130
|
}
|
|
55
|
-
DragAndDrop
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
showIndicator: false,
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=DragAndDrop.js.map
|
|
131
|
+
const DragAndDrop = /*#__PURE__*/ React.forwardRef(DragAndDropComponent);
|
|
132
|
+
|
|
133
|
+
export { DragAndDrop as default };
|
|
134
|
+
//# sourceMappingURL=DragAndDrop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragAndDrop.js","sourceRoot":"","sources":["../../../src/components/DragAndDrop/DragAndDrop.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAWnD,0BAA0B;AAC1B,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAA4B;;;;;sBAKlC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;CAC7F,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAuB;IACvD,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAA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, useState } from 'react';\nimport styled from '@emotion/styled';\nimport DragItem from './DragItem';\nimport { ORIENTATION, DragContext } from './types';\n\ntype DragAndDropProps = {\n /**\n * Orientation of the list layout\n * @default ORIENTATION.VERTICAL\n */\n orientation?: ORIENTATION;\n /** Drop event handler */\n onDrop: (start: number, end: number) => void;\n /** Shows drag indicator against each list item\n * @default false\n */\n showIndicator?: boolean;\n /**\n * i18n: Template for item aria-label. Placeholders: {:position}, {:grabKey}, {:moveKeys}, {:dropKey}, {:altDropKey}\n * @default 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop'\n */\n itemAriaLabelTemplate?: string;\n /** i18n: Aria label for drag handle\n * @default 'Drag to reorder'\n */\n dragHandleAriaLabel?: string;\n /**\n * i18n: Template for grabbed announcement. Placeholders: {:position}, {:moveKeys}, {:dropKey}, {:altDropKey}, {:cancelKey}\n * @default 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel'\n */\n grabbedAnnouncementTemplate?: string;\n /**\n * i18n: Template for moved announcement. Placeholders: {:position}\n * @default 'Item moved to position {:position}'\n */\n movedAnnouncementTemplate?: string;\n /**\n * i18n: Template for dropped announcement. Placeholders: {:position}\n * @default 'Item dropped at position {:position}'\n */\n droppedAnnouncementTemplate?: string;\n /**\n * i18n: Template for cancelled announcement\n * @default 'Drag cancelled, item restored to original position'\n */\n cancelledAnnouncementTemplate?: string;\n} & PropsWithChildren<unknown>;\n\n/** Container Component */\nconst Container = styled.div<{ orientation: ORIENTATION }>`\n flex: 1;\n display: flex;\n position: relative;\n flex-wrap: wrap;\n flex-direction: ${(props) => (props.orientation === ORIENTATION.HORIZONTAL ? 'row' : 'column')};\n`;\n\n/** Visually hidden but accessible to screen readers */\nconst VisuallyHidden = styled.div`\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n`;\n\n/**\n * A drag and drop container component that enables reordering of child elements.\n *\n * @component\n * @example\n * ```tsx\n * <DragAndDrop\n * orientation={ORIENTATION.VERTICAL}\n * onDrop={(start, end) => handleReorder(start, end)}\n * showIndicator={true}\n * >\n * <div>Item 1</div>\n * <div>Item 2</div>\n * <div>Item 3</div>\n * </DragAndDrop>\n * ```\n *\n * @param props - The component props\n * @param props.orientation - Determines the layout direction (horizontal or vertical). Defaults to VERTICAL.\n * @param props.onDrop - Callback fired when an item is dropped, receives the start and end indices\n * @param props.showIndicator - Whether to display drag indicators for each list item. Defaults to false.\n * @param props.children - Child elements to be rendered as draggable items\n *\n * @returns A draggable container with reorderable items\n */\nfunction DragAndDropComponent(props: DragAndDropProps, ref: React.Ref<HTMLDivElement>) {\n const {\n orientation = ORIENTATION.VERTICAL,\n children,\n onDrop,\n showIndicator = false,\n itemAriaLabelTemplate = 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',\n dragHandleAriaLabel = 'Drag to reorder',\n grabbedAnnouncementTemplate = 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',\n movedAnnouncementTemplate = 'Item moved to position {:position}',\n droppedAnnouncementTemplate = 'Item dropped at position {:position}',\n cancelledAnnouncementTemplate = 'Drag cancelled, item restored to original position',\n ...rest\n } = props;\n const [startIndex, setStartIndex] = useState<number | null>(null);\n const [originalIndex, setOriginalIndex] = useState<number | null>(null);\n const [isDragging, setIsDragging] = useState<boolean>(false);\n const [dragOver, setDragOver] = useState<number | null>(null);\n const [announcement, setAnnouncement] = useState<string | undefined>('');\n const childrenArray = React.Children.toArray(children);\n const totalItems = childrenArray.length;\n\n /**\n * Replace placeholders in i18n templates\n */\n const replacePlaceholders = (\n template: string,\n data: {\n position?: number;\n grabKey?: string;\n dropKey?: string;\n altDropKey?: string;\n cancelKey?: string;\n moveKeys?: string;\n },\n ): string => {\n return template\n .replace(/\\{:position\\}/g, String(data.position ?? ''))\n .replace(/\\{:grabKey\\}/g, data.grabKey ?? 'Space')\n .replace(/\\{:dropKey\\}/g, data.dropKey ?? 'Space')\n .replace(/\\{:altDropKey\\}/g, data.altDropKey ?? 'Enter')\n .replace(/\\{:cancelKey\\}/g, data.cancelKey ?? 'Escape')\n .replace(\n /\\{:moveKeys\\}/g,\n data.moveKeys ??\n (orientation === ORIENTATION.VERTICAL ? 'Arrow Up/Down' : 'Arrow Left/Right'),\n );\n };\n\n // i18n configuration object\n const i18n = {\n itemAriaLabelTemplate:\n itemAriaLabelTemplate ??\n 'Item {:position}. Press {:grabKey} to grab, {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop',\n dragHandleAriaLabel: dragHandleAriaLabel ?? 'Drag to reorder',\n grabbedAnnouncementTemplate:\n grabbedAnnouncementTemplate ??\n 'Item {:position} grabbed. Use {:moveKeys} to move, {:dropKey} or {:altDropKey} to drop, {:cancelKey} to cancel',\n movedAnnouncementTemplate:\n movedAnnouncementTemplate ?? 'Item moved to position {:position}',\n droppedAnnouncementTemplate:\n droppedAnnouncementTemplate ?? 'Item dropped at position {:position}',\n cancelledAnnouncementTemplate:\n cancelledAnnouncementTemplate ?? 'Drag cancelled, item restored to original position',\n replacePlaceholders,\n };\n\n /**\n * Drop handler invoked when a draggable item is released.\n * @param index\n */\n const drop = (index: number | null) => {\n if (startIndex !== null && index !== null) {\n onDrop?.(startIndex, index);\n }\n setStartIndex(null);\n setOriginalIndex(null);\n setIsDragging(false);\n };\n\n /**\n * Cancel handler to restore item to original position\n */\n const cancel = () => {\n if (originalIndex !== null && startIndex !== null && startIndex !== originalIndex) {\n onDrop?.(startIndex, originalIndex);\n }\n setStartIndex(null);\n setOriginalIndex(null);\n setIsDragging(false);\n };\n\n /**\n * Start grab handler to track original position\n */\n const startGrab = (index: number) => {\n setStartIndex(index);\n setOriginalIndex(index);\n setIsDragging(true);\n };\n\n return (\n <>\n <DragContext.Provider\n value={{\n startIndex,\n setStartIndex,\n drop,\n onDrop,\n cancel,\n startGrab,\n isDragging,\n setIsDragging,\n setDragOver,\n i18n,\n }}\n >\n <Container {...rest} ref={ref} orientation={orientation} role=\"list\">\n {React.Children.map(childrenArray, (child, index) => (\n <DragItem\n index={index}\n orientation={orientation}\n showIndicator={showIndicator}\n dragOver={dragOver}\n totalItems={totalItems}\n setAnnouncement={setAnnouncement}\n >\n {child}\n </DragItem>\n ))}\n </Container>\n </DragContext.Provider>\n <VisuallyHidden role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {announcement}\n </VisuallyHidden>\n </>\n );\n}\n\nconst DragAndDrop = React.forwardRef(DragAndDropComponent);\nexport default DragAndDrop;\n"],"names":["Container","styled","props","orientation","ORIENTATION","HORIZONTAL","VisuallyHidden","DragAndDropComponent","ref","VERTICAL","children","onDrop","showIndicator","itemAriaLabelTemplate","dragHandleAriaLabel","grabbedAnnouncementTemplate","movedAnnouncementTemplate","droppedAnnouncementTemplate","cancelledAnnouncementTemplate","rest","startIndex","setStartIndex","useState","originalIndex","setOriginalIndex","isDragging","setIsDragging","dragOver","setDragOver","announcement","setAnnouncement","childrenArray","React","Children","toArray","totalItems","length","replacePlaceholders","template","data","replace","String","position","grabKey","dropKey","altDropKey","cancelKey","moveKeys","i18n","drop","index","cancel","startGrab","_jsxs","_Fragment","_jsx","DragContext","Provider","value","role","map","child","DragItem","aria-live","aria-atomic","DragAndDrop","forwardRef"],"mappings":";;;;;;AAgDA,2BACA,MAAMA,WAAAA,iBAAYC,MAAAA,CAAAA,KAAAA,EAAAA;;;AAKI,CAAA,CAAA,CAAA,sEAAA,EAAA,CAACC,QAAWA,KAAAA,CAAMC,WAAW,KAAKC,WAAAA,CAAYC,UAAU,GAAG,KAAA,GAAQ,QAAA,EAAA,GAAA,CAAA;AAGzF,wDACA,MAAMC,gBAAAA,iBAAiBL,MAAAA,CAAAA,KAAAA,EAAAA;;;;AAYvB;;;;;;;;;;;;;;;;;;;;;;;;AAwBC,IACD,SAAS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A,EAAY,MAAA;AACxDnC,gBAAAA,QAAAA,EAAAA;;;;AAIjB;AAEA,MAAMoC,WAAAA,iBAAcjC,KAAAA,CAAMkC,UAAU,CAAC3D,oBAAAA;;;;"}
|
|
@@ -8,7 +8,11 @@ interface DragItemProps {
|
|
|
8
8
|
/** Whether to show a drag handle indicator instead of making the entire item draggable */
|
|
9
9
|
showIndicator: boolean;
|
|
10
10
|
/** The index of the item currently being dragged over */
|
|
11
|
-
dragOver: number;
|
|
11
|
+
dragOver: number | null;
|
|
12
|
+
/** Total number of items in the list */
|
|
13
|
+
totalItems: number;
|
|
14
|
+
/** Callback to set announcement for screen readers */
|
|
15
|
+
setAnnouncement: (message?: string) => void;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
18
|
* A draggable item component that supports both mouse and touch interactions for drag-and-drop functionality.
|