@elliemae/ds-toolbar 3.1.0-next.15 → 3.1.0-next.16
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 +12 -14
- 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.map +1 -1
- package/dist/cjs/deprecated/ToolbarGroup.js.map +1 -1
- 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 +2 -2
- package/dist/cjs/styled.js.map +1 -1
- 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 +15 -13
- 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.map +1 -1
- package/dist/esm/deprecated/ToolbarGroup.js.map +1 -1
- 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 +2 -2
- 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 +13 -13
- 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
|
@@ -18,6 +18,18 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
}
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
21
33
|
var __export = (target, all) => {
|
|
22
34
|
for (var name in all)
|
|
23
35
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,28 +46,40 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
46
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
47
|
var DSToolbarItemV2_exports = {};
|
|
36
48
|
__export(DSToolbarItemV2_exports, {
|
|
37
|
-
DSToolbarItemV2: () => DSToolbarItemV2
|
|
49
|
+
DSToolbarItemV2: () => DSToolbarItemV2,
|
|
50
|
+
DSToolbarItemV2WithSchema: () => DSToolbarItemV2WithSchema
|
|
38
51
|
});
|
|
39
52
|
module.exports = __toCommonJS(DSToolbarItemV2_exports);
|
|
40
53
|
var React = __toESM(require("react"));
|
|
41
54
|
var import_react = __toESM(require("react"));
|
|
55
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
42
56
|
var import_uid = require("uid");
|
|
43
57
|
var import_DSToolbarV2Context = require("./DSToolbarV2Context");
|
|
44
58
|
var import_styled = require("./styled");
|
|
45
59
|
var import_useToolbarItemHandlers = require("./useToolbarItemHandlers");
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types");
|
|
61
|
+
const DSToolbarItemV2 = (props) => {
|
|
62
|
+
const propsWithDefaults = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultItemProps);
|
|
63
|
+
(0, import_ds_utilities.useValidateTypescriptPropTypes)(propsWithDefaults, import_react_desc_prop_types.DSToolbarItemV2Schema);
|
|
64
|
+
const { render, isFirstItem } = propsWithDefaults;
|
|
65
|
+
const _a = (0, import_ds_utilities.useGetGlobalAttributes)(propsWithDefaults), { id } = _a, restGlobals = __objRest(_a, ["id"]);
|
|
66
|
+
const { registerReference, activeItem } = (0, import_react.useContext)(import_DSToolbarV2Context.DSToolbarV2Context);
|
|
48
67
|
const ref = (0, import_react.useRef)(null);
|
|
49
68
|
const toolbarItemId = (0, import_react.useMemo)(() => {
|
|
50
|
-
const
|
|
51
|
-
registerReference(
|
|
52
|
-
return
|
|
69
|
+
const id2 = `ds-toolbar-item-${(0, import_uid.uid)()}`;
|
|
70
|
+
registerReference(id2, ref);
|
|
71
|
+
return id2;
|
|
53
72
|
}, [registerReference, ref]);
|
|
73
|
+
const tabIndex = (0, import_react.useMemo)(() => activeItem === toolbarItemId || !activeItem && isFirstItem ? 0 : -1, [activeItem, isFirstItem, toolbarItemId]);
|
|
54
74
|
const handlers = (0, import_useToolbarItemHandlers.useToolbarItemHandlers)(toolbarItemId);
|
|
55
|
-
return /* @__PURE__ */ import_react.default.createElement(import_styled.StyledToolbarItem, __spreadValues({
|
|
75
|
+
return /* @__PURE__ */ import_react.default.createElement(import_styled.StyledToolbarItem, __spreadValues(__spreadValues({
|
|
56
76
|
id: toolbarItemId,
|
|
57
77
|
"data-testid": "ds-toolbar-item",
|
|
58
78
|
className: "ds-toolbar-item"
|
|
59
|
-
}, handlers), render({ innerRef: ref }));
|
|
79
|
+
}, handlers), restGlobals), render({ innerRef: ref, tabIndex }));
|
|
60
80
|
};
|
|
81
|
+
DSToolbarItemV2.propTypes = import_react_desc_prop_types.DSToolbarItemV2Schema;
|
|
82
|
+
DSToolbarItemV2.displayName = "DSToolbarItemV2";
|
|
83
|
+
const DSToolbarItemV2WithSchema = (0, import_ds_utilities.describe)(DSToolbarItemV2).description("Toolbar Item");
|
|
84
|
+
DSToolbarItemV2WithSchema.propTypes = import_react_desc_prop_types.DSToolbarItemV2Schema;
|
|
61
85
|
//# sourceMappingURL=DSToolbarItemV2.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSToolbarItemV2.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React, {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAmD;AACnD,0BAKO;AACP,iBAAoB;AACpB,gCAAmC;AACnC,oBAAkC;AAClC,oCAAuC;AACvC,mCAAwD;AAExD,MAAM,kBAA6D,CAAC,UAAU;AAC5E,QAAM,oBAAoB,sDAA6B,OAAO,6CAAgB;AAE9E,0DAA+B,mBAAmB,kDAAqB;AACvE,QAAM,EAAE,QAAQ,gBAAgB;AAChC,QAA+B,qDAAuB,iBAAiB,GAA/D,SAAuB,IAAhB,wBAAgB,IAAhB,CAAP;AACR,QAAM,EAAE,mBAAmB,eAAe,6BAAW,4CAAkB;AACvE,QAAM,MAAM,yBAAO,IAAI;AACvB,QAAM,gBAAgB,0BAAQ,MAAM;AAClC,UAAM,MAAK,mBAAmB,oBAAI;AAClC,sBAAkB,KAAI,GAAG;AACzB,WAAO;AAAA,EACT,GAAG,CAAC,mBAAmB,GAAG,CAAC;AAE3B,QAAM,WAAW,0BACf,MAAO,eAAe,iBAAkB,CAAC,cAAc,cAAe,IAAI,IAC1E,CAAC,YAAY,aAAa,aAAa,CACzC;AAEA,QAAM,WAAW,0DAAuB,aAAa;AACrD,SACE,mDAAC;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,kCAAS,eAAe,EAAE,YAAY,cAAc;AACtF,0BAA0B,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/DSToolbarV2.js
CHANGED
|
@@ -47,38 +47,36 @@ var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
|
47
47
|
var import_ds_utilities2 = require("@elliemae/ds-utilities");
|
|
48
48
|
var import_uid = require("uid");
|
|
49
49
|
var import_DSToolbarV2Context = require("./DSToolbarV2Context");
|
|
50
|
-
var
|
|
50
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types");
|
|
51
51
|
var import_styled = require("./styled");
|
|
52
52
|
const DSToolbarV2 = (props) => {
|
|
53
|
-
const
|
|
54
|
-
(0, import_ds_utilities.useValidateTypescriptPropTypes)(
|
|
53
|
+
const propsWithDefaults = (0, import_ds_utilities.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
|
|
54
|
+
(0, import_ds_utilities.useValidateTypescriptPropTypes)(propsWithDefaults, import_react_desc_prop_types.DSToolbarV2Schema);
|
|
55
|
+
const { alignment, withDepth, compact, innerRef, children } = propsWithDefaults;
|
|
56
|
+
const globalsProps = (0, import_ds_utilities.useGetGlobalAttributes)(propsWithDefaults);
|
|
55
57
|
const toolbarUid = (0, import_react.useMemo)(() => `ds-toolbar-${(0, import_uid.uid)()}`, []);
|
|
56
58
|
const [itemReferences, setItemReferences] = (0, import_react.useState)({});
|
|
59
|
+
const [activeItem, setActiveItem] = (0, import_react.useState)("");
|
|
57
60
|
const registerReference = (0, import_react.useCallback)((itemId, ref) => {
|
|
58
61
|
setItemReferences((prevItemReferences) => __spreadProps(__spreadValues({}, prevItemReferences), { [itemId]: ref }));
|
|
59
62
|
}, [setItemReferences]);
|
|
63
|
+
const ctx = (0, import_react.useMemo)(() => ({ toolbarUid, registerReference, itemReferences, activeItem, setActiveItem }), [activeItem, itemReferences, registerReference, toolbarUid]);
|
|
60
64
|
return /* @__PURE__ */ import_react.default.createElement(import_DSToolbarV2Context.DSToolbarV2Context.Provider, {
|
|
61
|
-
value:
|
|
62
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_styled.StyledToolbarWrapper, {
|
|
65
|
+
value: ctx
|
|
66
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_styled.StyledToolbarWrapper, __spreadValues({
|
|
63
67
|
role: "toolbar",
|
|
64
68
|
"data-testid": "ds-toolbar-wrapper",
|
|
65
69
|
id: toolbarUid,
|
|
66
70
|
alignItems: "center",
|
|
67
71
|
justifyContent: alignment === "left" ? "flex-start" : "flex-end",
|
|
68
72
|
withDepth,
|
|
69
|
-
cols: import_react.default.Children.map(children, () => ["auto"]),
|
|
70
73
|
gutter: "xxs2",
|
|
71
74
|
compact,
|
|
72
75
|
ref: innerRef
|
|
73
|
-
}, children));
|
|
74
|
-
};
|
|
75
|
-
DSToolbarV2.propTypes = import_props.DSToolbarV2Schema;
|
|
76
|
-
DSToolbarV2.defaultProps = {
|
|
77
|
-
alignment: "right",
|
|
78
|
-
withDepth: true,
|
|
79
|
-
compact: false
|
|
76
|
+
}, globalsProps), children));
|
|
80
77
|
};
|
|
78
|
+
DSToolbarV2.propTypes = import_react_desc_prop_types.DSToolbarV2Schema;
|
|
81
79
|
DSToolbarV2.displayName = "DSToolbarV2";
|
|
82
80
|
const DSToolbarV2WithSchema = (0, import_ds_utilities2.describe)(DSToolbarV2).description("Toolbar");
|
|
83
|
-
DSToolbarV2WithSchema.propTypes =
|
|
81
|
+
DSToolbarV2WithSchema.propTypes = import_react_desc_prop_types.DSToolbarV2Schema;
|
|
84
82
|
//# sourceMappingURL=DSToolbarV2.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSToolbarV2.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React, { useCallback, useMemo, useState } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAsD;AACtD,
|
|
4
|
+
"sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAsD;AACtD,0BAIO;AACP,2BAAyB;AACzB,iBAAoB;AACpB,gCAAmC;AACnC,mCAAgD;AAChD,oBAAqC;AAGrC,MAAM,cAAqD,CAAC,UAAU;AACpE,QAAM,oBAAoB,sDAA6B,OAAO,yCAAY;AAE1E,0DAA+B,mBAAmB,8CAAiB;AAEnE,QAAM,EAAE,WAAW,WAAW,SAAS,UAAU,aAAa;AAE9D,QAAM,eAAe,gDAAuB,iBAAiB;AAE7D,QAAM,aAAa,0BAAQ,MAAM,cAAc,oBAAI,KAAK,CAAC,CAAC;AAE1D,QAAM,CAAC,gBAAgB,qBAAqB,2BAAS,CAAC,CAAC;AACvD,QAAM,CAAC,YAAY,iBAAiB,2BAAS,EAAE;AAE/C,QAAM,oBAAoB,8BACxB,CAAC,QAAgB,QAA6C;AAC5D,sBAAkB,CAAC,uBAAwB,iCAAK,qBAAL,EAAyB,CAAC,SAAS,IAAI,EAAE;AAAA,EACtF,GACA,CAAC,iBAAiB,CACpB;AAEA,QAAM,MAAM,0BACV,MAAO,GAAE,YAAY,mBAAmB,gBAAgB,YAAY,cAAc,IAClF,CAAC,YAAY,gBAAgB,mBAAmB,UAAU,CAC5D;AAEA,SACE,mDAAC,6CAAmB,UAAnB;AAAA,IAA4B,OAAO;AAAA,KAClC,mDAAC;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,mCAAS,WAAW,EAAE,YAAY,SAAS;AACzE,sBAAsB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -28,6 +28,9 @@ var import_react = require("react");
|
|
|
28
28
|
const DSToolbarV2Context = (0, import_react.createContext)({
|
|
29
29
|
registerReference: () => null,
|
|
30
30
|
itemReferences: {},
|
|
31
|
-
toolbarUid: ""
|
|
31
|
+
toolbarUid: "",
|
|
32
|
+
activeItem: "",
|
|
33
|
+
setActiveItem: () => {
|
|
34
|
+
}
|
|
32
35
|
});
|
|
33
36
|
//# sourceMappingURL=DSToolbarV2Context.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSToolbarV2Context.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAgD;
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAgD;AAUzC,MAAM,qBAAqB,gCAAmC;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
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/deprecated/DSToolbar.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAC9B,2BAAkC;AAClC,0BAA+C;AAC/C,qCAAoC;AACpC,yBAAiB;AACjB,0BAAyB;AACzB,4BAAoB;AACpB,mCAAsC;AAEtC,MAAM,YAAY;AAElB,MAAM,mBAAmB,4CAAkB,KAAK,EAAE,WAAW,MAAM,CAAC,EAAE,WAAW,WAAW,WAAY;AAAA,EACtG,iBAAiB,CAAC;AAAA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAC9B,2BAAkC;AAClC,0BAA+C;AAC/C,qCAAoC;AACpC,yBAAiB;AACjB,0BAAyB;AACzB,4BAAoB;AACpB,mCAAsC;AAEtC,MAAM,YAAY;AAElB,MAAM,mBAAmB,4CAAkB,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,yBAA8B,IAAI;AAEvD,QAAM,EAAE,oBAAoB,wDAAsB,EAAE,cAAc,iBAAiB,CAAC;AAEpF,SACE,mDAAC,kEACK,iBACA,aAFL;AAAA,IAGC,YAAY,EAAE,WAAW,WAAW,KAAK;AAAA,IACzC,UAAU,mCAAU,UAAU,YAAY;AAAA,IAC1C,WAAW;AAAA,MAEV,4CAAwB,QAAQ,CACnC;AAEJ;AAEA,MAAM,eAAe;AAAA,EACnB,gBAAgB,8BAAU,OAAO,YAAY,kDAAkD;AAAA,EAC/F,WAAW,8BAAU,KAAK,YAAY,iCAAiC,EAAE,aAAa,IAAI;AAAA,EAC1F,WAAW,8BAAU,MAAM,CAAC,SAAS,MAAM,CAAC,EACzC,YAAY,yCAAyC,EACrD,aAAa,OAAO;AAAA,EACvB,MAAM,8BAAU,MAAM,CAAC,UAAU,SAAS,CAAC,EAAE,YAAY,cAAc,EAAE,aAAa,QAAQ;AAAA,EAC9F,kBAAkB,8BAAU,KACzB,YAAY,qDAAqD,EACjE,aAAa,IAAI;AAAA,EACpB,UAAU,8BAAU,UAAU,CAAC,8BAAU,OAAO,8BAAU,MAAM,8BAAU,IAAI,CAAC,EAAE,YAAY,eAAe,EACzG;AAAA,EACH,UAAU,8BAAU,OAAO,YAAY,sCAAsC;AAC/E;AAEA,UAAU,YAAY;AACtB,UAAU,cAAc;AACxB,MAAM,oBAAoB,kCAAS,SAAS;AAC5C,kBAAkB,YAAY;AAI9B,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/deprecated/ToolbarGroup.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,wBAAsB;AACtB,2BAAkC;AAClC,qCAAoC;AAEpC,MAAM,YAAY;AAElB,MAAM,wBAAwB,4CAAkB,KAAK,EACnD,WACA,MACA,CAAC,EAAE,YAAa;AAAA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,wBAAsB;AACtB,2BAAkC;AAClC,qCAAoC;AAEpC,MAAM,YAAY;AAElB,MAAM,wBAAwB,4CAAkB,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,mDAAC;AAAA,EAAsB,YAAY,EAAE,MAAM;AAAA,GACxC,4CAAwB,UAAU,EAAE,KAAK,CAAC,CAC7C;AAGF,aAAa,YAAY;AAAA,EACvB,UAAU,0BAAU;AAAA,EACpB,MAAM,0BAAU;AAAA,EAChB,OAAO,0BAAU;AACnB;AAEA,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
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));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var react_desc_prop_types_exports = {};
|
|
39
|
+
__export(react_desc_prop_types_exports, {
|
|
40
|
+
DSToolbarItemV2Schema: () => DSToolbarItemV2Schema,
|
|
41
|
+
DSToolbarV2Schema: () => DSToolbarV2Schema,
|
|
42
|
+
defaultItemProps: () => defaultItemProps,
|
|
43
|
+
defaultProps: () => defaultProps
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
46
|
+
var React = __toESM(require("react"));
|
|
47
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
48
|
+
const defaultItemProps = {
|
|
49
|
+
render: () => {
|
|
50
|
+
},
|
|
51
|
+
isFirstItem: false
|
|
52
|
+
};
|
|
53
|
+
const defaultProps = {
|
|
54
|
+
alignment: "right",
|
|
55
|
+
withDepth: true,
|
|
56
|
+
compact: false
|
|
57
|
+
};
|
|
58
|
+
const DSToolbarV2Schema = __spreadProps(__spreadValues({}, import_ds_utilities.globalAttributesPropTypes), {
|
|
59
|
+
alignment: import_ds_utilities.PropTypes.oneOf(["right", "left"]).description("Whether to align the content left or right").defaultValue("right"),
|
|
60
|
+
withDepth: import_ds_utilities.PropTypes.bool.description("Whether to add a box-shadow to the container").defaultValue(true),
|
|
61
|
+
compact: import_ds_utilities.PropTypes.bool.description("Whether you want the compact version of the toolbar").defaultValue(false),
|
|
62
|
+
innerRef: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.func, import_ds_utilities.PropTypes.object]).description("Reference to attach to the wrapper")
|
|
63
|
+
});
|
|
64
|
+
const DSToolbarItemV2Schema = __spreadProps(__spreadValues({}, import_ds_utilities.globalAttributesPropTypes), {
|
|
65
|
+
render: import_ds_utilities.PropTypes.func.isRequired.description("render function").defaultValue(() => {
|
|
66
|
+
}),
|
|
67
|
+
isFirstItem: import_ds_utilities.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)
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAAqD;AAmB9C,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,gDAD4B;AAAA,EAE/B,WAAW,8BAAU,MAAM,CAAC,SAAS,MAAM,CAAC,EACzC,YAAY,4CAA4C,EACxD,aAAa,OAAO;AAAA,EACvB,WAAW,8BAAU,KAAK,YAAY,8CAA8C,EAAE,aAAa,IAAI;AAAA,EACvG,SAAS,8BAAU,KAAK,YAAY,qDAAqD,EAAE,aAAa,KAAK;AAAA,EAC7G,UAAU,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,MAAM,CAAC,EAAE,YAAY,oCAAoC;AACpH;AAEO,MAAM,wBAAwB,iCAChC,gDADgC;AAAA,EAEnC,QAAQ,8BAAU,KAAK,WAAW,YAAY,iBAAiB,EAAE,aAAa,MAAM;AAAA,EAAC,CAAC;AAAA,EACtF,aAAa,8BAAU,KACpB,YACC,uGACF,EACC,aAAa,KAAK;AACvB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/styled.js
CHANGED
|
@@ -31,11 +31,11 @@ var import_ds_grid = __toESM(require("@elliemae/ds-grid"));
|
|
|
31
31
|
const StyledToolbarWrapper = (0, import_ds_system.styled)(import_ds_grid.default)`
|
|
32
32
|
background-color: ${(props) => props.theme.colors.neutral["000"]};
|
|
33
33
|
|
|
34
|
-
min-height: ${(props) => props.compact ? "28px" : "
|
|
34
|
+
min-height: ${(props) => props.compact ? "28px" : "36px"};
|
|
35
35
|
max-height: ${(props) => props.theme.space.xxl};
|
|
36
36
|
|
|
37
37
|
padding: 0 ${(props) => props.theme.space.xxs};
|
|
38
|
-
|
|
38
|
+
grid-auto-flow: column;
|
|
39
39
|
box-shadow: ${(props) => !props.withDepth ? "none" : "0 1px 5px 0 rgb(0 0 0 / 13%), 0 2px 4px 0 rgb(0 0 0 / 20%)"};
|
|
40
40
|
`;
|
|
41
41
|
const StyledToolbarItem = (0, import_ds_system.styled)(import_ds_grid.default)``;
|
package/dist/cjs/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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' : '
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAuB;AACvB,qBAAiB;AAEV,MAAM,uBAAuB,6BAAO,sBAAI;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,6BAAO,sBAAI;AAErC,MAAM,kBAAkB,6BAAO,sBAAI;AAAA;AAAA;AAAA,sBAGpB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,12 +27,15 @@ var React = __toESM(require("react"));
|
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_DSToolbarV2Context = require("./DSToolbarV2Context");
|
|
29
29
|
const useToolbarItemHandlers = (toolbarItemId) => {
|
|
30
|
-
const { toolbarUid, itemReferences } = (0, import_react.useContext)(import_DSToolbarV2Context.DSToolbarV2Context);
|
|
30
|
+
const { toolbarUid, itemReferences, setActiveItem } = (0, import_react.useContext)(import_DSToolbarV2Context.DSToolbarV2Context);
|
|
31
|
+
const onFocus = (0, import_react.useCallback)(() => {
|
|
32
|
+
setActiveItem(toolbarItemId);
|
|
33
|
+
}, [setActiveItem, toolbarItemId]);
|
|
31
34
|
const onKeyDown = (0, import_react.useCallback)((e) => {
|
|
32
35
|
const toolbarItems = [...document.querySelectorAll(`#${toolbarUid} .ds-toolbar-item`)];
|
|
33
36
|
let nextToolbarItemIndex = -1;
|
|
37
|
+
const toolbarItemIndex = toolbarItems.findIndex((domElem) => domElem.id === toolbarItemId);
|
|
34
38
|
if (["ArrowLeft", "ArrowRight"].includes(e.code)) {
|
|
35
|
-
const toolbarItemIndex = toolbarItems.findIndex((domElem) => domElem.id === toolbarItemId);
|
|
36
39
|
nextToolbarItemIndex = toolbarItemIndex + (e.code === "ArrowLeft" ? -1 : 1);
|
|
37
40
|
} else if (e.code === "Home") {
|
|
38
41
|
nextToolbarItemIndex = 0;
|
|
@@ -47,6 +50,6 @@ const useToolbarItemHandlers = (toolbarItemId) => {
|
|
|
47
50
|
ref.current.focus();
|
|
48
51
|
}
|
|
49
52
|
}, [toolbarUid, toolbarItemId, itemReferences]);
|
|
50
|
-
return { onKeyDown };
|
|
53
|
+
return { onKeyDown, onFocus };
|
|
51
54
|
};
|
|
52
55
|
//# sourceMappingURL=useToolbarItemHandlers.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useToolbarItemHandlers.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwC;AACxC,gCAAmC;AAE5B,MAAM,yBAAyB,CACpC,
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwC;AACxC,gCAAmC;AAE5B,MAAM,yBAAyB,CACpC,kBAIG;AACH,QAAM,EAAE,YAAY,gBAAgB,kBAAkB,6BAAW,4CAAkB;AAEnF,QAAM,UAAmC,8BAAY,MAAM;AACzD,kBAAc,aAAa;AAAA,EAC7B,GAAG,CAAC,eAAe,aAAa,CAAC;AAEjC,QAAM,YAAwC,8BAC5C,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
|
}
|
|
@@ -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 {
|
|
22
|
+
import {
|
|
23
|
+
useMemoMergePropsWithDefault,
|
|
24
|
+
useValidateTypescriptPropTypes,
|
|
25
|
+
useGetGlobalAttributes
|
|
26
|
+
} from "@elliemae/ds-utilities";
|
|
23
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
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/DSToolbar.tsx"],
|
|
4
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,
|
|
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,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
|
@@ -4,11 +4,11 @@ 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 '@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' : '
|
|
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.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Toolbar",
|
|
6
6
|
"files": [
|
|
@@ -87,28 +87,28 @@
|
|
|
87
87
|
"indent": 4
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@elliemae/ds-button": "3.1.0-next.
|
|
91
|
-
"@elliemae/ds-classnames": "3.1.0-next.
|
|
92
|
-
"@elliemae/ds-grid": "3.1.0-next.
|
|
93
|
-
"@elliemae/ds-icons": "3.1.0-next.
|
|
94
|
-
"@elliemae/ds-popper": "3.1.0-next.
|
|
95
|
-
"@elliemae/ds-shared": "3.1.0-next.
|
|
96
|
-
"@elliemae/ds-system": "3.1.0-next.
|
|
97
|
-
"@elliemae/ds-utilities": "3.1.0-next.
|
|
90
|
+
"@elliemae/ds-button": "3.1.0-next.16",
|
|
91
|
+
"@elliemae/ds-classnames": "3.1.0-next.16",
|
|
92
|
+
"@elliemae/ds-grid": "3.1.0-next.16",
|
|
93
|
+
"@elliemae/ds-icons": "3.1.0-next.16",
|
|
94
|
+
"@elliemae/ds-popper": "3.1.0-next.16",
|
|
95
|
+
"@elliemae/ds-shared": "3.1.0-next.16",
|
|
96
|
+
"@elliemae/ds-system": "3.1.0-next.16",
|
|
97
|
+
"@elliemae/ds-utilities": "3.1.0-next.16",
|
|
98
98
|
"prop-types": "~15.8.1",
|
|
99
99
|
"uid": "2.0.0"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@testing-library/jest-dom": "~5.16.
|
|
103
|
-
"@testing-library/react": "~12.1.
|
|
102
|
+
"@testing-library/jest-dom": "~5.16.4",
|
|
103
|
+
"@testing-library/react": "~12.1.3",
|
|
104
104
|
"@testing-library/user-event": "~13.5.0",
|
|
105
|
-
"styled-components": "~5.3.
|
|
105
|
+
"styled-components": "~5.3.5"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"lodash": "^4.17.21",
|
|
109
109
|
"react": "^17.0.2",
|
|
110
110
|
"react-dom": "^17.0.2",
|
|
111
|
-
"styled-components": "^5.3.
|
|
111
|
+
"styled-components": "^5.3.5"
|
|
112
112
|
},
|
|
113
113
|
"publishConfig": {
|
|
114
114
|
"access": "public",
|
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_ds_utilities = require("@elliemae/ds-utilities");
|
|
28
|
-
const DSToolbarV2Schema = {
|
|
29
|
-
alignment: import_ds_utilities.PropTypes.oneOf(["right", "left"]).description("Whether to align the content left or right").defaultValue("right"),
|
|
30
|
-
withDepth: import_ds_utilities.PropTypes.bool.description("Whether to add a box-shadow to the container").defaultValue(true),
|
|
31
|
-
compact: import_ds_utilities.PropTypes.bool.description("Whether you want the compact version of the toolbar").defaultValue(false),
|
|
32
|
-
innerRef: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.func, import_ds_utilities.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 '@elliemae/ds-utilities';\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,0BAA0B;AAEnB,MAAM,oBAAoB;AAAA,EAC/B,WAAW,8BAAU,MAAM,CAAC,SAAS,MAAM,CAAC,EACzC,YAAY,4CAA4C,EACxD,aAAa,OAAO;AAAA,EACvB,WAAW,8BAAU,KAAK,YAAY,8CAA8C,EAAE,aAAa,IAAI;AAAA,EACvG,SAAS,8BAAU,KAAK,YAAY,qDAAqD,EAAE,aAAa,KAAK;AAAA,EAC7G,UAAU,8BAAU,UAAU,CAAC,8BAAU,MAAM,8BAAU,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 "@elliemae/ds-utilities";
|
|
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
|
package/dist/esm/props.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/props.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from '@elliemae/ds-utilities';\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"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEO,MAAM,oBAAoB;AAAA,EAC/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;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|