@elliemae/ds-toolbar 3.1.0-next.2 → 3.1.0-next.20
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/cjs/DSToolbarItemV2.js +32 -8
- package/dist/cjs/DSToolbarItemV2.js.map +2 -2
- package/dist/cjs/DSToolbarV2.js +14 -16
- package/dist/cjs/DSToolbarV2.js.map +2 -2
- package/dist/cjs/DSToolbarV2Context.js +4 -1
- package/dist/cjs/DSToolbarV2Context.js.map +2 -2
- package/dist/cjs/deprecated/DSToolbar.js +14 -20
- package/dist/cjs/deprecated/DSToolbar.js.map +2 -2
- package/dist/cjs/deprecated/ToolbarGroup.js.map +1 -1
- package/dist/cjs/deprecated/hooks/useKeyboardNavigation.js +64 -0
- package/dist/cjs/deprecated/hooks/useKeyboardNavigation.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +69 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/styled.js +6 -6
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/useToolbarItemHandlers.js +6 -3
- package/dist/cjs/useToolbarItemHandlers.js.map +2 -2
- package/dist/esm/DSToolbarItemV2.js +37 -8
- package/dist/esm/DSToolbarItemV2.js.map +2 -2
- package/dist/esm/DSToolbarV2.js +16 -14
- package/dist/esm/DSToolbarV2.js.map +2 -2
- package/dist/esm/DSToolbarV2Context.js +4 -1
- package/dist/esm/DSToolbarV2Context.js.map +2 -2
- package/dist/esm/deprecated/DSToolbar.js +7 -13
- package/dist/esm/deprecated/DSToolbar.js.map +2 -2
- package/dist/esm/deprecated/ToolbarGroup.js.map +1 -1
- package/dist/esm/deprecated/hooks/useKeyboardNavigation.js +42 -0
- package/dist/esm/deprecated/hooks/useKeyboardNavigation.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +49 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/styled.js +3 -3
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/useToolbarItemHandlers.js +6 -3
- package/dist/esm/useToolbarItemHandlers.js.map +2 -2
- package/package.json +22 -22
- package/dist/cjs/props.js +0 -34
- package/dist/cjs/props.js.map +0 -7
- package/dist/esm/props.js +0 -12
- package/dist/esm/props.js.map +0 -7
|
@@ -14,28 +14,57 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
17
29
|
import * as React from "react";
|
|
18
30
|
import React2, { useContext, useMemo, useRef } from "react";
|
|
31
|
+
import {
|
|
32
|
+
describe,
|
|
33
|
+
useMemoMergePropsWithDefault,
|
|
34
|
+
useValidateTypescriptPropTypes,
|
|
35
|
+
useGetGlobalAttributes
|
|
36
|
+
} from "@elliemae/ds-utilities";
|
|
19
37
|
import { uid } from "uid";
|
|
20
38
|
import { DSToolbarV2Context } from "./DSToolbarV2Context";
|
|
21
39
|
import { StyledToolbarItem } from "./styled";
|
|
22
40
|
import { useToolbarItemHandlers } from "./useToolbarItemHandlers";
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
import { defaultItemProps, DSToolbarItemV2Schema } from "./react-desc-prop-types";
|
|
42
|
+
const DSToolbarItemV2 = (props) => {
|
|
43
|
+
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultItemProps);
|
|
44
|
+
useValidateTypescriptPropTypes(propsWithDefaults, DSToolbarItemV2Schema);
|
|
45
|
+
const { render, isFirstItem } = propsWithDefaults;
|
|
46
|
+
const _a = useGetGlobalAttributes(propsWithDefaults), { id } = _a, restGlobals = __objRest(_a, ["id"]);
|
|
47
|
+
const { registerReference, activeItem } = useContext(DSToolbarV2Context);
|
|
25
48
|
const ref = useRef(null);
|
|
26
49
|
const toolbarItemId = useMemo(() => {
|
|
27
|
-
const
|
|
28
|
-
registerReference(
|
|
29
|
-
return
|
|
50
|
+
const id2 = `ds-toolbar-item-${uid()}`;
|
|
51
|
+
registerReference(id2, ref);
|
|
52
|
+
return id2;
|
|
30
53
|
}, [registerReference, ref]);
|
|
54
|
+
const tabIndex = useMemo(() => activeItem === toolbarItemId || !activeItem && isFirstItem ? 0 : -1, [activeItem, isFirstItem, toolbarItemId]);
|
|
31
55
|
const handlers = useToolbarItemHandlers(toolbarItemId);
|
|
32
|
-
return /* @__PURE__ */ React2.createElement(StyledToolbarItem, __spreadValues({
|
|
56
|
+
return /* @__PURE__ */ React2.createElement(StyledToolbarItem, __spreadValues(__spreadValues({
|
|
33
57
|
id: toolbarItemId,
|
|
34
58
|
"data-testid": "ds-toolbar-item",
|
|
35
59
|
className: "ds-toolbar-item"
|
|
36
|
-
}, handlers), render({ innerRef: ref }));
|
|
60
|
+
}, handlers), restGlobals), render({ innerRef: ref, tabIndex }));
|
|
37
61
|
};
|
|
62
|
+
DSToolbarItemV2.propTypes = DSToolbarItemV2Schema;
|
|
63
|
+
DSToolbarItemV2.displayName = "DSToolbarItemV2";
|
|
64
|
+
const DSToolbarItemV2WithSchema = describe(DSToolbarItemV2).description("Toolbar Item");
|
|
65
|
+
DSToolbarItemV2WithSchema.propTypes = DSToolbarItemV2Schema;
|
|
38
66
|
export {
|
|
39
|
-
DSToolbarItemV2
|
|
67
|
+
DSToolbarItemV2,
|
|
68
|
+
DSToolbarItemV2WithSchema
|
|
40
69
|
};
|
|
41
70
|
//# sourceMappingURL=DSToolbarItemV2.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSToolbarItemV2.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useContext, useMemo, useRef } from 'react';\nimport {\n describe,\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n useGetGlobalAttributes,\n} from '@elliemae/ds-utilities';\nimport { uid } from 'uid';\nimport { DSToolbarV2Context } from './DSToolbarV2Context';\nimport { StyledToolbarItem } from './styled';\nimport { useToolbarItemHandlers } from './useToolbarItemHandlers';\nimport { defaultItemProps, DSToolbarItemV2Schema } from './react-desc-prop-types';\nimport type { DSToolbarItemT } from './react-desc-prop-types';\nconst DSToolbarItemV2: React.ComponentType<DSToolbarItemT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultItemProps);\n\n useValidateTypescriptPropTypes(propsWithDefaults, DSToolbarItemV2Schema);\n const { render, isFirstItem } = propsWithDefaults;\n const { id, ...restGlobals } = useGetGlobalAttributes(propsWithDefaults);\n const { registerReference, activeItem } = useContext(DSToolbarV2Context);\n const ref = useRef(null);\n const toolbarItemId = useMemo(() => {\n const id = `ds-toolbar-item-${uid()}`;\n registerReference(id, ref);\n return id;\n }, [registerReference, ref]);\n\n const tabIndex = useMemo(\n () => (activeItem === toolbarItemId || (!activeItem && isFirstItem) ? 0 : -1),\n [activeItem, isFirstItem, toolbarItemId],\n );\n\n const handlers = useToolbarItemHandlers(toolbarItemId);\n return (\n <StyledToolbarItem\n id={toolbarItemId}\n data-testid=\"ds-toolbar-item\"\n className=\"ds-toolbar-item\"\n {...handlers}\n {...restGlobals}\n >\n {render({ innerRef: ref, tabIndex })}\n </StyledToolbarItem>\n );\n};\n\nDSToolbarItemV2.propTypes = DSToolbarItemV2Schema;\n\nDSToolbarItemV2.displayName = 'DSToolbarItemV2';\nconst DSToolbarItemV2WithSchema = describe(DSToolbarItemV2).description('Toolbar Item');\nDSToolbarItemV2WithSchema.propTypes = DSToolbarItemV2Schema;\n\nexport { DSToolbarItemV2, DSToolbarItemV2WithSchema };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AACA;AACA;AACA;AACA;AAEA,MAAM,kBAA6D,CAAC,UAAU;AAC5E,QAAM,oBAAoB,6BAA6B,OAAO,gBAAgB;AAE9E,iCAA+B,mBAAmB,qBAAqB;AACvE,QAAM,EAAE,QAAQ,gBAAgB;AAChC,QAA+B,4BAAuB,iBAAiB,GAA/D,SAAuB,IAAhB,wBAAgB,IAAhB,CAAP;AACR,QAAM,EAAE,mBAAmB,eAAe,WAAW,kBAAkB;AACvE,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,gBAAgB,QAAQ,MAAM;AAClC,UAAM,MAAK,mBAAmB,IAAI;AAClC,sBAAkB,KAAI,GAAG;AACzB,WAAO;AAAA,EACT,GAAG,CAAC,mBAAmB,GAAG,CAAC;AAE3B,QAAM,WAAW,QACf,MAAO,eAAe,iBAAkB,CAAC,cAAc,cAAe,IAAI,IAC1E,CAAC,YAAY,aAAa,aAAa,CACzC;AAEA,QAAM,WAAW,uBAAuB,aAAa;AACrD,SACE,qCAAC;AAAA,IACC,IAAI;AAAA,IACJ,eAAY;AAAA,IACZ,WAAU;AAAA,KACN,WACA,cAEH,OAAO,EAAE,UAAU,KAAK,SAAS,CAAC,CACrC;AAEJ;AAEA,gBAAgB,YAAY;AAE5B,gBAAgB,cAAc;AAC9B,MAAM,4BAA4B,SAAS,eAAe,EAAE,YAAY,cAAc;AACtF,0BAA0B,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSToolbarV2.js
CHANGED
|
@@ -19,41 +19,43 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import * as React from "react";
|
|
21
21
|
import React2, { useCallback, useMemo, useState } from "react";
|
|
22
|
-
import {
|
|
23
|
-
|
|
22
|
+
import {
|
|
23
|
+
useMemoMergePropsWithDefault,
|
|
24
|
+
useValidateTypescriptPropTypes,
|
|
25
|
+
useGetGlobalAttributes
|
|
26
|
+
} from "@elliemae/ds-utilities";
|
|
27
|
+
import { describe } from "@elliemae/ds-utilities";
|
|
24
28
|
import { uid } from "uid";
|
|
25
29
|
import { DSToolbarV2Context } from "./DSToolbarV2Context";
|
|
26
|
-
import { DSToolbarV2Schema } from "./
|
|
30
|
+
import { DSToolbarV2Schema, defaultProps } from "./react-desc-prop-types";
|
|
27
31
|
import { StyledToolbarWrapper } from "./styled";
|
|
28
32
|
const DSToolbarV2 = (props) => {
|
|
29
|
-
const
|
|
30
|
-
useValidateTypescriptPropTypes(
|
|
33
|
+
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);
|
|
34
|
+
useValidateTypescriptPropTypes(propsWithDefaults, DSToolbarV2Schema);
|
|
35
|
+
const { alignment, withDepth, compact, innerRef, children } = propsWithDefaults;
|
|
36
|
+
const globalsProps = useGetGlobalAttributes(propsWithDefaults);
|
|
31
37
|
const toolbarUid = useMemo(() => `ds-toolbar-${uid()}`, []);
|
|
32
38
|
const [itemReferences, setItemReferences] = useState({});
|
|
39
|
+
const [activeItem, setActiveItem] = useState("");
|
|
33
40
|
const registerReference = useCallback((itemId, ref) => {
|
|
34
41
|
setItemReferences((prevItemReferences) => __spreadProps(__spreadValues({}, prevItemReferences), { [itemId]: ref }));
|
|
35
42
|
}, [setItemReferences]);
|
|
43
|
+
const ctx = useMemo(() => ({ toolbarUid, registerReference, itemReferences, activeItem, setActiveItem }), [activeItem, itemReferences, registerReference, toolbarUid]);
|
|
36
44
|
return /* @__PURE__ */ React2.createElement(DSToolbarV2Context.Provider, {
|
|
37
|
-
value:
|
|
38
|
-
}, /* @__PURE__ */ React2.createElement(StyledToolbarWrapper, {
|
|
45
|
+
value: ctx
|
|
46
|
+
}, /* @__PURE__ */ React2.createElement(StyledToolbarWrapper, __spreadValues({
|
|
39
47
|
role: "toolbar",
|
|
40
48
|
"data-testid": "ds-toolbar-wrapper",
|
|
41
49
|
id: toolbarUid,
|
|
42
50
|
alignItems: "center",
|
|
43
51
|
justifyContent: alignment === "left" ? "flex-start" : "flex-end",
|
|
44
52
|
withDepth,
|
|
45
|
-
cols: React2.Children.map(children, () => ["auto"]),
|
|
46
53
|
gutter: "xxs2",
|
|
47
54
|
compact,
|
|
48
55
|
ref: innerRef
|
|
49
|
-
}, children));
|
|
56
|
+
}, globalsProps), children));
|
|
50
57
|
};
|
|
51
58
|
DSToolbarV2.propTypes = DSToolbarV2Schema;
|
|
52
|
-
DSToolbarV2.defaultProps = {
|
|
53
|
-
alignment: "right",
|
|
54
|
-
withDepth: true,
|
|
55
|
-
compact: false
|
|
56
|
-
};
|
|
57
59
|
DSToolbarV2.displayName = "DSToolbarV2";
|
|
58
60
|
const DSToolbarV2WithSchema = describe(DSToolbarV2).description("Toolbar");
|
|
59
61
|
DSToolbarV2WithSchema.propTypes = DSToolbarV2Schema;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSToolbarV2.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useCallback, useMemo, useState } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useCallback, useMemo, useState } from 'react';\nimport {\n useMemoMergePropsWithDefault,\n useValidateTypescriptPropTypes,\n useGetGlobalAttributes,\n} from '@elliemae/ds-utilities';\nimport { describe } from '@elliemae/ds-utilities';\nimport { uid } from 'uid';\nimport { DSToolbarV2Context } from './DSToolbarV2Context';\nimport { DSToolbarV2Schema, defaultProps } from './react-desc-prop-types';\nimport { StyledToolbarWrapper } from './styled';\nimport type { DSToolbarT } from './react-desc-prop-types';\n\nconst DSToolbarV2: React.ComponentType<DSToolbarT.Props> = (props) => {\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n\n useValidateTypescriptPropTypes(propsWithDefaults, DSToolbarV2Schema);\n\n const { alignment, withDepth, compact, innerRef, children } = propsWithDefaults;\n\n const globalsProps = useGetGlobalAttributes(propsWithDefaults);\n\n const toolbarUid = useMemo(() => `ds-toolbar-${uid()}`, []);\n\n const [itemReferences, setItemReferences] = useState({});\n const [activeItem, setActiveItem] = useState('');\n\n const registerReference = useCallback(\n (itemId: string, ref: React.MutableRefObject<HTMLElement>) => {\n setItemReferences((prevItemReferences) => ({ ...prevItemReferences, [itemId]: ref }));\n },\n [setItemReferences],\n );\n\n const ctx = useMemo(\n () => ({ toolbarUid, registerReference, itemReferences, activeItem, setActiveItem }),\n [activeItem, itemReferences, registerReference, toolbarUid],\n );\n\n return (\n <DSToolbarV2Context.Provider value={ctx}>\n <StyledToolbarWrapper\n role=\"toolbar\"\n data-testid=\"ds-toolbar-wrapper\"\n id={toolbarUid}\n alignItems=\"center\"\n justifyContent={alignment === 'left' ? 'flex-start' : 'flex-end'}\n withDepth={withDepth}\n gutter=\"xxs2\"\n compact={compact}\n ref={innerRef}\n {...globalsProps}\n >\n {children}\n </StyledToolbarWrapper>\n </DSToolbarV2Context.Provider>\n );\n};\n\nDSToolbarV2.propTypes = DSToolbarV2Schema;\n\nDSToolbarV2.displayName = 'DSToolbarV2';\nconst DSToolbarV2WithSchema = describe(DSToolbarV2).description('Toolbar');\nDSToolbarV2WithSchema.propTypes = DSToolbarV2Schema;\n\nexport { DSToolbarV2, DSToolbarV2WithSchema };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAAA;AAAA;AAAA;AAAA;AAKA;AACA;AACA;AACA;AACA;AAGA,MAAM,cAAqD,CAAC,UAAU;AACpE,QAAM,oBAAoB,6BAA6B,OAAO,YAAY;AAE1E,iCAA+B,mBAAmB,iBAAiB;AAEnE,QAAM,EAAE,WAAW,WAAW,SAAS,UAAU,aAAa;AAE9D,QAAM,eAAe,uBAAuB,iBAAiB;AAE7D,QAAM,aAAa,QAAQ,MAAM,cAAc,IAAI,KAAK,CAAC,CAAC;AAE1D,QAAM,CAAC,gBAAgB,qBAAqB,SAAS,CAAC,CAAC;AACvD,QAAM,CAAC,YAAY,iBAAiB,SAAS,EAAE;AAE/C,QAAM,oBAAoB,YACxB,CAAC,QAAgB,QAA6C;AAC5D,sBAAkB,CAAC,uBAAwB,iCAAK,qBAAL,EAAyB,CAAC,SAAS,IAAI,EAAE;AAAA,EACtF,GACA,CAAC,iBAAiB,CACpB;AAEA,QAAM,MAAM,QACV,MAAO,GAAE,YAAY,mBAAmB,gBAAgB,YAAY,cAAc,IAClF,CAAC,YAAY,gBAAgB,mBAAmB,UAAU,CAC5D;AAEA,SACE,qCAAC,mBAAmB,UAAnB;AAAA,IAA4B,OAAO;AAAA,KAClC,qCAAC;AAAA,IACC,MAAK;AAAA,IACL,eAAY;AAAA,IACZ,IAAI;AAAA,IACJ,YAAW;AAAA,IACX,gBAAgB,cAAc,SAAS,eAAe;AAAA,IACtD;AAAA,IACA,QAAO;AAAA,IACP;AAAA,IACA,KAAK;AAAA,KACD,eAEH,QACH,CACF;AAEJ;AAEA,YAAY,YAAY;AAExB,YAAY,cAAc;AAC1B,MAAM,wBAAwB,SAAS,WAAW,EAAE,YAAY,SAAS;AACzE,sBAAsB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,10 @@ import { createContext } from "react";
|
|
|
3
3
|
const DSToolbarV2Context = createContext({
|
|
4
4
|
registerReference: () => null,
|
|
5
5
|
itemReferences: {},
|
|
6
|
-
toolbarUid: ""
|
|
6
|
+
toolbarUid: "",
|
|
7
|
+
activeItem: "",
|
|
8
|
+
setActiveItem: () => {
|
|
9
|
+
}
|
|
7
10
|
});
|
|
8
11
|
export {
|
|
9
12
|
DSToolbarV2Context
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSToolbarV2Context.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, MutableRefObject } from 'react';\n\ninterface IDSToolbarV2Context {\n registerReference: (uid: string, ref: MutableRefObject<HTMLElement>) => void;\n itemReferences: Record<string, MutableRefObject<HTMLElement>>;\n toolbarUid: string;\n}\n\nexport const DSToolbarV2Context = createContext<IDSToolbarV2Context>({\n registerReference: () => null,\n itemReferences: {},\n toolbarUid: '',\n});\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, MutableRefObject } from 'react';\n\ninterface IDSToolbarV2Context {\n registerReference: (uid: string, ref: MutableRefObject<HTMLElement>) => void;\n itemReferences: Record<string, MutableRefObject<HTMLElement>>;\n toolbarUid: string;\n activeItem: string;\n setActiveItem: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport const DSToolbarV2Context = createContext<IDSToolbarV2Context>({\n registerReference: () => null,\n itemReferences: {},\n toolbarUid: '',\n activeItem: '',\n setActiveItem: () => {},\n});\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAUO,MAAM,qBAAqB,cAAmC;AAAA,EACnE,mBAAmB,MAAM;AAAA,EACzB,gBAAgB,CAAC;AAAA,EACjB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe,MAAM;AAAA,EAAC;AACxB,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -31,14 +31,13 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
};
|
|
32
32
|
import * as React from "react";
|
|
33
33
|
import React2, { useRef } from "react";
|
|
34
|
-
import { describe, PropTypes } from "react-desc";
|
|
35
34
|
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
36
|
-
import {
|
|
37
|
-
import { mergeRefs } from "@elliemae/ds-utilities";
|
|
35
|
+
import { describe, PropTypes, mergeRefs } from "@elliemae/ds-utilities";
|
|
38
36
|
import decorateToolbarChildren from "./decorateToolbarChildren";
|
|
39
37
|
import Item from "./ToolbarItem";
|
|
40
38
|
import ToolbarGroup from "./ToolbarGroup";
|
|
41
39
|
import Divider from "./ToolbarDivider";
|
|
40
|
+
import { useKeyboardNavigation } from "./hooks/useKeyboardNavigation";
|
|
42
41
|
const blockName = "toolbar";
|
|
43
42
|
const ToolbarContainer = aggregatedClasses("div")(blockName, null, ({ withDepth, alignment, size }) => ({
|
|
44
43
|
"without-depth": !withDepth,
|
|
@@ -64,17 +63,12 @@ const DSToolbar = (_a) => {
|
|
|
64
63
|
"size"
|
|
65
64
|
]);
|
|
66
65
|
const containerRef = useRef(null);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
getContainer: () => containerRef.current,
|
|
70
|
-
keyBindings: {
|
|
71
|
-
Tab: "next"
|
|
72
|
-
},
|
|
73
|
-
orientation: "horizontal"
|
|
74
|
-
}, /* @__PURE__ */ React2.createElement(ToolbarContainer, __spreadProps(__spreadValues(__spreadValues({}, containerProps), otherProps), {
|
|
66
|
+
const { handleOnKeyDown } = useKeyboardNavigation({ containerRef, autoFocusOnMount });
|
|
67
|
+
return /* @__PURE__ */ React2.createElement(ToolbarContainer, __spreadProps(__spreadValues(__spreadValues({}, containerProps), otherProps), {
|
|
75
68
|
classProps: { withDepth, alignment, size },
|
|
76
|
-
innerRef: mergeRefs(innerRef, containerRef)
|
|
77
|
-
|
|
69
|
+
innerRef: mergeRefs(innerRef, containerRef),
|
|
70
|
+
onKeyDown: handleOnKeyDown
|
|
71
|
+
}), decorateToolbarChildren(children));
|
|
78
72
|
};
|
|
79
73
|
const toolbarProps = {
|
|
80
74
|
containerProps: PropTypes.object.description("Set of Properties attached to the main container"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/DSToolbar.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef } from 'react';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { describe, PropTypes, mergeRefs } from '@elliemae/ds-utilities';\nimport decorateToolbarChildren from './decorateToolbarChildren';\nimport Item from './ToolbarItem';\nimport ToolbarGroup from './ToolbarGroup';\nimport Divider from './ToolbarDivider';\nimport { useKeyboardNavigation } from './hooks/useKeyboardNavigation';\n\nconst blockName = 'toolbar';\n\nconst ToolbarContainer = aggregatedClasses('div')(blockName, null, ({ withDepth, alignment, size }) => ({\n 'without-depth': !withDepth,\n [alignment]: !!alignment,\n [size]: size,\n}));\n\nconst DSToolbar = ({\n containerProps = {},\n innerRef,\n withDepth = true,\n alignment = 'right', // left || right\n autoFocusOnMount = true,\n children = [],\n size = 'normal',\n ...otherProps\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const { handleOnKeyDown } = useKeyboardNavigation({ containerRef, autoFocusOnMount });\n\n return (\n <ToolbarContainer\n {...containerProps}\n {...otherProps}\n classProps={{ withDepth, alignment, size }}\n innerRef={mergeRefs(innerRef, containerRef)}\n onKeyDown={handleOnKeyDown}\n >\n {decorateToolbarChildren(children)}\n </ToolbarContainer>\n );\n};\n\nconst toolbarProps = {\n containerProps: PropTypes.object.description('Set of Properties attached to the main container'),\n withDepth: PropTypes.bool.description('Shows a shadow rear the toolbar').defaultValue(true),\n alignment: PropTypes.oneOf(['right', 'left'])\n .description('Aligns the toolbar to the left or right')\n .defaultValue('right'),\n size: PropTypes.oneOf(['normal', 'compact']).description('Toolbar size').defaultValue('normal'),\n autoFocusOnMount: PropTypes.bool\n .description('Wheter to focus the component when it mounts or not')\n .defaultValue(true),\n children: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.node]).description('Toolbar items')\n .isRequired,\n innerRef: PropTypes.object.description('Ref to the Toolbar container element'),\n};\n\nDSToolbar.propTypes = toolbarProps;\nDSToolbar.displayName = 'DSToolbar';\nconst ToolbarWithSchema = describe(DSToolbar);\nToolbarWithSchema.propTypes = toolbarProps;\n\nexport { DSToolbar, Item as ToolbarItem, ToolbarGroup, Divider as ToolbarDivider, ToolbarWithSchema };\n\nexport default DSToolbar;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,YAAY;AAElB,MAAM,mBAAmB,kBAAkB,KAAK,EAAE,WAAW,MAAM,CAAC,EAAE,WAAW,WAAW,WAAY;AAAA,EACtG,iBAAiB,CAAC;AAAA,EAClB,CAAC,YAAY,CAAC,CAAC;AAAA,EACf,CAAC,OAAO;AACV,EAAE;AAEF,MAAM,YAAY,CAAC,OASb;AATa,eACjB;AAAA,qBAAiB,CAAC;AAAA,IAClB;AAAA,IACA,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,mBAAmB;AAAA,IACnB,WAAW,CAAC;AAAA,IACZ,OAAO;AAAA,MAPU,IAQd,uBARc,IAQd;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,eAAe,OAA8B,IAAI;AAEvD,QAAM,EAAE,oBAAoB,sBAAsB,EAAE,cAAc,iBAAiB,CAAC;AAEpF,SACE,qCAAC,kEACK,iBACA,aAFL;AAAA,IAGC,YAAY,EAAE,WAAW,WAAW,KAAK;AAAA,IACzC,UAAU,UAAU,UAAU,YAAY;AAAA,IAC1C,WAAW;AAAA,MAEV,wBAAwB,QAAQ,CACnC;AAEJ;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB,UAAU,OAAO,YAAY,kDAAkD;AAAA,EAC/F,WAAW,UAAU,KAAK,YAAY,iCAAiC,EAAE,aAAa,IAAI;AAAA,EAC1F,WAAW,UAAU,MAAM,CAAC,SAAS,MAAM,CAAC,EACzC,YAAY,yCAAyC,EACrD,aAAa,OAAO;AAAA,EACvB,MAAM,UAAU,MAAM,CAAC,UAAU,SAAS,CAAC,EAAE,YAAY,cAAc,EAAE,aAAa,QAAQ;AAAA,EAC9F,kBAAkB,UAAU,KACzB,YAAY,qDAAqD,EACjE,aAAa,IAAI;AAAA,EACpB,UAAU,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,UAAU,IAAI,CAAC,EAAE,YAAY,eAAe,EACzG;AAAA,EACH,UAAU,UAAU,OAAO,YAAY,sCAAsC;AAC/E;AAEA,UAAU,YAAY;AACtB,UAAU,cAAc;AACxB,MAAM,oBAAoB,SAAS,SAAS;AAC5C,kBAAkB,YAAY;AAI9B,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/ToolbarGroup.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport PropTypes from 'prop-types';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport decorateToolbarChildren from './decorateToolbarChildren';\n\nconst blockName = 'toolbar-group';\n\nconst ToolbarGroupContainer = aggregatedClasses('div')(\n blockName,\n null,\n ({ space }) => ({\n [`space-${space}`]: !!space,\n }),\n);\n\nconst ToolbarGroup = ({ children, size, space = 0 }) => (\n <ToolbarGroupContainer classProps={{ space }}>\n {decorateToolbarChildren(children, { size })}\n </ToolbarGroupContainer>\n);\n\nToolbarGroup.propTypes = {\n children: PropTypes.any,\n size: PropTypes.number,\n space: PropTypes.number,\n};\n\nexport default ToolbarGroup;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,MAAM,YAAY;AAElB,MAAM,wBAAwB,kBAAkB,KAAK,EACnD,WACA,MACA,CAAC,EAAE,YAAa;AAAA,
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,MAAM,YAAY;AAElB,MAAM,wBAAwB,kBAAkB,KAAK,EACnD,WACA,MACA,CAAC,EAAE,YAAa;AAAA,EACd,CAAC,SAAS,UAAU,CAAC,CAAC;AACxB,EACF;AAEA,MAAM,eAAe,CAAC,EAAE,UAAU,MAAM,QAAQ,QAC9C,qCAAC;AAAA,EAAsB,YAAY,EAAE,MAAM;AAAA,GACxC,wBAAwB,UAAU,EAAE,KAAK,CAAC,CAC7C;AAGF,aAAa,YAAY;AAAA,EACvB,UAAU,UAAU;AAAA,EACpB,MAAM,UAAU;AAAA,EAChB,OAAO,UAAU;AACnB;AAEA,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
3
|
+
const useKeyboardNavigation = ({ containerRef, autoFocusOnMount }) => {
|
|
4
|
+
const allChildrenButtonRef = useRef(null);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (containerRef.current) {
|
|
7
|
+
allChildrenButtonRef.current = containerRef.current.querySelectorAll("button");
|
|
8
|
+
}
|
|
9
|
+
if (autoFocusOnMount) {
|
|
10
|
+
setTimeout(() => allChildrenButtonRef.current?.[0].focus());
|
|
11
|
+
}
|
|
12
|
+
}, [autoFocusOnMount]);
|
|
13
|
+
const handleOnKeyDown = useCallback((e) => {
|
|
14
|
+
if (allChildrenButtonRef.current) {
|
|
15
|
+
const lastButton = allChildrenButtonRef.current[allChildrenButtonRef.current?.length - 1];
|
|
16
|
+
const firstButton = allChildrenButtonRef.current[0];
|
|
17
|
+
if (e.key === "ArrowRight") {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
if (e.target !== lastButton) {
|
|
20
|
+
e.target.nextSibling.focus();
|
|
21
|
+
} else {
|
|
22
|
+
firstButton.focus();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (e.key === "ArrowLeft") {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
if (e.target !== firstButton) {
|
|
28
|
+
e.target.previousSibling.focus();
|
|
29
|
+
} else {
|
|
30
|
+
lastButton.focus();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
return {
|
|
36
|
+
handleOnKeyDown
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
useKeyboardNavigation
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useKeyboardNavigation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/deprecated/hooks/useKeyboardNavigation.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef, useEffect, useCallback } from 'react';\n\ninterface useKeyboardNavigationT {\n containerRef: React.MutableRefObject<HTMLDivElement | null>;\n autoFocusOnMount: boolean;\n}\n\n// Toolbar should not allow to use Tab/Shift+Tab to navigate between ToolbarItems.\n// Tab/Shift+Tab should be only used once to enter the whole controller.\n// Toolbars should be only navigable with Arrows to follow correct a11y.\n// https://www.w3.org/TR/wai-aria-practices/examples/toolbar/toolbar.html\n\nexport const useKeyboardNavigation = ({ containerRef, autoFocusOnMount }: useKeyboardNavigationT) => {\n const allChildrenButtonRef = useRef<NodeListOf<HTMLButtonElement> | null>(null);\n\n useEffect(() => {\n if (containerRef.current) {\n allChildrenButtonRef.current = containerRef.current.querySelectorAll('button');\n // allChildrenButtonRef.current.forEach((button, index) => {\n // if (index !== 0) {\n // button.setAttribute('tabindex', '-1');\n // }\n // });\n }\n\n if (autoFocusOnMount) {\n setTimeout(() => allChildrenButtonRef.current?.[0].focus());\n }\n\n // return () => {\n // allChildrenButtonRef.current?.forEach((button, index) => {\n // if (index !== 0) {\n // button.setAttribute('tabindex', '');\n // }\n // });\n // };\n }, [autoFocusOnMount]);\n\n const handleOnKeyDown = useCallback((e) => {\n if (allChildrenButtonRef.current) {\n const lastButton = allChildrenButtonRef.current[allChildrenButtonRef.current?.length - 1];\n const firstButton = allChildrenButtonRef.current[0];\n\n if (e.key === 'ArrowRight') {\n e.preventDefault();\n if (e.target !== lastButton) {\n e.target.nextSibling.focus();\n } else {\n firstButton.focus();\n }\n }\n if (e.key === 'ArrowLeft') {\n e.preventDefault();\n if (e.target !== firstButton) {\n e.target.previousSibling.focus();\n } else {\n lastButton.focus();\n }\n }\n }\n }, []);\n\n return {\n handleOnKeyDown,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAYO,MAAM,wBAAwB,CAAC,EAAE,cAAc,uBAA+C;AACnG,QAAM,uBAAuB,OAA6C,IAAI;AAE9E,YAAU,MAAM;AACd,QAAI,aAAa,SAAS;AACxB,2BAAqB,UAAU,aAAa,QAAQ,iBAAiB,QAAQ;AAAA,IAM/E;AAEA,QAAI,kBAAkB;AACpB,iBAAW,MAAM,qBAAqB,UAAU,GAAG,MAAM,CAAC;AAAA,IAC5D;AAAA,EASF,GAAG,CAAC,gBAAgB,CAAC;AAErB,QAAM,kBAAkB,YAAY,CAAC,MAAM;AACzC,QAAI,qBAAqB,SAAS;AAChC,YAAM,aAAa,qBAAqB,QAAQ,qBAAqB,SAAS,SAAS;AACvF,YAAM,cAAc,qBAAqB,QAAQ;AAEjD,UAAI,EAAE,QAAQ,cAAc;AAC1B,UAAE,eAAe;AACjB,YAAI,EAAE,WAAW,YAAY;AAC3B,YAAE,OAAO,YAAY,MAAM;AAAA,QAC7B,OAAO;AACL,sBAAY,MAAM;AAAA,QACpB;AAAA,MACF;AACA,UAAI,EAAE,QAAQ,aAAa;AACzB,UAAE,eAAe;AACjB,YAAI,EAAE,WAAW,aAAa;AAC5B,YAAE,OAAO,gBAAgB,MAAM;AAAA,QACjC,OAAO;AACL,qBAAW,MAAM;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import { globalAttributesPropTypes, PropTypes } from "@elliemae/ds-utilities";
|
|
22
|
+
const defaultItemProps = {
|
|
23
|
+
render: () => {
|
|
24
|
+
},
|
|
25
|
+
isFirstItem: false
|
|
26
|
+
};
|
|
27
|
+
const defaultProps = {
|
|
28
|
+
alignment: "right",
|
|
29
|
+
withDepth: true,
|
|
30
|
+
compact: false
|
|
31
|
+
};
|
|
32
|
+
const DSToolbarV2Schema = __spreadProps(__spreadValues({}, globalAttributesPropTypes), {
|
|
33
|
+
alignment: PropTypes.oneOf(["right", "left"]).description("Whether to align the content left or right").defaultValue("right"),
|
|
34
|
+
withDepth: PropTypes.bool.description("Whether to add a box-shadow to the container").defaultValue(true),
|
|
35
|
+
compact: PropTypes.bool.description("Whether you want the compact version of the toolbar").defaultValue(false),
|
|
36
|
+
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description("Reference to attach to the wrapper")
|
|
37
|
+
});
|
|
38
|
+
const DSToolbarItemV2Schema = __spreadProps(__spreadValues({}, globalAttributesPropTypes), {
|
|
39
|
+
render: PropTypes.func.isRequired.description("render function").defaultValue(() => {
|
|
40
|
+
}),
|
|
41
|
+
isFirstItem: PropTypes.bool.description("If true the item will have tab index 0 to be the first element focusable by keyboard on the page load").defaultValue(false)
|
|
42
|
+
});
|
|
43
|
+
export {
|
|
44
|
+
DSToolbarItemV2Schema,
|
|
45
|
+
DSToolbarV2Schema,
|
|
46
|
+
defaultItemProps,
|
|
47
|
+
defaultProps
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\n\nexport declare namespace DSToolbarT {\n export interface Props {\n alignment?: 'left' | 'right';\n withDepth?: boolean;\n compact?: boolean;\n innerRef?: React.MutableRefObject<HTMLDivElement>;\n children: React.Component<DSToolbarItemT.Props>;\n }\n}\n\nexport declare namespace DSToolbarItemT {\n export interface Props {\n render: (props: { innerRef: React.MutableRefObject<HTMLElement>; tabIndex: number }) => JSX.Element;\n isFirstItem?: boolean;\n }\n}\n\nexport const defaultItemProps = {\n render: () => {},\n isFirstItem: false,\n};\n\nexport const defaultProps = {\n alignment: 'right',\n withDepth: true,\n compact: false,\n};\n\nexport const DSToolbarV2Schema = {\n ...globalAttributesPropTypes,\n alignment: PropTypes.oneOf(['right', 'left'])\n .description('Whether to align the content left or right')\n .defaultValue('right'),\n withDepth: PropTypes.bool.description('Whether to add a box-shadow to the container').defaultValue(true),\n compact: PropTypes.bool.description('Whether you want the compact version of the toolbar').defaultValue(false),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Reference to attach to the wrapper'),\n};\n\nexport const DSToolbarItemV2Schema = {\n ...globalAttributesPropTypes,\n render: PropTypes.func.isRequired.description('render function').defaultValue(() => {}),\n isFirstItem: PropTypes.bool\n .description(\n 'If true the item will have tab index 0 to be the first element focusable by keyboard on the page load',\n )\n .defaultValue(false),\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AAmBO,MAAM,mBAAmB;AAAA,EAC9B,QAAQ,MAAM;AAAA,EAAC;AAAA,EACf,aAAa;AACf;AAEO,MAAM,eAAe;AAAA,EAC1B,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS;AACX;AAEO,MAAM,oBAAoB,iCAC5B,4BAD4B;AAAA,EAE/B,WAAW,UAAU,MAAM,CAAC,SAAS,MAAM,CAAC,EACzC,YAAY,4CAA4C,EACxD,aAAa,OAAO;AAAA,EACvB,WAAW,UAAU,KAAK,YAAY,8CAA8C,EAAE,aAAa,IAAI;AAAA,EACvG,SAAS,UAAU,KAAK,YAAY,qDAAqD,EAAE,aAAa,KAAK;AAAA,EAC7G,UAAU,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,CAAC,EAAE,YAAY,oCAAoC;AACpH;AAEO,MAAM,wBAAwB,iCAChC,4BADgC;AAAA,EAEnC,QAAQ,UAAU,KAAK,WAAW,YAAY,iBAAiB,EAAE,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EACtF,aAAa,UAAU,KACpB,YACC,uGACF,EACC,aAAa,KAAK;AACvB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/styled.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import styled from "
|
|
2
|
+
import { styled } from "@elliemae/ds-system";
|
|
3
3
|
import Grid from "@elliemae/ds-grid";
|
|
4
4
|
const StyledToolbarWrapper = styled(Grid)`
|
|
5
5
|
background-color: ${(props) => props.theme.colors.neutral["000"]};
|
|
6
6
|
|
|
7
|
-
min-height: ${(props) => props.compact ? "28px" : "
|
|
7
|
+
min-height: ${(props) => props.compact ? "28px" : "36px"};
|
|
8
8
|
max-height: ${(props) => props.theme.space.xxl};
|
|
9
9
|
|
|
10
10
|
padding: 0 ${(props) => props.theme.space.xxs};
|
|
11
|
-
|
|
11
|
+
grid-auto-flow: column;
|
|
12
12
|
box-shadow: ${(props) => !props.withDepth ? "none" : "0 1px 5px 0 rgb(0 0 0 / 13%), 0 2px 4px 0 rgb(0 0 0 / 20%)"};
|
|
13
13
|
`;
|
|
14
14
|
const StyledToolbarItem = styled(Grid)``;
|
package/dist/esm/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from '
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\nimport Grid from '@elliemae/ds-grid';\n\nexport const StyledToolbarWrapper = styled(Grid)`\n background-color: ${(props) => props.theme.colors.neutral['000']};\n\n min-height: ${(props) => (props.compact ? '28px' : '36px')};\n max-height: ${(props) => props.theme.space.xxl};\n\n padding: 0 ${(props) => props.theme.space.xxs};\n grid-auto-flow: column;\n box-shadow: ${(props) => (!props.withDepth ? 'none' : '0 1px 5px 0 rgb(0 0 0 / 13%), 0 2px 4px 0 rgb(0 0 0 / 20%)')};\n`;\n\nexport const StyledToolbarItem = styled(Grid)``;\n\nexport const StyledSeparator = styled(Grid)`\n height: 30px;\n width: 1px;\n background-color: ${(props) => props.theme.colors.neutral[200]};\n`;\n"],
|
|
5
5
|
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,uBAAuB,OAAO,IAAI;AAAA,sBACzB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA;AAAA,gBAE5C,CAAC,UAAW,MAAM,UAAU,SAAS;AAAA,gBACrC,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA;AAAA,eAE9B,CAAC,UAAU,MAAM,MAAM,MAAM;AAAA;AAAA,gBAE5B,CAAC,UAAW,CAAC,MAAM,YAAY,SAAS;AAAA;AAGjD,MAAM,oBAAoB,OAAO,IAAI;AAErC,MAAM,kBAAkB,OAAO,IAAI;AAAA;AAAA;AAAA,sBAGpB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,12 +2,15 @@ import * as React from "react";
|
|
|
2
2
|
import { useCallback, useContext } from "react";
|
|
3
3
|
import { DSToolbarV2Context } from "./DSToolbarV2Context";
|
|
4
4
|
const useToolbarItemHandlers = (toolbarItemId) => {
|
|
5
|
-
const { toolbarUid, itemReferences } = useContext(DSToolbarV2Context);
|
|
5
|
+
const { toolbarUid, itemReferences, setActiveItem } = useContext(DSToolbarV2Context);
|
|
6
|
+
const onFocus = useCallback(() => {
|
|
7
|
+
setActiveItem(toolbarItemId);
|
|
8
|
+
}, [setActiveItem, toolbarItemId]);
|
|
6
9
|
const onKeyDown = useCallback((e) => {
|
|
7
10
|
const toolbarItems = [...document.querySelectorAll(`#${toolbarUid} .ds-toolbar-item`)];
|
|
8
11
|
let nextToolbarItemIndex = -1;
|
|
12
|
+
const toolbarItemIndex = toolbarItems.findIndex((domElem) => domElem.id === toolbarItemId);
|
|
9
13
|
if (["ArrowLeft", "ArrowRight"].includes(e.code)) {
|
|
10
|
-
const toolbarItemIndex = toolbarItems.findIndex((domElem) => domElem.id === toolbarItemId);
|
|
11
14
|
nextToolbarItemIndex = toolbarItemIndex + (e.code === "ArrowLeft" ? -1 : 1);
|
|
12
15
|
} else if (e.code === "Home") {
|
|
13
16
|
nextToolbarItemIndex = 0;
|
|
@@ -22,7 +25,7 @@ const useToolbarItemHandlers = (toolbarItemId) => {
|
|
|
22
25
|
ref.current.focus();
|
|
23
26
|
}
|
|
24
27
|
}, [toolbarUid, toolbarItemId, itemReferences]);
|
|
25
|
-
return { onKeyDown };
|
|
28
|
+
return { onKeyDown, onFocus };
|
|
26
29
|
};
|
|
27
30
|
export {
|
|
28
31
|
useToolbarItemHandlers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/useToolbarItemHandlers.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useContext } from 'react';\nimport { DSToolbarV2Context } from './DSToolbarV2Context';\n\nexport const useToolbarItemHandlers = (\n toolbarItemId: string,\n): {\n onKeyDown: React.KeyboardEventHandler;\n} => {\n const { toolbarUid, itemReferences } = useContext(DSToolbarV2Context);\n\n const onKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n const toolbarItems = [...document.querySelectorAll(`#${toolbarUid} .ds-toolbar-item`)];\n let nextToolbarItemIndex = -1;\n\n if (['ArrowLeft', 'ArrowRight'].includes(e.code)) {\n
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,yBAAyB,CACpC,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useContext } from 'react';\nimport { DSToolbarV2Context } from './DSToolbarV2Context';\n\nexport const useToolbarItemHandlers = (\n toolbarItemId: string,\n): {\n onKeyDown: React.KeyboardEventHandler;\n onFocus: React.FocusEventHandler;\n} => {\n const { toolbarUid, itemReferences, setActiveItem } = useContext(DSToolbarV2Context);\n\n const onFocus: React.FocusEventHandler = useCallback(() => {\n setActiveItem(toolbarItemId);\n }, [setActiveItem, toolbarItemId]);\n\n const onKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n const toolbarItems = [...document.querySelectorAll(`#${toolbarUid} .ds-toolbar-item`)];\n let nextToolbarItemIndex = -1;\n const toolbarItemIndex = toolbarItems.findIndex((domElem) => domElem.id === toolbarItemId);\n\n if (['ArrowLeft', 'ArrowRight'].includes(e.code)) {\n nextToolbarItemIndex = toolbarItemIndex + (e.code === 'ArrowLeft' ? -1 : 1);\n } else if (e.code === 'Home') {\n nextToolbarItemIndex = 0;\n } else if (e.code === 'End') {\n nextToolbarItemIndex = toolbarItems.length - 1;\n }\n\n if (nextToolbarItemIndex >= 0 && nextToolbarItemIndex < toolbarItems.length) {\n e.preventDefault();\n e.stopPropagation();\n const ref = itemReferences[toolbarItems[nextToolbarItemIndex].id];\n if (ref.current) ref.current.focus();\n }\n },\n [toolbarUid, toolbarItemId, itemReferences],\n );\n\n return { onKeyDown, onFocus };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,yBAAyB,CACpC,kBAIG;AACH,QAAM,EAAE,YAAY,gBAAgB,kBAAkB,WAAW,kBAAkB;AAEnF,QAAM,UAAmC,YAAY,MAAM;AACzD,kBAAc,aAAa;AAAA,EAC7B,GAAG,CAAC,eAAe,aAAa,CAAC;AAEjC,QAAM,YAAwC,YAC5C,CAAC,MAAM;AACL,UAAM,eAAe,CAAC,GAAG,SAAS,iBAAiB,IAAI,6BAA6B,CAAC;AACrF,QAAI,uBAAuB;AAC3B,UAAM,mBAAmB,aAAa,UAAU,CAAC,YAAY,QAAQ,OAAO,aAAa;AAEzF,QAAI,CAAC,aAAa,YAAY,EAAE,SAAS,EAAE,IAAI,GAAG;AAChD,6BAAuB,mBAAoB,GAAE,SAAS,cAAc,KAAK;AAAA,IAC3E,WAAW,EAAE,SAAS,QAAQ;AAC5B,6BAAuB;AAAA,IACzB,WAAW,EAAE,SAAS,OAAO;AAC3B,6BAAuB,aAAa,SAAS;AAAA,IAC/C;AAEA,QAAI,wBAAwB,KAAK,uBAAuB,aAAa,QAAQ;AAC3E,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAClB,YAAM,MAAM,eAAe,aAAa,sBAAsB;AAC9D,UAAI,IAAI;AAAS,YAAI,QAAQ,MAAM;AAAA,IACrC;AAAA,EACF,GACA,CAAC,YAAY,eAAe,cAAc,CAC5C;AAEA,SAAO,EAAE,WAAW,QAAQ;AAC9B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-toolbar",
|
|
3
|
-
"version": "3.1.0-next.
|
|
3
|
+
"version": "3.1.0-next.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Toolbar",
|
|
6
6
|
"files": [
|
|
@@ -86,40 +86,40 @@
|
|
|
86
86
|
"reportFile": "tests.xml",
|
|
87
87
|
"indent": 4
|
|
88
88
|
},
|
|
89
|
-
"scripts": {
|
|
90
|
-
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
91
|
-
"test": "node ../../scripts/testing/test.mjs",
|
|
92
|
-
"lint": "node ../../scripts/lint.mjs",
|
|
93
|
-
"dts": "node ../../scripts/dts.mjs",
|
|
94
|
-
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
95
|
-
},
|
|
96
89
|
"dependencies": {
|
|
97
|
-
"@elliemae/ds-button": "3.1.0-next.
|
|
98
|
-
"@elliemae/ds-classnames": "3.1.0-next.
|
|
99
|
-
"@elliemae/ds-grid": "3.1.0-next.
|
|
100
|
-
"@elliemae/ds-icons": "3.1.0-next.
|
|
101
|
-
"@elliemae/ds-popper": "3.1.0-next.
|
|
102
|
-
"@elliemae/ds-shared": "3.1.0-next.
|
|
103
|
-
"@elliemae/ds-system": "3.1.0-next.
|
|
104
|
-
"@elliemae/ds-utilities": "3.1.0-next.
|
|
90
|
+
"@elliemae/ds-button": "3.1.0-next.20",
|
|
91
|
+
"@elliemae/ds-classnames": "3.1.0-next.20",
|
|
92
|
+
"@elliemae/ds-grid": "3.1.0-next.20",
|
|
93
|
+
"@elliemae/ds-icons": "3.1.0-next.20",
|
|
94
|
+
"@elliemae/ds-popper": "3.1.0-next.20",
|
|
95
|
+
"@elliemae/ds-shared": "3.1.0-next.20",
|
|
96
|
+
"@elliemae/ds-system": "3.1.0-next.20",
|
|
97
|
+
"@elliemae/ds-utilities": "3.1.0-next.20",
|
|
105
98
|
"prop-types": "~15.8.1",
|
|
106
|
-
"react-desc": "~4.1.3",
|
|
107
99
|
"uid": "2.0.0"
|
|
108
100
|
},
|
|
109
101
|
"devDependencies": {
|
|
110
|
-
"@testing-library/jest-dom": "~5.16.
|
|
111
|
-
"@testing-library/react": "~12.1.
|
|
102
|
+
"@testing-library/jest-dom": "~5.16.4",
|
|
103
|
+
"@testing-library/react": "~12.1.3",
|
|
112
104
|
"@testing-library/user-event": "~13.5.0",
|
|
113
|
-
"styled-components": "~5.3.
|
|
105
|
+
"styled-components": "~5.3.5"
|
|
114
106
|
},
|
|
115
107
|
"peerDependencies": {
|
|
116
108
|
"lodash": "^4.17.21",
|
|
117
109
|
"react": "^17.0.2",
|
|
118
110
|
"react-dom": "^17.0.2",
|
|
119
|
-
"styled-components": "^5.3.
|
|
111
|
+
"styled-components": "^5.3.5"
|
|
120
112
|
},
|
|
121
113
|
"publishConfig": {
|
|
122
114
|
"access": "public",
|
|
123
115
|
"typeSafety": false
|
|
116
|
+
},
|
|
117
|
+
"scripts": {
|
|
118
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
119
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
120
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
121
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
122
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs",
|
|
123
|
+
"checkDeps": "npx -yes ../ds-codemods check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\""
|
|
124
124
|
}
|
|
125
|
-
}
|
|
125
|
+
}
|
package/dist/cjs/props.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
var props_exports = {};
|
|
22
|
-
__export(props_exports, {
|
|
23
|
-
DSToolbarV2Schema: () => DSToolbarV2Schema
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(props_exports);
|
|
26
|
-
var React = __toESM(require("react"));
|
|
27
|
-
var import_react_desc = require("react-desc");
|
|
28
|
-
const DSToolbarV2Schema = {
|
|
29
|
-
alignment: import_react_desc.PropTypes.oneOf(["right", "left"]).description("Whether to align the content left or right").defaultValue("right"),
|
|
30
|
-
withDepth: import_react_desc.PropTypes.bool.description("Whether to add a box-shadow to the container").defaultValue(true),
|
|
31
|
-
compact: import_react_desc.PropTypes.bool.description("Whether you want the compact version of the toolbar").defaultValue(false),
|
|
32
|
-
innerRef: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.func, import_react_desc.PropTypes.object]).description("Reference to attach to the wrapper")
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=props.js.map
|
package/dist/cjs/props.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/props.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { PropTypes } from 'react-desc';\n\nexport const DSToolbarV2Schema = {\n alignment: PropTypes.oneOf(['right', 'left'])\n .description('Whether to align the content left or right')\n .defaultValue('right'),\n withDepth: PropTypes.bool.description('Whether to add a box-shadow to the container').defaultValue(true),\n compact: PropTypes.bool.description('Whether you want the compact version of the toolbar').defaultValue(false),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Reference to attach to the wrapper'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,oBAAoB;AAAA,EAC/B,WAAW,4BAAU,MAAM,CAAC,SAAS,MAAM,CAAC,EACzC,YAAY,4CAA4C,EACxD,aAAa,OAAO;AAAA,EACvB,WAAW,4BAAU,KAAK,YAAY,8CAA8C,EAAE,aAAa,IAAI;AAAA,EACvG,SAAS,4BAAU,KAAK,YAAY,qDAAqD,EAAE,aAAa,KAAK;AAAA,EAC7G,UAAU,4BAAU,UAAU,CAAC,4BAAU,MAAM,4BAAU,MAAM,CAAC,EAAE,YAAY,oCAAoC;AACpH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/props.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { PropTypes } from "react-desc";
|
|
3
|
-
const DSToolbarV2Schema = {
|
|
4
|
-
alignment: PropTypes.oneOf(["right", "left"]).description("Whether to align the content left or right").defaultValue("right"),
|
|
5
|
-
withDepth: PropTypes.bool.description("Whether to add a box-shadow to the container").defaultValue(true),
|
|
6
|
-
compact: PropTypes.bool.description("Whether you want the compact version of the toolbar").defaultValue(false),
|
|
7
|
-
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description("Reference to attach to the wrapper")
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
DSToolbarV2Schema
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=props.js.map
|