@uva-glass/component-library 1.53.0 → 1.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AddTableFrom-CwnPli3F.js +162 -0
- package/dist/AddTableFrom-CwnPli3F.js.map +1 -0
- package/dist/{Lexical.prod-DNRTKPfN.js → Lexical.prod-BiuZHlIm.js} +927 -897
- package/dist/Lexical.prod-BiuZHlIm.js.map +1 -0
- package/dist/LexicalUtils.prod-BZOm66mY.js +94 -0
- package/dist/{LexicalUtils.prod-D_BPEjfg.js.map → LexicalUtils.prod-BZOm66mY.js.map} +1 -1
- package/dist/{ListPlugin-CgNBzfIl.js → ListPlugin-DFFbKLaN.js} +4 -4
- package/dist/{ListPlugin-CgNBzfIl.js.map → ListPlugin-DFFbKLaN.js.map} +1 -1
- package/dist/RteEditor.module-BBbfV1rk.js +24 -0
- package/dist/RteEditor.module-BBbfV1rk.js.map +1 -0
- package/dist/Sortable.module-BrgGu8qp.js +24 -0
- package/dist/Sortable.module-BrgGu8qp.js.map +1 -0
- package/dist/SortableProvider-Z0e0qeQT.js +152 -0
- package/dist/SortableProvider-Z0e0qeQT.js.map +1 -0
- package/dist/TablePlugin-CKJQiwra.js +1506 -0
- package/dist/TablePlugin-CKJQiwra.js.map +1 -0
- package/dist/assets/AddTableFrom.css +1 -0
- package/dist/assets/PageOverlay.css +1 -0
- package/dist/assets/RteEditor.css +1 -1
- package/dist/assets/Sortable.css +1 -0
- package/dist/assets/useFlyout.css +1 -1
- package/dist/components/CheckboxTree/CheckboxTree.js +11 -9
- package/dist/components/CheckboxTree/CheckboxTree.js.map +1 -1
- package/dist/components/Icon/icons/index.d.ts +3 -0
- package/dist/components/Icon/icons/index.js +18 -13
- package/dist/components/Icon/icons/index.js.map +1 -1
- package/dist/components/InputField/InputField.stories.js +13 -11
- package/dist/components/InputField/InputField.stories.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
- package/dist/components/MultiSelect/components/MultiSelectHeader.js +4 -2
- package/dist/components/MultiSelect/components/MultiSelectHeader.js.map +1 -1
- package/dist/components/MultiSelect/index.js +1 -1
- package/dist/components/PageOverlay/PageOverlay.d.ts +25 -0
- package/dist/components/PageOverlay/PageOverlay.js +100 -0
- package/dist/components/PageOverlay/PageOverlay.js.map +1 -0
- package/dist/components/PageOverlay/PageOverlay.stories.d.ts +7 -0
- package/dist/components/PageOverlay/PageOverlay.stories.js +167 -0
- package/dist/components/PageOverlay/PageOverlay.stories.js.map +1 -0
- package/dist/components/PageOverlay/index.d.ts +1 -0
- package/dist/components/PageOverlay/index.js +5 -0
- package/dist/components/PageOverlay/index.js.map +1 -0
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +26 -24
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js.map +1 -1
- package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +2 -2
- package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +18 -16
- package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkFrom.d.ts +12 -0
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkFrom.js +28 -0
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkFrom.js.map +1 -0
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +49 -68
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
- package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +3 -3
- package/dist/components/RteEditor/Plugins/ListPlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.d.ts +10 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +25 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js.map +1 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.d.ts +1 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +29 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js.map +1 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/index.d.ts +1 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/index.js +5 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/index.js.map +1 -0
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +26 -24
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/index.d.ts +1 -0
- package/dist/components/RteEditor/Plugins/index.js +6 -4
- package/dist/components/RteEditor/Plugins/index.js.map +1 -1
- package/dist/components/RteEditor/RteEditor.js +559 -774
- package/dist/components/RteEditor/RteEditor.js.map +1 -1
- package/dist/components/RteEditor/UvaTheme/UvaTheme.d.ts +1 -0
- package/dist/components/RteEditor/UvaTheme/UvaTheme.js +5 -4
- package/dist/components/RteEditor/UvaTheme/UvaTheme.js.map +1 -1
- package/dist/components/RteEditor/hooks/useFlyout.d.ts +1 -0
- package/dist/components/RteEditor/hooks/useFlyout.js +18 -36
- package/dist/components/RteEditor/hooks/useFlyout.js.map +1 -1
- package/dist/components/Sortable/Sortable.d.ts +16 -0
- package/dist/components/Sortable/Sortable.js +27 -0
- package/dist/components/Sortable/Sortable.js.map +1 -0
- package/dist/components/Sortable/Sortable.stories.d.ts +7 -0
- package/dist/components/Sortable/Sortable.stories.js +53 -0
- package/dist/components/Sortable/Sortable.stories.js.map +1 -0
- package/dist/components/Sortable/SortableProvider.d.ts +23 -0
- package/dist/components/Sortable/SortableProvider.js +10 -0
- package/dist/components/Sortable/SortableProvider.js.map +1 -0
- package/dist/components/Sortable/actions.d.ts +49 -0
- package/dist/components/Sortable/actions.js +33 -0
- package/dist/components/Sortable/actions.js.map +1 -0
- package/dist/components/Sortable/components/SortableContainer.d.ts +7 -0
- package/dist/components/Sortable/components/SortableContainer.js +9 -0
- package/dist/components/Sortable/components/SortableContainer.js.map +1 -0
- package/dist/components/Sortable/components/SortableHandle.d.ts +4 -0
- package/dist/components/Sortable/components/SortableHandle.js +11 -0
- package/dist/components/Sortable/components/SortableHandle.js.map +1 -0
- package/dist/components/Sortable/components/SortableItem.d.ts +9 -0
- package/dist/components/Sortable/components/SortableItem.js +113 -0
- package/dist/components/Sortable/components/SortableItem.js.map +1 -0
- package/dist/components/Sortable/constants.d.ts +10 -0
- package/dist/components/Sortable/constants.js +14 -0
- package/dist/components/Sortable/constants.js.map +1 -0
- package/dist/components/Sortable/index.d.ts +1 -0
- package/dist/components/Sortable/index.js +5 -0
- package/dist/components/Sortable/index.js.map +1 -0
- package/dist/components/Sortable/sortableReducer.d.ts +24 -0
- package/dist/components/Sortable/sortableReducer.js +92 -0
- package/dist/components/Sortable/sortableReducer.js.map +1 -0
- package/dist/components/hooks/useOnClickOuside.d.ts +4 -0
- package/dist/components/hooks/useOnClickOuside.js +15 -0
- package/dist/components/hooks/useOnClickOuside.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +45 -41
- package/dist/components/index.js.map +1 -1
- package/dist/{helpers-TSjo3aAv.js → helpers-CJF7fErD.js} +3 -3
- package/dist/{helpers-TSjo3aAv.js.map → helpers-CJF7fErD.js.map} +1 -1
- package/dist/index.js +45 -41
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/Lexical.prod-DNRTKPfN.js.map +0 -1
- package/dist/LexicalUtils.prod-D_BPEjfg.js +0 -64
- package/dist/MultiSelect-D1FnMER4.js +0 -53
- package/dist/MultiSelect-D1FnMER4.js.map +0 -1
- package/dist/RteEditor.module-BjGyWKhW.js +0 -26
- package/dist/RteEditor.module-BjGyWKhW.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sortable.js","sources":["../../../src/components/Sortable/Sortable.tsx"],"sourcesContent":["import { Children } from 'react';\n\nimport type { ReactElement } from 'react';\nimport type { SortableItemProps } from './components/SortableItem';\n\nimport { SortableItem } from './components/SortableItem';\nimport { SortableProvider } from './SortableProvider';\n\nexport type Index = string | number;\n\nexport interface SortableProps {\n /** The elements to show inside the Sortable. */\n children: ReactElement[] | string[];\n /** The placement of each item Handle (6 dots 2x3). */\n ItemHandlePlacement?: SortableItemProps['handlePlacement'];\n /** If true, a scrollable version of the list will be rendered (max height 21rem/336px). */\n scrollable?: boolean;\n /** If true, the sorting will be disabled. */\n disabled?: boolean;\n /** The callback function that is invoked when new sorting takes place. */\n onSort?: (items: (string | ReactElement)[]) => void;\n}\n\n// A component that renders a list of children that can be sorted with drag and drop.\nexport const Sortable = ({ children, ItemHandlePlacement = 'left', scrollable, disabled, onSort }: SortableProps) => {\n return (\n <SortableProvider\n items={children}\n scrollable={scrollable}\n onSort={onSort}\n key={`sortable-with-children-${Children.count(children)}`}\n >\n {children.map((child, index) => (\n <SortableItem\n handlePlacement={ItemHandlePlacement}\n disabled={disabled || Children.count(children) <= 1}\n index={index}\n key={`sortable-item-${index}`}\n >\n {child}\n </SortableItem>\n ))}\n </SortableProvider>\n );\n};\n"],"names":["Sortable","children","ItemHandlePlacement","scrollable","disabled","onSort","jsx","SortableProvider","child","index","SortableItem","Children"],"mappings":";;;;AAwBa,MAAAA,IAAW,CAAC,EAAE,UAAAC,GAAU,qBAAAC,IAAsB,QAAQ,YAAAC,GAAY,UAAAC,GAAU,QAAAC,QAErF,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,OAAON;AAAA,IACP,YAAAE;AAAA,IACA,QAAAE;AAAA,IAGC,UAASJ,EAAA,IAAI,CAACO,GAAOC,MACpB,gBAAAH;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,iBAAiBR;AAAA,QACjB,UAAUE,KAAYO,EAAS,MAAMV,CAAQ,KAAK;AAAA,QAClD,OAAAQ;AAAA,QAGC,UAAAD;AAAA,MAAA;AAAA,MAFI,iBAAiBC,CAAK;AAAA,IAAA,CAI9B;AAAA,EAAA;AAAA,EAXI,0BAA0BE,EAAS,MAAMV,CAAQ,CAAC;AAAA;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { SortableProps } from './Sortable';
|
|
3
|
+
declare const _default: Meta<SortableProps>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const SortableExample: import('@storybook/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, SortableProps>;
|
|
6
|
+
export declare const withHandleRight: import('@storybook/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, SortableProps>;
|
|
7
|
+
export declare const WithComplexChildren: import('@storybook/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, SortableProps>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as e, jsxs as m, Fragment as i } from "react/jsx-runtime";
|
|
2
|
+
import { fn as s } from "../../index-MQ0yPLdl.js";
|
|
3
|
+
import { Sortable as o } from "./Sortable.js";
|
|
4
|
+
import { InputField as c } from "../InputField/InputField.js";
|
|
5
|
+
import { Icon as d } from "../Icon/Icon.js";
|
|
6
|
+
import { Button as p } from "../Buttons/Button.js";
|
|
7
|
+
import "../Buttons/LinkButton.js";
|
|
8
|
+
import "@react-aria/button";
|
|
9
|
+
const b = "<Sortable onSort={onSortFunction} ItemHandlePlacement={ItemHandlePlacement} scrollable={scrollable} disabled={disabled}> {children} </ Sortable>", j = {
|
|
10
|
+
title: "Organisms/Sortable",
|
|
11
|
+
component: o,
|
|
12
|
+
argTypes: {
|
|
13
|
+
children: {
|
|
14
|
+
table: {
|
|
15
|
+
disable: !0
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
ItemHandlePlacement: {
|
|
19
|
+
table: {
|
|
20
|
+
disable: !0
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
parameters: {
|
|
25
|
+
inspectComponent: o,
|
|
26
|
+
codeString: b
|
|
27
|
+
}
|
|
28
|
+
}, l = {
|
|
29
|
+
ItemHandlePlacement: "left",
|
|
30
|
+
onSort: s()
|
|
31
|
+
}, r = ["Item-1", "Item-2", "Item-3", "Item-4", "Item-5"], a = (n) => /* @__PURE__ */ e(o, { ...n, children: r }), h = a.bind({});
|
|
32
|
+
h.args = {
|
|
33
|
+
...l
|
|
34
|
+
};
|
|
35
|
+
const f = a.bind({});
|
|
36
|
+
f.args = {
|
|
37
|
+
...l,
|
|
38
|
+
ItemHandlePlacement: "right"
|
|
39
|
+
};
|
|
40
|
+
const I = (n) => /* @__PURE__ */ e(o, { ...n, children: r.map((t) => /* @__PURE__ */ m(i, { children: [
|
|
41
|
+
/* @__PURE__ */ e("div", { style: { width: "100%" }, children: /* @__PURE__ */ e(c, { id: t, placeholder: t }, t) }),
|
|
42
|
+
/* @__PURE__ */ e(p, { variant: "blank-icon", children: /* @__PURE__ */ e(d, { name: "Trash", color: "#a0002aff" }) })
|
|
43
|
+
] }, t)) }), g = I.bind({});
|
|
44
|
+
g.args = {
|
|
45
|
+
...l
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
h as SortableExample,
|
|
49
|
+
g as WithComplexChildren,
|
|
50
|
+
j as default,
|
|
51
|
+
f as withHandleRight
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=Sortable.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sortable.stories.js","sources":["../../../src/components/Sortable/Sortable.stories.tsx"],"sourcesContent":["import { fn } from '@storybook/test';\nimport { Fragment } from 'react/jsx-runtime';\n\nimport type { Meta, StoryFn } from '@storybook/react';\nimport type { SortableProps } from './Sortable';\n\nimport { Sortable } from './Sortable';\n\nimport { InputField } from 'components/InputField';\nimport { Icon } from 'components/Icon';\nimport { Button } from 'components/Buttons';\n\nconst codeString =\n '<Sortable onSort={onSortFunction} ItemHandlePlacement={ItemHandlePlacement} scrollable={scrollable} disabled={disabled}> {children} </ Sortable>';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Organisms/Sortable',\n component: Sortable,\n argTypes: {\n children: {\n table: {\n disable: true,\n },\n },\n ItemHandlePlacement: {\n table: {\n disable: true,\n },\n },\n },\n parameters: {\n inspectComponent: Sortable,\n codeString: codeString,\n },\n} as Meta<SortableProps>;\n\nconst defaultArgs: Partial<SortableProps> = {\n ItemHandlePlacement: 'left',\n onSort: fn(),\n};\n\nconst mockItems = ['Item-1', 'Item-2', 'Item-3', 'Item-4', 'Item-5'];\n\nconst Template: StoryFn<SortableProps> = (args) => <Sortable {...args}>{mockItems}</Sortable>;\n\nexport const SortableExample = Template.bind({});\nSortableExample.args = {\n ...defaultArgs,\n};\n\nexport const withHandleRight = Template.bind({});\nwithHandleRight.args = {\n ...defaultArgs,\n ItemHandlePlacement: 'right',\n};\n\nconst TemplateComplex: StoryFn<SortableProps> = (args) => (\n <Sortable {...args}>\n {mockItems.map((item) => (\n <Fragment key={item}>\n <div style={{ width: '100%' }}>\n <InputField key={item} id={item} placeholder={item} />\n </div>\n <Button variant=\"blank-icon\">\n <Icon name=\"Trash\" color=\"#a0002aff\" />\n </Button>\n </Fragment>\n ))}\n </Sortable>\n);\n\nexport const WithComplexChildren = TemplateComplex.bind({});\nWithComplexChildren.args = {\n ...defaultArgs,\n};\n"],"names":["codeString","Sortable_stories","Sortable","defaultArgs","fn","mockItems","Template","args","SortableExample","withHandleRight","TemplateComplex","jsx","item","jsxs","Fragment","InputField","Button","Icon","WithComplexChildren"],"mappings":";;;;;;;;AAYA,MAAMA,IACJ,oJAGaC,IAAA;AAAA,EACb,OAAO;AAAA,EACP,WAAWC;AAAA,EACX,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,qBAAqB;AAAA,MACnB,OAAO;AAAA,QACL,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,kBAAkBA;AAAA,IAClB,YAAAF;AAAA,EACF;AACF,GAEMG,IAAsC;AAAA,EAC1C,qBAAqB;AAAA,EACrB,QAAQC,EAAG;AACb,GAEMC,IAAY,CAAC,UAAU,UAAU,UAAU,UAAU,QAAQ,GAE7DC,IAAmC,CAACC,wBAAUL,GAAU,EAAA,GAAGK,GAAO,UAAUF,EAAA,CAAA,GAErEG,IAAkBF,EAAS,KAAK,EAAE;AAC/CE,EAAgB,OAAO;AAAA,EACrB,GAAGL;AACL;AAEO,MAAMM,IAAkBH,EAAS,KAAK,EAAE;AAC/CG,EAAgB,OAAO;AAAA,EACrB,GAAGN;AAAA,EACH,qBAAqB;AACvB;AAEA,MAAMO,IAA0C,CAACH,MAC/C,gBAAAI,EAACT,GAAU,EAAA,GAAGK,GACX,UAAAF,EAAU,IAAI,CAACO,MACd,gBAAAC,EAACC,GACC,EAAA,UAAA;AAAA,EAAA,gBAAAH,EAAC,OAAI,EAAA,OAAO,EAAE,OAAO,OAAO,GAC1B,UAAC,gBAAAA,EAAAI,GAAA,EAAsB,IAAIH,GAAM,aAAaA,EAAA,GAA7BA,CAAmC,GACtD;AAAA,EACA,gBAAAD,EAACK,GAAO,EAAA,SAAQ,cACd,UAAA,gBAAAL,EAACM,KAAK,MAAK,SAAQ,OAAM,YAAA,CAAY,EACvC,CAAA;AAAA,KANaL,CAOf,CACD,EACH,CAAA,GAGWM,IAAsBR,EAAgB,KAAK,EAAE;AAC1DQ,EAAoB,OAAO;AAAA,EACzB,GAAGf;AACL;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { SortableStateType } from './sortableReducer';
|
|
3
|
+
type SortableContextType = {
|
|
4
|
+
clearDraggingSource: () => void;
|
|
5
|
+
clearDraggingTarget: () => void;
|
|
6
|
+
dragEnd: () => void;
|
|
7
|
+
dragStart: (index: number) => void;
|
|
8
|
+
drop: (index: number) => void;
|
|
9
|
+
moveToPosition: (index: number) => void;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
setClone: (node: Element) => void;
|
|
12
|
+
setDraggingSource: (index: number) => void;
|
|
13
|
+
setDraggingTarget: (index: number) => void;
|
|
14
|
+
};
|
|
15
|
+
interface Props {
|
|
16
|
+
children: SortableStateType['sortableItems'];
|
|
17
|
+
items: ReactElement[] | string[];
|
|
18
|
+
scrollable?: boolean;
|
|
19
|
+
onSort?: (items: (string | ReactElement)[]) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function SortableProvider({ children, items, scrollable, onSort }: Props): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function useSortable(): SortableContextType & SortableStateType;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "./sortableReducer.js";
|
|
4
|
+
import { S as p, u as a } from "../../SortableProvider-Z0e0qeQT.js";
|
|
5
|
+
import "./actions.js";
|
|
6
|
+
export {
|
|
7
|
+
p as SortableProvider,
|
|
8
|
+
a as useSortable
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=SortableProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CLEAR_DRAGGING_SOURCE, CLEAR_DRAGGING_TARGET, DRAG_END, DRAG_START, DROP, MOVE_TO_POSITION, RESET, SET_CLONE, SET_DRAGGING_SOURCE, SET_DRAGGING_TARGET } from './constants';
|
|
2
|
+
type ClearDraggingSourceAction = {
|
|
3
|
+
type: typeof CLEAR_DRAGGING_SOURCE;
|
|
4
|
+
};
|
|
5
|
+
type ClearDraggingTargetAction = {
|
|
6
|
+
type: typeof CLEAR_DRAGGING_TARGET;
|
|
7
|
+
};
|
|
8
|
+
type DragEndAction = {
|
|
9
|
+
type: typeof DRAG_END;
|
|
10
|
+
};
|
|
11
|
+
type DragStartAction = {
|
|
12
|
+
type: typeof DRAG_START;
|
|
13
|
+
payload: number;
|
|
14
|
+
};
|
|
15
|
+
type DropAction = {
|
|
16
|
+
type: typeof DROP;
|
|
17
|
+
payload: number;
|
|
18
|
+
};
|
|
19
|
+
type MoveToPositionAction = {
|
|
20
|
+
type: typeof MOVE_TO_POSITION;
|
|
21
|
+
payload: number;
|
|
22
|
+
};
|
|
23
|
+
type ResetAction = {
|
|
24
|
+
type: typeof RESET;
|
|
25
|
+
};
|
|
26
|
+
type SetCloneAction = {
|
|
27
|
+
type: typeof SET_CLONE;
|
|
28
|
+
payload: Element;
|
|
29
|
+
};
|
|
30
|
+
type SetDraggingSourceAction = {
|
|
31
|
+
type: typeof SET_DRAGGING_SOURCE;
|
|
32
|
+
payload: number;
|
|
33
|
+
};
|
|
34
|
+
type SetDraggingTargetAction = {
|
|
35
|
+
type: typeof SET_DRAGGING_TARGET;
|
|
36
|
+
payload: number;
|
|
37
|
+
};
|
|
38
|
+
export type Actions = ClearDraggingSourceAction | ClearDraggingTargetAction | DragEndAction | DragStartAction | DropAction | MoveToPositionAction | ResetAction | SetCloneAction | SetDraggingSourceAction | SetDraggingTargetAction;
|
|
39
|
+
export declare const setClone: (payload: SetCloneAction["payload"]) => SetCloneAction;
|
|
40
|
+
export declare const clearDraggingSource: () => ClearDraggingSourceAction;
|
|
41
|
+
export declare const clearDraggingTarget: () => ClearDraggingTargetAction;
|
|
42
|
+
export declare const dragEnd: () => DragEndAction;
|
|
43
|
+
export declare const dragStart: (draggingItemIndex: DragStartAction["payload"]) => DragStartAction;
|
|
44
|
+
export declare const drop: (targetItemIndex: DropAction["payload"]) => DropAction;
|
|
45
|
+
export declare const moveToPosition: (targetItemIndex: MoveToPositionAction["payload"]) => MoveToPositionAction;
|
|
46
|
+
export declare const reset: () => ResetAction;
|
|
47
|
+
export declare const setDraggingSource: (sourceItemIndex: SetDraggingSourceAction["payload"]) => SetDraggingSourceAction;
|
|
48
|
+
export declare const setDraggingTarget: (targetItemIndex: SetDraggingTargetAction["payload"]) => SetDraggingTargetAction;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SET_CLONE as o, CLEAR_DRAGGING_SOURCE as e, CLEAR_DRAGGING_TARGET as a, DRAG_END as p, DRAG_START as r, DROP as n, MOVE_TO_POSITION as g, RESET as G, SET_DRAGGING_SOURCE as s, SET_DRAGGING_TARGET as y } from "./constants.js";
|
|
2
|
+
const R = (t) => ({
|
|
3
|
+
type: o,
|
|
4
|
+
payload: t
|
|
5
|
+
}), T = () => ({ type: e }), c = () => ({ type: a }), _ = () => ({ type: p }), D = (t) => ({
|
|
6
|
+
type: r,
|
|
7
|
+
payload: t
|
|
8
|
+
}), A = (t) => ({
|
|
9
|
+
type: n,
|
|
10
|
+
payload: t
|
|
11
|
+
}), S = (t) => ({
|
|
12
|
+
type: g,
|
|
13
|
+
payload: t
|
|
14
|
+
}), d = () => ({ type: G }), l = (t) => ({
|
|
15
|
+
type: s,
|
|
16
|
+
payload: t
|
|
17
|
+
}), O = (t) => ({
|
|
18
|
+
type: y,
|
|
19
|
+
payload: t
|
|
20
|
+
});
|
|
21
|
+
export {
|
|
22
|
+
T as clearDraggingSource,
|
|
23
|
+
c as clearDraggingTarget,
|
|
24
|
+
_ as dragEnd,
|
|
25
|
+
D as dragStart,
|
|
26
|
+
A as drop,
|
|
27
|
+
S as moveToPosition,
|
|
28
|
+
d as reset,
|
|
29
|
+
R as setClone,
|
|
30
|
+
l as setDraggingSource,
|
|
31
|
+
O as setDraggingTarget
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sources":["../../../src/components/Sortable/actions.ts"],"sourcesContent":["import {\n CLEAR_DRAGGING_SOURCE,\n CLEAR_DRAGGING_TARGET,\n DRAG_END,\n DRAG_START,\n DROP,\n MOVE_TO_POSITION,\n RESET,\n SET_CLONE,\n SET_DRAGGING_SOURCE,\n SET_DRAGGING_TARGET,\n} from './constants';\n\ntype ClearDraggingSourceAction = {\n type: typeof CLEAR_DRAGGING_SOURCE;\n};\n\ntype ClearDraggingTargetAction = {\n type: typeof CLEAR_DRAGGING_TARGET;\n};\n\ntype DragEndAction = {\n type: typeof DRAG_END;\n};\n\ntype DragStartAction = {\n type: typeof DRAG_START;\n payload: number;\n};\n\ntype DropAction = {\n type: typeof DROP;\n payload: number;\n};\n\ntype MoveToPositionAction = {\n type: typeof MOVE_TO_POSITION;\n payload: number;\n};\n\ntype ResetAction = {\n type: typeof RESET;\n};\n\ntype SetCloneAction = {\n type: typeof SET_CLONE;\n payload: Element;\n};\n\ntype SetDraggingSourceAction = {\n type: typeof SET_DRAGGING_SOURCE;\n payload: number;\n};\n\ntype SetDraggingTargetAction = {\n type: typeof SET_DRAGGING_TARGET;\n payload: number;\n};\n\nexport type Actions =\n | ClearDraggingSourceAction\n | ClearDraggingTargetAction\n | DragEndAction\n | DragStartAction\n | DropAction\n | MoveToPositionAction\n | ResetAction\n | SetCloneAction\n | SetDraggingSourceAction\n | SetDraggingTargetAction;\n\nexport const setClone = (payload: SetCloneAction['payload']): SetCloneAction => ({\n type: SET_CLONE,\n payload,\n});\n\nexport const clearDraggingSource = (): ClearDraggingSourceAction => ({ type: CLEAR_DRAGGING_SOURCE });\n\nexport const clearDraggingTarget = (): ClearDraggingTargetAction => ({ type: CLEAR_DRAGGING_TARGET });\n\nexport const dragEnd = (): DragEndAction => ({ type: DRAG_END });\n\nexport const dragStart = (draggingItemIndex: DragStartAction['payload']): DragStartAction => ({\n type: DRAG_START,\n payload: draggingItemIndex,\n});\n\nexport const drop = (targetItemIndex: DropAction['payload']): DropAction => ({\n type: DROP,\n payload: targetItemIndex,\n});\n\nexport const moveToPosition = (targetItemIndex: MoveToPositionAction['payload']): MoveToPositionAction => ({\n type: MOVE_TO_POSITION,\n payload: targetItemIndex,\n});\n\nexport const reset = (): ResetAction => ({ type: RESET });\n\nexport const setDraggingSource = (sourceItemIndex: SetDraggingSourceAction['payload']): SetDraggingSourceAction => ({\n type: SET_DRAGGING_SOURCE,\n payload: sourceItemIndex,\n});\n\nexport const setDraggingTarget = (targetItemIndex: SetDraggingTargetAction['payload']): SetDraggingTargetAction => ({\n type: SET_DRAGGING_TARGET,\n payload: targetItemIndex,\n});\n"],"names":["setClone","payload","SET_CLONE","clearDraggingSource","CLEAR_DRAGGING_SOURCE","clearDraggingTarget","CLEAR_DRAGGING_TARGET","dragEnd","DRAG_END","dragStart","draggingItemIndex","DRAG_START","drop","targetItemIndex","DROP","moveToPosition","MOVE_TO_POSITION","reset","RESET","setDraggingSource","sourceItemIndex","SET_DRAGGING_SOURCE","setDraggingTarget","SET_DRAGGING_TARGET"],"mappings":";AAuEa,MAAAA,IAAW,CAACC,OAAwD;AAAA,EAC/E,MAAMC;AAAA,EACN,SAAAD;AACF,IAEaE,IAAsB,OAAkC,EAAE,MAAMC,MAEhEC,IAAsB,OAAkC,EAAE,MAAMC,MAEhEC,IAAU,OAAsB,EAAE,MAAMC,MAExCC,IAAY,CAACC,OAAoE;AAAA,EAC5F,MAAMC;AAAA,EACN,SAASD;AACX,IAEaE,IAAO,CAACC,OAAwD;AAAA,EAC3E,MAAMC;AAAA,EACN,SAASD;AACX,IAEaE,IAAiB,CAACF,OAA4E;AAAA,EACzG,MAAMG;AAAA,EACN,SAASH;AACX,IAEaI,IAAQ,OAAoB,EAAE,MAAMC,MAEpCC,IAAoB,CAACC,OAAkF;AAAA,EAClH,MAAMC;AAAA,EACN,SAASD;AACX,IAEaE,IAAoB,CAACT,OAAkF;AAAA,EAClH,MAAMU;AAAA,EACN,SAASV;AACX;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type OnSort = (indices: number[]) => void;
|
|
2
|
+
interface SortableContainerProps {
|
|
3
|
+
scrollable?: boolean;
|
|
4
|
+
onSort?: OnSort;
|
|
5
|
+
}
|
|
6
|
+
export declare function SortableContainer({ scrollable, onSort }: SortableContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "../../../clsx-OuTLNxxd.js";
|
|
4
|
+
import "../../../Sortable.module-BrgGu8qp.js";
|
|
5
|
+
import { a } from "../../../SortableProvider-Z0e0qeQT.js";
|
|
6
|
+
export {
|
|
7
|
+
a as SortableContainer
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=SortableContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableContainer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Icon as e } from "../../Icon/Icon.js";
|
|
3
|
+
import { s as t } from "../../../Sortable.module-BrgGu8qp.js";
|
|
4
|
+
const r = "ontouchstart" in globalThis.document.documentElement;
|
|
5
|
+
function m({ placement: n }) {
|
|
6
|
+
return r ? null : /* @__PURE__ */ o("div", { className: `${t.sortable__handle} ${t[`sortable__handle--${n}`]}`, children: /* @__PURE__ */ o(e, { name: "Dots" }) });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
m as SortableHandle
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=SortableHandle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableHandle.js","sources":["../../../../src/components/Sortable/components/SortableHandle.tsx"],"sourcesContent":["import { Icon } from 'components/Icon';\nimport styles from 'components/Sortable/Sortable.module.css';\n\nexport interface SortableHandleProps {\n placement: 'left' | 'right';\n}\n\nconst noSupportTouch = 'ontouchstart' in globalThis.document.documentElement;\n\nexport function SortableHandle({ placement }: SortableHandleProps) {\n if (noSupportTouch) return null;\n\n return (\n <div className={`${styles['sortable__handle']} ${styles[`sortable__handle--${placement}`]}`}>\n <Icon name=\"Dots\" />\n </div>\n );\n}\n"],"names":["noSupportTouch","SortableHandle","placement","styles","Icon"],"mappings":";;;AAOA,MAAMA,IAAiB,kBAAkB,WAAW,SAAS;AAE7C,SAAAC,EAAe,EAAE,WAAAC,KAAkC;AACjE,SAAIF,IAAuB,yBAGxB,OAAI,EAAA,WAAW,GAAGG,EAAO,gBAAmB,IAAIA,EAAO,qBAAqBD,CAAS,EAAE,CAAC,IACvF,4BAACE,GAAK,EAAA,MAAK,QAAO,EACpB,CAAA;AAEJ;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SortableHandleProps } from './SortableHandle';
|
|
3
|
+
export interface SortableItemProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
handlePlacement: SortableHandleProps['placement'];
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
index: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function SortableItem({ children, handlePlacement, disabled, index }: SortableItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsxs as i, jsx as r, Fragment as v } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useRef as M, useEffect as Q } from "react";
|
|
3
|
+
import { Icon as w } from "../../Icon/Icon.js";
|
|
4
|
+
import { SortableHandle as E } from "./SortableHandle.js";
|
|
5
|
+
import { s as t } from "../../../Sortable.module-BrgGu8qp.js";
|
|
6
|
+
import { u as k } from "../../../SortableProvider-Z0e0qeQT.js";
|
|
7
|
+
const G = ["Space", "ArrowDown", "ArrowUp"], J = "ontouchstart" in globalThis.document.documentElement, C = new Image(0, 0);
|
|
8
|
+
C.src = // 1px transparent png
|
|
9
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";
|
|
10
|
+
function L({ children: D, handlePlacement: u, disabled: _, index: e }) {
|
|
11
|
+
const {
|
|
12
|
+
clone: h,
|
|
13
|
+
dragEnd: m,
|
|
14
|
+
draggingSource: c,
|
|
15
|
+
draggingTarget: f,
|
|
16
|
+
dragStart: g,
|
|
17
|
+
drop: N,
|
|
18
|
+
maxIndex: p,
|
|
19
|
+
moveToPosition: T,
|
|
20
|
+
setClone: I,
|
|
21
|
+
setDraggingSource: U
|
|
22
|
+
} = k(), [$, A] = S(!1), [y, d] = S(!1), n = M(null), s = e !== void 0 && e >= 0;
|
|
23
|
+
Q(() => {
|
|
24
|
+
n.current && globalThis.document.activeElement !== n.current && (e === f && f === c ? (n.current.focus(), d(!0)) : d(!1));
|
|
25
|
+
}, [e, f, c, U]);
|
|
26
|
+
function K(a) {
|
|
27
|
+
if (a.stopPropagation(), a.dataTransfer.effectAllowed = "move", a.dataTransfer.setDragImage(C, 0, 0), n.current) {
|
|
28
|
+
const o = n.current.cloneNode(!0);
|
|
29
|
+
o.classList.add(t["sortable__sort-item--ghost"]), I(o);
|
|
30
|
+
}
|
|
31
|
+
s && g(e), A(!0);
|
|
32
|
+
}
|
|
33
|
+
function R() {
|
|
34
|
+
$ || (h && document.body.removeChild(h), A(!1), m());
|
|
35
|
+
}
|
|
36
|
+
function B(a) {
|
|
37
|
+
const { code: o } = a;
|
|
38
|
+
if (o === "Tab" && c !== void 0) {
|
|
39
|
+
m();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (G.includes(o) === !1 || !s) return;
|
|
43
|
+
if (o === "Space") {
|
|
44
|
+
y ? (d(!1), m()) : (d(!0), g(e));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (c === void 0) return;
|
|
48
|
+
const l = o === "ArrowUp" ? e - 1 : e + 1;
|
|
49
|
+
l < 0 || l > p || T(l);
|
|
50
|
+
}
|
|
51
|
+
function b(a) {
|
|
52
|
+
if (a.preventDefault(), !s) return;
|
|
53
|
+
g(e);
|
|
54
|
+
const { direction: o } = a.currentTarget.dataset, l = o === "up" ? e - 1 : e + 1;
|
|
55
|
+
N(l);
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ i(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
className: t["sortable__sort-item"],
|
|
61
|
+
draggable: !_,
|
|
62
|
+
onDragEnd: R,
|
|
63
|
+
onDragStart: K,
|
|
64
|
+
onKeyUpCapture: B,
|
|
65
|
+
ref: n,
|
|
66
|
+
role: "presentation",
|
|
67
|
+
tabIndex: 0,
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ i(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
className: `${t["sortable__sort-item__contents"]} ${t[`sortable__sort-item__contents--handle-${u}`]}`,
|
|
73
|
+
children: [
|
|
74
|
+
u === "left" && /* @__PURE__ */ r(E, { placement: "left" }),
|
|
75
|
+
D,
|
|
76
|
+
u === "right" && /* @__PURE__ */ r(E, { placement: "right" })
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ r("div", { className: t["sortable__sort-item__button-container"], "data-touch": J, children: !_ && s && /* @__PURE__ */ r(v, { children: s && /* @__PURE__ */ i(v, { children: [
|
|
81
|
+
e > 0 && /* @__PURE__ */ i(
|
|
82
|
+
"button",
|
|
83
|
+
{
|
|
84
|
+
className: `${t["sortable__sort-item__handle"]} ${t["sortable__sort-item__handle--up"]}`,
|
|
85
|
+
"data-direction": "up",
|
|
86
|
+
onClickCapture: b,
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ r("div", { className: t["sortable__sort-item__handle--icon"], children: /* @__PURE__ */ r(w, { name: "CheveronDown" }) }),
|
|
89
|
+
/* @__PURE__ */ r("span", { className: t["sortable__visually-hidden"], children: "Move up" })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
e < p && /* @__PURE__ */ i(
|
|
94
|
+
"button",
|
|
95
|
+
{
|
|
96
|
+
className: `${t["sortable__sort-item__handle"]} ${t["sortable__sort-item__handle--down"]}`,
|
|
97
|
+
"data-direction": "down",
|
|
98
|
+
onClickCapture: b,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ r("div", { className: t["sortable__sort-item__handle--icon"], children: /* @__PURE__ */ r(w, { name: "CheveronDown" }) }),
|
|
101
|
+
/* @__PURE__ */ r("span", { className: t["sortable__visually-hidden"], children: "Move down" })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }) }) })
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
L as SortableItem
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=SortableItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortableItem.js","sources":["../../../../src/components/Sortable/components/SortableItem.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { DragEvent, MouseEvent, KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\nimport type { SortableHandleProps } from './SortableHandle';\n\nimport { Icon } from 'components/Icon';\nimport { SortableHandle } from 'components/Sortable/components/SortableHandle';\nimport styles from 'components/Sortable/Sortable.module.css';\nimport { useSortable } from 'components/Sortable/SortableProvider';\n\nexport interface SortableItemProps {\n children: ReactNode;\n handlePlacement: SortableHandleProps['placement'];\n disabled?: boolean;\n index: number;\n}\n\nconst ACCESS_KEYS = ['Space', 'ArrowDown', 'ArrowUp'];\nconst noSupportTouch = 'ontouchstart' in globalThis.document.documentElement;\nconst dragImage = new Image(0, 0);\n\ndragImage.src =\n // 1px transparent png\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';\n\nexport function SortableItem({ children, handlePlacement, disabled, index }: SortableItemProps) {\n const {\n clone,\n dragEnd,\n draggingSource,\n draggingTarget,\n dragStart,\n drop,\n maxIndex,\n moveToPosition,\n setClone,\n setDraggingSource,\n } = useSortable();\n const [grabbing, setGrabbing] = useState(false);\n const [moving, setmoving] = useState(false);\n const itemRef = useRef<HTMLDivElement>(null);\n const hasIndex = index !== undefined && index >= 0;\n\n useEffect(() => {\n if (!itemRef.current) return;\n if (globalThis.document.activeElement === itemRef.current) return;\n\n if (index === draggingTarget && draggingTarget === draggingSource) {\n // Manually setting focus after an item has been moved with the keyboard; focus is lost after rerender\n itemRef.current.focus();\n setmoving(true);\n } else {\n setmoving(false);\n }\n }, [index, draggingTarget, draggingSource, setDraggingSource]);\n\n function handleDragStart(event: DragEvent<HTMLDivElement>) {\n event.stopPropagation();\n\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setDragImage(dragImage, 0, 0);\n\n if (itemRef.current) {\n const cloned = itemRef.current.cloneNode(true) as Element;\n\n cloned.classList.add(styles['sortable__sort-item--ghost']);\n\n setClone(cloned);\n }\n\n if (hasIndex) dragStart(index);\n setGrabbing(true);\n }\n\n function handleDragEnd() {\n if (grabbing) return;\n\n if (clone) document.body.removeChild(clone);\n\n setGrabbing(false);\n dragEnd();\n }\n\n function handleKeyUp(event: ReactKeyboardEvent<HTMLDivElement>) {\n const { code } = event;\n\n if (code === 'Tab' && draggingSource !== undefined) {\n dragEnd();\n return;\n }\n\n if (ACCESS_KEYS.includes(code) === false) return;\n\n if (!hasIndex) return;\n\n if (code === 'Space') {\n if (moving) {\n setmoving(false);\n dragEnd();\n } else {\n setmoving(true);\n dragStart(index);\n }\n\n return;\n }\n\n if (draggingSource === undefined) return;\n\n const newTarget = code === 'ArrowUp' ? index - 1 : index + 1;\n\n if (newTarget < 0 || newTarget > maxIndex) return;\n\n moveToPosition(newTarget);\n }\n\n function handleMove(event: MouseEvent<HTMLButtonElement>) {\n event.preventDefault();\n\n if (!hasIndex) return;\n\n dragStart(index);\n\n const { direction } = event.currentTarget.dataset;\n const newTarget = direction === 'up' ? index - 1 : index + 1;\n\n drop(newTarget);\n }\n\n return (\n <div\n className={styles['sortable__sort-item']}\n draggable={!disabled}\n onDragEnd={handleDragEnd}\n onDragStart={handleDragStart}\n onKeyUpCapture={handleKeyUp}\n ref={itemRef}\n role=\"presentation\"\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n >\n <div\n className={`${styles['sortable__sort-item__contents']} ${styles[`sortable__sort-item__contents--handle-${handlePlacement}`]}`}\n >\n {handlePlacement === 'left' && <SortableHandle placement=\"left\" />}\n {children}\n {handlePlacement === 'right' && <SortableHandle placement=\"right\" />}\n </div>\n\n <div className={styles['sortable__sort-item__button-container']} data-touch={noSupportTouch}>\n {!disabled && hasIndex && (\n <>\n {hasIndex && (\n <>\n {index > 0 && (\n <button\n className={`${styles['sortable__sort-item__handle']} ${styles['sortable__sort-item__handle--up']}`}\n data-direction=\"up\"\n onClickCapture={handleMove}\n >\n <div className={styles['sortable__sort-item__handle--icon']}>\n <Icon name=\"CheveronDown\" />\n </div>\n <span className={styles['sortable__visually-hidden']}>Move up</span>\n </button>\n )}\n\n {index < maxIndex && (\n <button\n className={`${styles['sortable__sort-item__handle']} ${styles['sortable__sort-item__handle--down']}`}\n data-direction=\"down\"\n onClickCapture={handleMove}\n >\n <div className={styles['sortable__sort-item__handle--icon']}>\n <Icon name=\"CheveronDown\" />\n </div>\n <span className={styles['sortable__visually-hidden']}>Move down</span>\n </button>\n )}\n </>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n"],"names":["ACCESS_KEYS","noSupportTouch","dragImage","SortableItem","children","handlePlacement","disabled","index","clone","dragEnd","draggingSource","draggingTarget","dragStart","drop","maxIndex","moveToPosition","setClone","setDraggingSource","useSortable","grabbing","setGrabbing","useState","moving","setmoving","itemRef","useRef","hasIndex","useEffect","handleDragStart","event","cloned","styles","handleDragEnd","handleKeyUp","code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AAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const CLEAR_DRAGGING_SOURCE = "CLEAR_DRAGGING_SOURCE";
|
|
2
|
+
export declare const CLEAR_DRAGGING_TARGET = "CLEAR_DRAGGING_TARGET";
|
|
3
|
+
export declare const DRAG_END = "DRAG_END";
|
|
4
|
+
export declare const DRAG_START = "DRAG_START";
|
|
5
|
+
export declare const DROP = "DROP";
|
|
6
|
+
export declare const MOVE_TO_POSITION = "MOVE_TO_POSITION";
|
|
7
|
+
export declare const RESET = "RESET";
|
|
8
|
+
export declare const SET_CLONE = "SET_CLONE";
|
|
9
|
+
export declare const SET_DRAGGING_SOURCE = "SET_DRAGGING_SOURCE";
|
|
10
|
+
export declare const SET_DRAGGING_TARGET = "SET_DRAGGING_TARGET";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const G = "CLEAR_DRAGGING_SOURCE", R = "CLEAR_DRAGGING_TARGET", E = "DRAG_END", _ = "DRAG_START", T = "DROP", A = "MOVE_TO_POSITION", D = "RESET", O = "SET_CLONE", S = "SET_DRAGGING_SOURCE", N = "SET_DRAGGING_TARGET";
|
|
2
|
+
export {
|
|
3
|
+
G as CLEAR_DRAGGING_SOURCE,
|
|
4
|
+
R as CLEAR_DRAGGING_TARGET,
|
|
5
|
+
E as DRAG_END,
|
|
6
|
+
_ as DRAG_START,
|
|
7
|
+
T as DROP,
|
|
8
|
+
A as MOVE_TO_POSITION,
|
|
9
|
+
D as RESET,
|
|
10
|
+
O as SET_CLONE,
|
|
11
|
+
S as SET_DRAGGING_SOURCE,
|
|
12
|
+
N as SET_DRAGGING_TARGET
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/components/Sortable/constants.ts"],"sourcesContent":["export const CLEAR_DRAGGING_SOURCE = 'CLEAR_DRAGGING_SOURCE';\nexport const CLEAR_DRAGGING_TARGET = 'CLEAR_DRAGGING_TARGET';\nexport const DRAG_END = 'DRAG_END';\nexport const DRAG_START = 'DRAG_START';\nexport const DROP = 'DROP';\nexport const MOVE_TO_POSITION = 'MOVE_TO_POSITION';\nexport const RESET = 'RESET';\nexport const SET_CLONE = 'SET_CLONE';\nexport const SET_DRAGGING_SOURCE = 'SET_DRAGGING_SOURCE';\nexport const SET_DRAGGING_TARGET = 'SET_DRAGGING_TARGET';\n"],"names":["CLEAR_DRAGGING_SOURCE","CLEAR_DRAGGING_TARGET","DRAG_END","DRAG_START","DROP","MOVE_TO_POSITION","RESET","SET_CLONE","SET_DRAGGING_SOURCE","SET_DRAGGING_TARGET"],"mappings":"AAAO,MAAMA,IAAwB,yBACxBC,IAAwB,yBACxBC,IAAW,YACXC,IAAa,cACbC,IAAO,QACPC,IAAmB,oBACnBC,IAAQ,SACRC,IAAY,aACZC,IAAsB,uBACtBC,IAAsB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Sortable';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { Actions } from './actions';
|
|
3
|
+
import { SortableItem, SortableItemProps } from './components/SortableItem';
|
|
4
|
+
type SortableItems = ReactElement<SortableItemProps, typeof SortableItem>[];
|
|
5
|
+
export interface SortableStateType {
|
|
6
|
+
clone?: Element;
|
|
7
|
+
draggingSource?: number;
|
|
8
|
+
draggingTarget?: number;
|
|
9
|
+
indices: number[];
|
|
10
|
+
itemsBeforeDrag: SortableItems;
|
|
11
|
+
maxIndex: number;
|
|
12
|
+
sortableItems: SortableItems;
|
|
13
|
+
}
|
|
14
|
+
export declare const initialState: {
|
|
15
|
+
clone: undefined;
|
|
16
|
+
draggingSource: undefined;
|
|
17
|
+
draggingTarget: undefined;
|
|
18
|
+
indices: never[];
|
|
19
|
+
itemsBeforeDrag: never[];
|
|
20
|
+
maxIndex: number;
|
|
21
|
+
sortableItems: never[];
|
|
22
|
+
};
|
|
23
|
+
export declare const sortableReducer: (state: SortableStateType | undefined, action: Actions) => SortableStateType;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { CLEAR_DRAGGING_SOURCE as s, CLEAR_DRAGGING_TARGET as c, MOVE_TO_POSITION as l, SET_DRAGGING_SOURCE as u, SET_DRAGGING_TARGET as t, DROP as S, RESET as p, DRAG_END as T, DRAG_START as R, SET_CLONE as m } from "./constants.js";
|
|
3
|
+
const G = {
|
|
4
|
+
clone: void 0,
|
|
5
|
+
draggingSource: void 0,
|
|
6
|
+
draggingTarget: void 0,
|
|
7
|
+
indices: [],
|
|
8
|
+
itemsBeforeDrag: [],
|
|
9
|
+
maxIndex: 0,
|
|
10
|
+
sortableItems: []
|
|
11
|
+
}, d = (e, r, ...g) => (e === r || g.splice(r, 0, ...g.splice(e, 1)), g);
|
|
12
|
+
function E(e, r, ...g) {
|
|
13
|
+
return g.splice(e, 1), [...g.splice(r, 0, /* @__PURE__ */ n("span", {})), ...g];
|
|
14
|
+
}
|
|
15
|
+
const _ = (e = G, r) => {
|
|
16
|
+
const g = e;
|
|
17
|
+
switch (r.type) {
|
|
18
|
+
case m:
|
|
19
|
+
return {
|
|
20
|
+
...e,
|
|
21
|
+
clone: r.payload
|
|
22
|
+
};
|
|
23
|
+
case R:
|
|
24
|
+
return {
|
|
25
|
+
...e,
|
|
26
|
+
draggingSource: r.payload,
|
|
27
|
+
itemsBeforeDrag: e.sortableItems
|
|
28
|
+
};
|
|
29
|
+
case T:
|
|
30
|
+
return {
|
|
31
|
+
...e,
|
|
32
|
+
draggingSource: void 0,
|
|
33
|
+
draggingTarget: void 0
|
|
34
|
+
};
|
|
35
|
+
case p:
|
|
36
|
+
return {
|
|
37
|
+
...e,
|
|
38
|
+
draggingTarget: void 0,
|
|
39
|
+
sortableItems: e.itemsBeforeDrag
|
|
40
|
+
};
|
|
41
|
+
case S: {
|
|
42
|
+
const o = d(g.draggingSource, r.payload, ...e.itemsBeforeDrag), i = o.map(({ props: a }) => a.index);
|
|
43
|
+
return {
|
|
44
|
+
...e,
|
|
45
|
+
clone: void 0,
|
|
46
|
+
draggingSource: void 0,
|
|
47
|
+
draggingTarget: void 0,
|
|
48
|
+
indices: i,
|
|
49
|
+
sortableItems: o
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
case t:
|
|
53
|
+
return {
|
|
54
|
+
...e,
|
|
55
|
+
draggingTarget: r.payload,
|
|
56
|
+
sortableItems: E(
|
|
57
|
+
g.draggingSource,
|
|
58
|
+
r.payload,
|
|
59
|
+
...e.itemsBeforeDrag
|
|
60
|
+
)
|
|
61
|
+
};
|
|
62
|
+
case u:
|
|
63
|
+
return {
|
|
64
|
+
...e,
|
|
65
|
+
draggingSource: r.payload
|
|
66
|
+
};
|
|
67
|
+
case l:
|
|
68
|
+
return {
|
|
69
|
+
...e,
|
|
70
|
+
draggingTarget: r.payload,
|
|
71
|
+
draggingSource: r.payload,
|
|
72
|
+
sortableItems: d(g.draggingSource, r.payload, ...e.sortableItems)
|
|
73
|
+
};
|
|
74
|
+
case c:
|
|
75
|
+
return {
|
|
76
|
+
...e,
|
|
77
|
+
draggingTarget: void 0
|
|
78
|
+
};
|
|
79
|
+
case s:
|
|
80
|
+
return {
|
|
81
|
+
...e,
|
|
82
|
+
draggingSource: void 0
|
|
83
|
+
};
|
|
84
|
+
default:
|
|
85
|
+
return e;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
G as initialState,
|
|
90
|
+
_ as sortableReducer
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=sortableReducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortableReducer.js","sources":["../../../src/components/Sortable/sortableReducer.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Actions } from './actions';\nimport type { SortableItem, SortableItemProps } from './components/SortableItem';\n\nimport {\n CLEAR_DRAGGING_SOURCE,\n CLEAR_DRAGGING_TARGET,\n DRAG_END,\n DRAG_START,\n DROP,\n MOVE_TO_POSITION,\n RESET,\n SET_CLONE,\n SET_DRAGGING_SOURCE,\n SET_DRAGGING_TARGET,\n} from './constants';\n\ntype SortableItems = ReactElement<SortableItemProps, typeof SortableItem>[];\n\nexport interface SortableStateType {\n clone?: Element;\n draggingSource?: number;\n draggingTarget?: number;\n indices: number[];\n itemsBeforeDrag: SortableItems;\n maxIndex: number;\n sortableItems: SortableItems;\n}\n\n// When dragging has started, draggingSource is a number value and not undefined any more\ntype SortableStateWithSource = SortableStateType & {\n draggingSource: number;\n};\n\nexport const initialState = {\n clone: undefined,\n draggingSource: undefined,\n draggingTarget: undefined,\n indices: [],\n itemsBeforeDrag: [],\n maxIndex: 0,\n sortableItems: [],\n};\n\nconst getReorderedList = (from: number, to: number, ...arr: SortableItems) =>\n from === to ? arr : (arr.splice(to, 0, ...arr.splice(from, 1)), arr);\n\nfunction getReorderedListWithPlaceholder(from: number, to: number, ...arr: SortableItems) {\n arr.splice(from, 1);\n\n return [...arr.splice(to, 0, <span />), ...arr];\n}\n\nexport const sortableReducer = (state: SortableStateType = initialState, action: Actions): SortableStateType => {\n const stateWithSource = state as SortableStateWithSource;\n\n switch (action.type) {\n case SET_CLONE: {\n return {\n ...state,\n clone: action.payload,\n };\n }\n\n case DRAG_START: {\n return {\n ...state,\n draggingSource: action.payload,\n itemsBeforeDrag: state.sortableItems,\n };\n }\n\n case DRAG_END: {\n return {\n ...state,\n draggingSource: undefined,\n draggingTarget: undefined,\n };\n }\n\n case RESET: {\n return {\n ...state,\n draggingTarget: undefined,\n sortableItems: state.itemsBeforeDrag,\n };\n }\n\n case DROP: {\n const sortableItems = getReorderedList(stateWithSource.draggingSource, action.payload, ...state.itemsBeforeDrag);\n const indices = sortableItems.map(({ props }) => props.index);\n\n return {\n ...state,\n clone: undefined,\n draggingSource: undefined,\n draggingTarget: undefined,\n indices,\n sortableItems,\n };\n }\n\n case SET_DRAGGING_TARGET: {\n return {\n ...state,\n draggingTarget: action.payload,\n sortableItems: getReorderedListWithPlaceholder(\n stateWithSource.draggingSource,\n action.payload,\n ...state.itemsBeforeDrag\n ),\n };\n }\n\n case SET_DRAGGING_SOURCE: {\n return {\n ...state,\n draggingSource: action.payload,\n };\n }\n\n case MOVE_TO_POSITION: {\n return {\n ...state,\n draggingTarget: action.payload,\n draggingSource: action.payload,\n sortableItems: getReorderedList(stateWithSource.draggingSource, action.payload, ...state.sortableItems),\n };\n }\n\n case CLEAR_DRAGGING_TARGET:\n return {\n ...state,\n draggingTarget: undefined,\n };\n\n case CLEAR_DRAGGING_SOURCE:\n return {\n ...state,\n draggingSource: undefined,\n };\n\n default:\n return state;\n }\n};\n"],"names":["initialState","getReorderedList","from","to","arr","getReorderedListWithPlaceholder","jsx","sortableReducer","state","action","stateWithSource","SET_CLONE","DRAG_START","DRAG_END","RESET","DROP","sortableItems","indices","props","SET_DRAGGING_TARGET","SET_DRAGGING_SOURCE","MOVE_TO_POSITION","CLEAR_DRAGGING_TARGET","CLEAR_DRAGGING_SOURCE"],"mappings":";;AAkCO,MAAMA,IAAe;AAAA,EAC1B,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,SAAS,CAAC;AAAA,EACV,iBAAiB,CAAC;AAAA,EAClB,UAAU;AAAA,EACV,eAAe,CAAC;AAClB,GAEMC,IAAmB,CAACC,GAAcC,MAAeC,OACrDF,MAASC,KAAYC,EAAI,OAAOD,GAAI,GAAG,GAAGC,EAAI,OAAOF,GAAM,CAAC,CAAC,GAAGE;AAElE,SAASC,EAAgCH,GAAcC,MAAeC,GAAoB;AACpF,SAAAA,EAAA,OAAOF,GAAM,CAAC,GAEX,CAAC,GAAGE,EAAI,OAAOD,GAAI,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EAAO;AAAA,QACvB,gBAAgBA,EAAO;AAAA,QACvB,eAAeR,EAAiBS,EAAgB,gBAAgBD,EAAO,SAAS,GAAGD,EAAM,aAAa;AAAA,MAAA;AAAA,IAI1G,KAAKc;AACI,aAAA;AAAA,QACL,GAAGd;AAAA,QACH,gBAAgB;AAAA,MAAA;AAAA,IAGpB,KAAKe;AACI,aAAA;AAAA,QACL,GAAGf;AAAA,QACH,gBAAgB;AAAA,MAAA;AAAA,IAGpB;AACS,aAAAA;AAAA,EACX;AACF;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect as r } from "react";
|
|
2
|
+
const u = (e, n) => {
|
|
3
|
+
r(() => {
|
|
4
|
+
const t = (o) => {
|
|
5
|
+
!e.current || e.current.contains(o.target) || n(o);
|
|
6
|
+
};
|
|
7
|
+
return document.addEventListener("mousedown", t), document.addEventListener("touchstart", t), () => {
|
|
8
|
+
document.removeEventListener("mousedown", t), document.removeEventListener("touchstart", t);
|
|
9
|
+
};
|
|
10
|
+
}, [e, n]);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
u as useOnClickOutside
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useOnClickOuside.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnClickOuside.js","sources":["../../../src/components/hooks/useOnClickOuside.ts"],"sourcesContent":["import { type RefObject, useEffect } from 'react';\n\ntype Handler = (event: MouseEvent | TouchEvent | KeyboardEvent) => void;\n\nexport const useOnClickOutside = <T extends HTMLElement = HTMLElement>(ref: RefObject<T>, handler: Handler): void => {\n useEffect(() => {\n const listener = (\n event:\n | (MouseEvent & { target: HTMLElement | null })\n | (TouchEvent & { target: HTMLElement | null })\n | (KeyboardEvent & { target: HTMLElement | null })\n ): void => {\n if (!ref.current || ref.current.contains(event.target as Node)) {\n return;\n }\n handler(event as MouseEvent | TouchEvent | KeyboardEvent);\n };\n document.addEventListener('mousedown', listener as EventListener);\n document.addEventListener('touchstart', listener as EventListener);\n return () => {\n document.removeEventListener('mousedown', listener as EventListener);\n document.removeEventListener('touchstart', listener as EventListener);\n };\n }, [ref, handler]);\n};\n"],"names":["useOnClickOutside","ref","handler","useEffect","listener","event"],"mappings":";AAIa,MAAAA,IAAoB,CAAsCC,GAAmBC,MAA2B;AACnH,EAAAC,EAAU,MAAM;AACR,UAAAC,IAAW,CACfC,MAIS;AACL,MAAA,CAACJ,EAAI,WAAWA,EAAI,QAAQ,SAASI,EAAM,MAAc,KAG7DH,EAAQG,CAAgD;AAAA,IAAA;AAEjD,oBAAA,iBAAiB,aAAaD,CAAyB,GACvD,SAAA,iBAAiB,cAAcA,CAAyB,GAC1D,MAAM;AACF,eAAA,oBAAoB,aAAaA,CAAyB,GAC1D,SAAA,oBAAoB,cAAcA,CAAyB;AAAA,IAAA;AAAA,EACtE,GACC,CAACH,GAAKC,CAAO,CAAC;AACnB;"}
|
|
@@ -29,6 +29,7 @@ export * from './MetaDataList';
|
|
|
29
29
|
export * from './ModalDialog';
|
|
30
30
|
export * from './MultiSelect';
|
|
31
31
|
export * from './OverlayCloseButton';
|
|
32
|
+
export * from './PageOverlay';
|
|
32
33
|
export * from './Periods';
|
|
33
34
|
export * from './PeriodSelector';
|
|
34
35
|
export * from './ProgrammeCard';
|
|
@@ -39,5 +40,6 @@ export * from './SectionNotification';
|
|
|
39
40
|
export * from './SelectListbox';
|
|
40
41
|
export * from './SelectListbox/SelectProvider';
|
|
41
42
|
export * from './Spinner';
|
|
43
|
+
export * from './Sortable';
|
|
42
44
|
export * from './StatusPill';
|
|
43
45
|
export * from './Tooltip';
|