@elliemae/ds-app-picker 3.0.0-next.9 → 3.0.1

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.
@@ -2,65 +2,31 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
5
  var __getProtoOf = Object.getPrototypeOf;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
22
- var __objRest = (source, exclude) => {
23
- var target = {};
24
- for (var prop in source)
25
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
- target[prop] = source[prop];
27
- if (source != null && __getOwnPropSymbols)
28
- for (var prop of __getOwnPropSymbols(source)) {
29
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
- target[prop] = source[prop];
31
- }
32
- return target;
33
- };
34
7
  var __export = (target, all) => {
35
8
  for (var name in all)
36
9
  __defProp(target, name, { get: all[name], enumerable: true });
37
10
  };
38
- var __reExport = (target, module2, copyDefault, desc) => {
39
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
40
- for (let key of __getOwnPropNames(module2))
41
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
42
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
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 });
43
16
  }
44
- return target;
17
+ return to;
45
18
  };
46
- var __toESM = (module2, isNodeMode) => {
47
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
48
- };
49
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
50
- return (module2, temp) => {
51
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
52
- };
53
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
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);
54
21
  var AppPickerImpl_exports = {};
55
22
  __export(AppPickerImpl_exports, {
56
23
  default: () => AppPickerImpl_default
57
24
  });
25
+ module.exports = __toCommonJS(AppPickerImpl_exports);
58
26
  var React = __toESM(require("react"));
59
27
  var import_react = __toESM(require("react"));
60
- var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
61
- var import_lodash = require("lodash");
28
+ var import_ds_chip = require("@elliemae/ds-chip");
62
29
  var import_utils = require("./utils");
63
- var import_ds_truncated_tooltip_text = require("@elliemae/ds-truncated-tooltip-text");
64
30
  var import_styles = require("./styles");
65
31
  const AppPickerImpl = ({
66
32
  apps = [],
@@ -90,7 +56,7 @@ const AppPickerImpl = ({
90
56
  allFocusableButtons?.current[0]?.focus();
91
57
  }
92
58
  }, [wrapperRef]);
93
- const handleKeyDown = (e) => {
59
+ const handleKeyDown = (0, import_react.useCallback)((e) => {
94
60
  switch (e.key) {
95
61
  case import_utils.keys.ESC:
96
62
  triggerRef?.current?.focus();
@@ -110,8 +76,8 @@ const AppPickerImpl = ({
110
76
  default:
111
77
  break;
112
78
  }
113
- };
114
- const handleOnClick = (0, import_react.useCallback)((e, app) => {
79
+ }, [close, triggerRef]);
80
+ const handleOnClick = (0, import_react.useCallback)((app) => (e) => {
115
81
  if (app.onClick)
116
82
  app.onClick(e, app);
117
83
  }, []);
@@ -122,56 +88,72 @@ const AppPickerImpl = ({
122
88
  close();
123
89
  }
124
90
  }, [onKeyDown, close]);
125
- const buildRows = (appList, prevIndex = 0) => {
126
- const rows = (0, import_lodash.chunk)(appList, 3);
127
- const formattedRows = rows.map((row, index) => /* @__PURE__ */ import_react.default.createElement(import_styles.StyledRow, {
128
- key: index
129
- }, row.map((app, key) => {
130
- const _a = app, { label, disabled, selected, icon: Icon, id } = _a, otherProps = __objRest(_a, ["label", "disabled", "selected", "icon", "id"]);
131
- return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledChip, __spreadValues({
132
- key,
133
- onClick: (e) => handleOnClick(e, app),
91
+ const totalAppsLenght = (0, import_react.useMemo)(() => apps.length + customApps.length, []);
92
+ const buildRows = (0, import_react.useCallback)((appList, prevIndex = 0, title) => {
93
+ const formattedRows = appList.map((app, index) => {
94
+ const { label, disabled, selected, icon: Icon, id } = app;
95
+ return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledListItem, null, /* @__PURE__ */ import_react.default.createElement(import_ds_chip.DSChip, {
96
+ key: index,
97
+ onClick: handleOnClick(app),
134
98
  onKeyDown: handleKeyDown,
135
99
  "data-testid": "app-picker__chip",
136
100
  "aria-disabled": disabled,
137
101
  disabled,
138
102
  selected,
139
103
  "aria-selected": selected,
140
- "aria-setsize": apps.length + customApps.length,
141
- "aria-posinset": key + prevIndex,
142
- id
143
- }, (0, import_ds_props_helpers.getDataProps)(otherProps)), /* @__PURE__ */ import_react.default.createElement(Icon, {
144
- className: "app-picker__icon",
145
- size: "m"
146
- }), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledChipLabel, null, /* @__PURE__ */ import_react.default.createElement(import_ds_truncated_tooltip_text.SimpleTruncatedTooltipText, {
147
- value: label,
148
- placement: "bottom"
149
- })));
150
- })));
104
+ "aria-setsize": totalAppsLenght,
105
+ "aria-posinset": index + prevIndex,
106
+ id,
107
+ "aria-label": `${label}. ${title}`,
108
+ icon: () => /* @__PURE__ */ import_react.default.createElement(Icon, {
109
+ className: "app-picker__icon",
110
+ size: "m"
111
+ }),
112
+ label
113
+ }));
114
+ });
151
115
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, formattedRows);
152
- };
153
- const AppsRows = () => buildRows(apps, 1);
154
- const CustomRows = () => buildRows(customApps, apps.length);
116
+ }, [handleKeyDown, handleOnClick, totalAppsLenght]);
117
+ const AppsRows = (0, import_react.useMemo)(() => buildRows(apps, 1, sectionTitle), []);
118
+ const CustomRows = (0, import_react.useMemo)(() => buildRows(customApps, apps.length, customSectionTitle), []);
119
+ const layout = (0, import_react.useMemo)(() => {
120
+ const cols = ["repeat(3, 92px)"];
121
+ let appsRows = 0;
122
+ let customRows = 0;
123
+ let rows = [];
124
+ if (apps.length > 0) {
125
+ appsRows = apps.length / 3;
126
+ rows.push("68px", `repeat(${appsRows}, 68px})`);
127
+ }
128
+ if (customApps.length > 0) {
129
+ customRows = customApps.length / 3;
130
+ rows.push("9px", "68px", `repeat(${customRows}, 68px})`);
131
+ }
132
+ return {
133
+ rows,
134
+ cols
135
+ };
136
+ }, [apps.length, customApps.length]);
155
137
  return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledWrapper, {
156
138
  role: "listbox",
157
139
  ref: wrapperRef,
158
140
  onKeyDown: handleOnKeyDownWrapper,
159
141
  "data-testid": "app-picker__wrapper",
160
- isOverflow
161
- }, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTitle, {
162
- "data-testid": "app-picker__main-title",
142
+ isOverflow,
143
+ cols: layout.cols,
144
+ rows: layout.rows,
145
+ forwardedAs: "ul"
146
+ }, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledListItemFullRow, {
163
147
  "aria-hidden": true
164
- }, sectionTitle), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledGrid, {
165
- "data-testid": "app-picker__main-grid"
166
- }, /* @__PURE__ */ import_react.default.createElement(AppsRows, null)), !!customApps.length && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledSeparator, {
148
+ }, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTitle, {
149
+ "data-testid": "app-picker__main-title"
150
+ }, sectionTitle)), AppsRows, customApps.length > 0 && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledListItemFullRow, {
167
151
  "aria-hidden": true
168
- }), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTitle, {
169
- "data-testid": "app-picker__custom-title",
152
+ }, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledSeparator, null)), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledListItemFullRow, {
170
153
  "aria-hidden": true
171
- }, customSectionTitle), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledGrid, {
172
- "data-testid": "app-picker__custom-grid"
173
- }, /* @__PURE__ */ import_react.default.createElement(CustomRows, null))));
154
+ }, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTitle, {
155
+ "data-testid": "app-picker__custom-title"
156
+ }, customSectionTitle)), CustomRows));
174
157
  };
175
158
  var AppPickerImpl_default = AppPickerImpl;
176
- module.exports = __toCommonJS(AppPickerImpl_exports);
177
159
  //# sourceMappingURL=AppPickerImpl.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/AppPickerImpl.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable react/prop-types */\n/* eslint-disable react/no-array-index-key */\n/* eslint-disable max-lines */\nimport React, { useEffect, useCallback, useRef } from 'react';\nimport { getDataProps } from '@elliemae/ds-props-helpers';\nimport { chunk } from 'lodash';\nimport { keys } from './utils';\nimport { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport {\n StyledWrapper,\n StyledChip,\n StyledChipLabel,\n StyledTitle,\n StyledGrid,\n StyledRow,\n StyledSeparator,\n} from './styles';\n\nconst AppPickerImpl: DSAppPickerImplType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n close = () => null,\n wrapperRef,\n onKeyDown,\n triggerRef,\n isOverflow,\n}) => {\n const allFocusableButtons = useRef<HTMLButtonElement[]>([]);\n const selectedButton = useRef<number | null>(null);\n\n useEffect(() => {\n wrapperRef?.current?.querySelectorAll('button').forEach((e, index) => {\n if (!e.hasAttribute('disabled')) {\n allFocusableButtons?.current?.push(e);\n }\n if (e.getAttribute('aria-selected') === 'true') {\n selectedButton.current = index;\n }\n });\n\n if (selectedButton.current) {\n wrapperRef?.current?.querySelectorAll('button')[selectedButton.current].focus();\n } else {\n allFocusableButtons?.current[0]?.focus();\n }\n }, [wrapperRef]);\n\n // eslint-disable-next-line max-statements\n const handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case keys.ESC:\n triggerRef?.current?.focus();\n close();\n break;\n case keys.TAB:\n if (e.shiftKey) {\n if (e.target === allFocusableButtons.current[0]) {\n e.preventDefault();\n allFocusableButtons?.current[allFocusableButtons.current.length - 1]?.focus();\n }\n } else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {\n e.preventDefault();\n allFocusableButtons?.current[0]?.focus();\n }\n break;\n default:\n break;\n }\n };\n\n const handleOnClick = useCallback((e, app) => {\n if (app.onClick) app.onClick(e, app);\n }, []);\n\n const handleOnKeyDownWrapper = useCallback(\n (e) => {\n if (onKeyDown) onKeyDown(e);\n if (!onKeyDown && e.key === keys.ESC) {\n close();\n }\n },\n [onKeyDown, close],\n );\n\n const buildRows = (appList: AppItemType[], prevIndex = 0): JSX.Element => {\n const rows = chunk(appList, 3); // divides array in subarrays of 3 items\n const formattedRows = rows.map((row, index) => (\n <StyledRow key={index}>\n {row.map((app, key) => {\n const { label, disabled, selected, icon: Icon, id, ...otherProps } = app;\n return (\n <StyledChip\n key={key}\n onClick={(e) => handleOnClick(e, app)}\n onKeyDown={handleKeyDown}\n data-testid=\"app-picker__chip\"\n aria-disabled={disabled}\n disabled={disabled}\n selected={selected}\n aria-selected={selected}\n aria-setsize={apps.length + customApps.length}\n aria-posinset={key + prevIndex}\n id={id}\n {...getDataProps(otherProps)}\n >\n <Icon className=\"app-picker__icon\" size=\"m\" />\n <StyledChipLabel>\n <SimpleTruncatedTooltipText value={label} placement=\"bottom\" />\n </StyledChipLabel>\n </StyledChip>\n );\n })}\n </StyledRow>\n ));\n return <>{formattedRows}</>;\n };\n\n const AppsRows = () => buildRows(apps, 1);\n const CustomRows = () => buildRows(customApps, apps.length);\n\n return (\n <StyledWrapper\n role=\"listbox\"\n ref={wrapperRef}\n onKeyDown={handleOnKeyDownWrapper}\n data-testid=\"app-picker__wrapper\"\n isOverflow={isOverflow}\n >\n <StyledTitle data-testid=\"app-picker__main-title\" aria-hidden>\n {sectionTitle}\n </StyledTitle>\n <StyledGrid data-testid=\"app-picker__main-grid\">\n <AppsRows />\n </StyledGrid>\n {!!customApps.length && (\n <>\n <StyledSeparator aria-hidden />\n <StyledTitle data-testid=\"app-picker__custom-title\" aria-hidden>\n {customSectionTitle}\n </StyledTitle>\n <StyledGrid data-testid=\"app-picker__custom-grid\">\n <CustomRows />\n </StyledGrid>\n </>\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AA,KAEA,mDAAC,2BAAD;AAAA,IAAa,eAAY;AAAA,IAAyB,eAAW;AAAA,KAC1D,eAEH,mDAAC,0BAAD;AAAA,IAAY,eAAY;AAAA,KACtB,mDAAC,UAAD,QAED,CAAC,CAAC,WAAW,UACZ,wFACE,mDAAC,+BAAD;AAAA,IAAiB,eAAW;AAAA,MAC5B,mDAAC,2BAAD;AAAA,IAAa,eAAY;AAAA,IAA2B,eAAW;AAAA,KAC5D,qBAEH,mDAAC,0BAAD;AAAA,IAAY,eAAY;AAAA,KACtB,mDAAC,YAAD;AAAA;AAQZ,IAAO,wBAAQ;",
4
+ "sourcesContent": ["/* eslint-disable react/prop-types */\n/* eslint-disable react/no-array-index-key */\n/* eslint-disable max-lines */\nimport React, { useEffect, useCallback, useRef, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils';\nimport { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles';\n\nconst AppPickerImpl: DSAppPickerImplType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n close = () => null,\n wrapperRef,\n onKeyDown,\n triggerRef,\n isOverflow,\n}) => {\n const allFocusableButtons = useRef<HTMLButtonElement[]>([]);\n const selectedButton = useRef<number | null>(null);\n\n useEffect(() => {\n wrapperRef?.current?.querySelectorAll('button').forEach((e, index) => {\n if (!e.hasAttribute('disabled')) {\n allFocusableButtons?.current?.push(e);\n }\n if (e.getAttribute('aria-selected') === 'true') {\n selectedButton.current = index;\n }\n });\n\n if (selectedButton.current) {\n wrapperRef?.current?.querySelectorAll('button')[selectedButton.current].focus();\n } else {\n allFocusableButtons?.current[0]?.focus();\n }\n }, [wrapperRef]);\n\n // eslint-disable-next-line max-statements\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n switch (e.key) {\n case keys.ESC:\n triggerRef?.current?.focus();\n close();\n break;\n case keys.TAB:\n if (e.shiftKey) {\n if (e.target === allFocusableButtons.current[0]) {\n e.preventDefault();\n allFocusableButtons?.current[allFocusableButtons.current.length - 1]?.focus();\n }\n } else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {\n e.preventDefault();\n allFocusableButtons?.current[0]?.focus();\n }\n break;\n default:\n break;\n }\n },\n [close, triggerRef],\n );\n\n const handleOnClick = useCallback(\n (app: AppItemType) => (e: React.MouseEvent) => {\n if (app.onClick) app.onClick(e, app);\n },\n [],\n );\n\n const handleOnKeyDownWrapper = useCallback(\n (e) => {\n if (onKeyDown) onKeyDown(e);\n if (!onKeyDown && e.key === keys.ESC) {\n close();\n }\n },\n [onKeyDown, close],\n );\n\n const totalAppsLenght = useMemo(() => apps.length + customApps.length, []);\n\n const buildRows = useCallback(\n (appList: AppItemType[], prevIndex = 0, title: string): JSX.Element => {\n const formattedRows = appList.map((app, index) => {\n const { label, disabled, selected, icon: Icon, id } = app;\n return (\n <StyledListItem>\n <DSChip\n key={index}\n onClick={handleOnClick(app)}\n onKeyDown={handleKeyDown}\n data-testid=\"app-picker__chip\"\n aria-disabled={disabled}\n disabled={disabled}\n selected={selected}\n aria-selected={selected}\n aria-setsize={totalAppsLenght}\n aria-posinset={index + prevIndex}\n id={id}\n aria-label={`${label}. ${title}`}\n icon={() => <Icon className=\"app-picker__icon\" size=\"m\" />}\n label={label}\n ></DSChip>\n </StyledListItem>\n );\n });\n\n return <>{formattedRows}</>;\n },\n [handleKeyDown, handleOnClick, totalAppsLenght],\n );\n\n const AppsRows = useMemo(() => buildRows(apps, 1, sectionTitle), []);\n const CustomRows = useMemo(() => buildRows(customApps, apps.length, customSectionTitle), []);\n\n const layout = useMemo(() => {\n const cols = ['repeat(3, 92px)'];\n let appsRows = 0;\n let customRows = 0;\n let rows = [];\n if (apps.length > 0) {\n appsRows = apps.length / 3;\n rows.push('68px', `repeat(${appsRows}, 68px})`);\n }\n if (customApps.length > 0) {\n customRows = customApps.length / 3;\n rows.push('9px', '68px', `repeat(${customRows}, 68px})`);\n }\n return {\n rows,\n cols,\n };\n }, [apps.length, customApps.length]);\n\n return (\n <StyledWrapper\n role=\"listbox\"\n ref={wrapperRef}\n onKeyDown={handleOnKeyDownWrapper}\n data-testid=\"app-picker__wrapper\"\n isOverflow={isOverflow}\n cols={layout.cols}\n rows={layout.rows}\n forwardedAs=\"ul\"\n >\n <StyledListItemFullRow aria-hidden>\n <StyledTitle data-testid=\"app-picker__main-title\">{sectionTitle}</StyledTitle>\n </StyledListItemFullRow>\n {AppsRows}\n {customApps.length > 0 && (\n <>\n <StyledListItemFullRow aria-hidden>\n <StyledSeparator />\n </StyledListItemFullRow>\n <StyledListItemFullRow aria-hidden>\n <StyledTitle data-testid=\"app-picker__custom-title\">{customSectionTitle}</StyledTitle>\n </StyledListItemFullRow>\n {CustomRows}\n </>\n )}\n </StyledWrapper>\n );\n};\n\nexport default AppPickerImpl;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAA+D;AAC/D,qBAAuB;AACvB,mBAAqB;AAErB,oBAAmG;AAEnG,MAAM,gBAAqC,CAAC;AAAA,EAC1C,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,QAAQ,MAAM;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,sBAAsB,yBAA4B,CAAC,CAAC;AAC1D,QAAM,iBAAiB,yBAAsB,IAAI;AAEjD,8BAAU,MAAM;AACd,gBAAY,SAAS,iBAAiB,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU;AACpE,UAAI,CAAC,EAAE,aAAa,UAAU,GAAG;AAC/B,6BAAqB,SAAS,KAAK,CAAC;AAAA,MACtC;AACA,UAAI,EAAE,aAAa,e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ACA,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,aAAY;AAAA,KAEZ,mDAAC;AAAA,IAAsB,eAAW;AAAA,KAChC,mDAAC;AAAA,IAAY,eAAY;AAAA,KAA0B,YAAa,CAClE,GACC,UACA,WAAW,SAAS,KACnB,wFACE,mDAAC;AAAA,IAAsB,eAAW;AAAA,KAChC,mDAAC,mCAAgB,CACnB,GACA,mDAAC;AAAA,IAAsB,eAAW;AAAA,KAChC,mDAAC;AAAA,IAAY,eAAY;AAAA,KAA4B,kBAAmB,CAC1E,GACC,UACH,CAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
6
6
  "names": []
7
7
  }
@@ -4,40 +4,33 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
11
10
  };
12
- var __reExport = (target, module2, copyDefault, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
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 });
17
16
  }
18
- return target;
17
+ return to;
19
18
  };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
- return (module2, temp) => {
25
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
- };
27
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
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);
28
21
  var DSAppPicker_exports = {};
29
22
  __export(DSAppPicker_exports, {
30
23
  AppPickerWithSchema: () => AppPickerWithSchema,
31
24
  DSAppPicker: () => DSAppPicker,
32
25
  default: () => DSAppPicker_default
33
26
  });
27
+ module.exports = __toCommonJS(DSAppPicker_exports);
34
28
  var React = __toESM(require("react"));
35
29
  var import_react = __toESM(require("react"));
36
- var import_react_desc = require("react-desc");
37
30
  var import_ds_icons = require("@elliemae/ds-icons");
38
- var import_ds_button = __toESM(require("@elliemae/ds-button"));
39
- var import_ds_popover = __toESM(require("@elliemae/ds-popover"));
31
+ var import_ds_button = require("@elliemae/ds-button");
40
32
  var import_ds_utilities = require("@elliemae/ds-utilities");
33
+ var import_ds_popover = __toESM(require("@elliemae/ds-popover"));
41
34
  var import_AppPickerImpl = __toESM(require("./AppPickerImpl"));
42
35
  var import_propTypes = require("./propTypes");
43
36
  const DSAppPicker = ({
@@ -107,17 +100,18 @@ const DSAppPicker = ({
107
100
  triggerRef: triggerRef || defaultTriggerRef,
108
101
  isOverflow
109
102
  });
110
- const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ import_react.default.createElement(import_ds_button.default, {
103
+ const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ import_react.default.createElement(import_ds_button.DSButtonV2, {
111
104
  "data-testid": "app-picker__button",
112
105
  id: "app-picker__button",
113
- buttonType: "text",
114
- icon: /* @__PURE__ */ import_react.default.createElement(Icon, null),
106
+ buttonType: "icon",
107
+ "aria-haspopup": "true",
108
+ "aria-expanded": open || isOpen,
115
109
  innerRef: (0, import_ds_utilities.mergeRefs)(ref, defaultTriggerRef),
116
110
  onClick: (e) => {
117
111
  onClick(e);
118
112
  setOpen(true);
119
113
  }
120
- }));
114
+ }, /* @__PURE__ */ import_react.default.createElement(Icon, null)));
121
115
  return /* @__PURE__ */ import_react.default.createElement(import_ds_popover.default, {
122
116
  content: /* @__PURE__ */ import_react.default.createElement(AppPickerContent, null),
123
117
  isOpen: typeof isOpen === "boolean" ? isOpen : open,
@@ -133,9 +127,8 @@ const DSAppPicker = ({
133
127
  }
134
128
  });
135
129
  };
136
- DSAppPicker.propTypes = import_propTypes.propTypes;
137
- const AppPickerWithSchema = (0, import_react_desc.describe)(DSAppPicker);
130
+ DSAppPicker.displayName = "DSAppPicker";
131
+ const AppPickerWithSchema = (0, import_ds_utilities.describe)(DSAppPicker);
138
132
  AppPickerWithSchema.propTypes = import_propTypes.propTypes;
139
133
  var DSAppPicker_default = DSAppPicker;
140
- module.exports = __toCommonJS(DSAppPicker_exports);
141
134
  //# sourceMappingURL=DSAppPicker.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/DSAppPicker.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React, { useState, useEffect, useRef } from 'react';\nimport { describe } from 'react-desc';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport DSButton from '@elliemae/ds-button';\nimport DSPopover from '@elliemae/ds-popover';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport AppPickerImpl from './AppPickerImpl';\nimport { propTypes } from './propTypes';\nimport type { DSAppPickerType } from './types/AppPickerTypes';\n\nconst DSAppPicker: DSAppPickerType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n icon: Icon = () => <MenuPicker fill={['brand-primary', 700]} size=\"m\" />,\n renderTrigger,\n isOpen,\n onClose = () => null,\n actionRef,\n onKeyDown,\n onClick = () => null,\n onClickOutside = () => null,\n triggerRef,\n}) => {\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<HTMLUListElement>(null);\n const defaultTriggerRef = useRef(null);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToIndex = (index) => {\n if (wrapperRef.current) {\n const parent = wrapperRef.current;\n const buttons = [...parent.querySelectorAll('button')];\n buttons[index].focus();\n }\n };\n }\n }, [actionRef, apps, customApps]);\n\n useEffect(() => {\n setTimeout(() => {\n if (wrapperRef.current) {\n const { scrollHeight, clientHeight } = wrapperRef.current;\n if (scrollHeight > clientHeight) return setIsOverflow(true);\n }\n return setIsOverflow(false);\n });\n }, [isOpen, open]);\n\n const handleOnClose = () => {\n if (typeof isOpen === 'boolean') {\n setOpen(isOpen);\n } else {\n setOpen(false);\n }\n onClose();\n };\n\n const handleOnClickOutside = (e: MouseEvent) => {\n setOpen(false);\n onClose();\n onClickOutside(e);\n };\n\n const AppPickerContent = () => (\n <AppPickerImpl\n apps={apps}\n customApps={customApps}\n sectionTitle={sectionTitle}\n customSectionTitle={customSectionTitle}\n close={handleOnClose}\n wrapperRef={wrapperRef}\n onKeyDown={onKeyDown}\n triggerRef={triggerRef || defaultTriggerRef}\n isOverflow={isOverflow}\n />\n );\n\n const RenderTrigger =\n renderTrigger ||\n (({ ref }) => (\n <DSButton\n data-testid=\"app-picker__button\"\n id=\"app-picker__button\"\n buttonType=\"text\"\n icon={<Icon />}\n innerRef={mergeRefs(ref, defaultTriggerRef)}\n onClick={(e) => {\n onClick(e);\n setOpen(true);\n }}\n />\n ));\n\n return (\n <DSPopover\n content={<AppPickerContent />}\n isOpen={typeof isOpen === 'boolean' ? isOpen : open}\n onClickOutside={handleOnClickOutside}\n placement=\"bottom\"\n interactionType=\"click\"\n renderTrigger={RenderTrigger}\n showArrow\n style={{\n padding: '0',\n maxWidth: '1000px',\n width: 'fit-content',\n }}\n />\n );\n};\n\nDSAppPicker.propTypes = propTypes;\n\nconst AppPickerWithSchema = describe(DSAppPicker);\nAppPickerWithSchema.propTypes = propTypes;\n\nexport { DSAppPicker, AppPickerWithSchema };\nexport default DSAppPicker;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAmD;AACnD,wBAAyB;AACzB,sBAA2B;AAC3B,uBAAqB;AACrB,wBAAsB;AACtB,0BAA0B;AAC1B,2BAA0B;AAC1B,uBAA0B;AAG1B,MAAM,cAA+B,CAAC;AAAA,EACpC,OAAO;AAAA,EACP,aAAa;AAAA,EACb,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,MAAM,OAAO,MAAM,mDAAC,4BAAD;AAAA,IAAY,MAAM,CAAC,iBAAiB;AAAA,IAAM,MAAK;AAAA;AAAA,EAClE;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB,iBAAiB,MAAM;AAAA,EACvB;AAAA,MACI;AACJ,QAAM,CAAC,MAAM,WAAW,2BAAS;AACjC,QAAM,CAAC,YAAY,iBAAiB,2BAAS;AAC7C,QAAM,aAAa,yBAAyB;AAC5C,QAAM,oBAAoB,yBAAO;AAEjC,8BAAU,MAAM;AACd,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,eAAe,CAAC,UAAU;AAC1C,YAAI,WAAW,SAAS;AACtB,gBAAM,SAAS,WAAW;AAC1B,gBAAM,UAAU,CAAC,GAAG,OAAO,iBAAiB;AAC5C,kBAAQ,OAAO;AAAA;AAAA;AAAA;AAAA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';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport { DSButtonV2 } from '@elliemae/ds-button';\nimport { describe, mergeRefs } from '@elliemae/ds-utilities';\nimport DSPopover from '@elliemae/ds-popover';\nimport AppPickerImpl from './AppPickerImpl';\nimport { propTypes } from './propTypes';\nimport type { DSAppPickerType } from './types/AppPickerTypes';\n\nconst DSAppPicker: DSAppPickerType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n icon: Icon = () => <MenuPicker fill={['brand-primary', 700]} size=\"m\" />,\n renderTrigger,\n isOpen,\n onClose = () => null,\n actionRef,\n onKeyDown,\n onClick = () => null,\n onClickOutside = () => null,\n triggerRef,\n}) => {\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<HTMLUListElement>(null);\n const defaultTriggerRef = useRef(null);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToIndex = (index) => {\n if (wrapperRef.current) {\n const parent = wrapperRef.current;\n const buttons = [...parent.querySelectorAll('button')];\n buttons[index].focus();\n }\n };\n }\n }, [actionRef, apps, customApps]);\n\n useEffect(() => {\n setTimeout(() => {\n if (wrapperRef.current) {\n const { scrollHeight, clientHeight } = wrapperRef.current;\n if (scrollHeight > clientHeight) return setIsOverflow(true);\n }\n return setIsOverflow(false);\n });\n }, [isOpen, open]);\n\n const handleOnClose = () => {\n if (typeof isOpen === 'boolean') {\n setOpen(isOpen);\n } else {\n setOpen(false);\n }\n onClose();\n };\n\n const handleOnClickOutside = (e: MouseEvent) => {\n setOpen(false);\n onClose();\n onClickOutside(e);\n };\n\n const AppPickerContent = () => (\n <AppPickerImpl\n apps={apps}\n customApps={customApps}\n sectionTitle={sectionTitle}\n customSectionTitle={customSectionTitle}\n close={handleOnClose}\n wrapperRef={wrapperRef}\n onKeyDown={onKeyDown}\n triggerRef={triggerRef || defaultTriggerRef}\n isOverflow={isOverflow}\n />\n );\n const RenderTrigger =\n renderTrigger ||\n (({ ref }) => (\n <DSButtonV2\n data-testid=\"app-picker__button\"\n id=\"app-picker__button\"\n buttonType=\"icon\"\n aria-haspopup=\"true\"\n aria-expanded={open || isOpen}\n innerRef={mergeRefs(ref, defaultTriggerRef)}\n onClick={(e) => {\n onClick(e);\n setOpen(true);\n }}\n >\n <Icon />\n </DSButtonV2>\n ));\n\n return (\n <DSPopover\n content={<AppPickerContent />}\n isOpen={typeof isOpen === 'boolean' ? isOpen : open}\n onClickOutside={handleOnClickOutside}\n placement=\"bottom\"\n interactionType=\"click\"\n renderTrigger={RenderTrigger}\n showArrow\n style={{\n padding: '0',\n maxWidth: '1000px',\n width: 'fit-content',\n }}\n />\n );\n};\n\nDSAppPicker.displayName = 'DSAppPicker';\nconst AppPickerWithSchema = describe(DSAppPicker);\nAppPickerWithSchema.propTypes = propTypes;\n\nexport { DSAppPicker, AppPickerWithSchema };\nexport default DSAppPicker;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAmD;AAEnD,sBAA2B;AAC3B,uBAA2B;AAC3B,0BAAoC;AACpC,wBAAsB;AACtB,2BAA0B;AAC1B,uBAA0B;AAG1B,MAAM,cAA+B,CAAC;AAAA,EACpC,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,MAAM,OAAO,MAAM,mDAAC;AAAA,IAAW,MAAM,CAAC,iBAAiB,GAAG;AAAA,IAAG,MAAK;AAAA,GAAI;AAAA,EACtE;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB,iBAAiB,MAAM;AAAA,EACvB;AAAA,MACI;AACJ,QAAM,CAAC,MAAM,WAAW,2BAAS,KAAK;AACtC,QAAM,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iB;AAAA,IAC1C,SAAS,CAAC,MAAM;AACd,cAAQ,CAAC;AACT,cAAQ,IAAI;AAAA,IACd;AAAA,KAEA,mDAAC,UAAK,CACR;AAGJ,SACE,mDAAC;AAAA,IACC,SAAS,mDAAC,sBAAiB;AAAA,IAC3B,QAAQ,OAAO,WAAW,YAAY,SAAS;AAAA,IAC/C,gBAAgB;AAAA,IAChB,WAAU;AAAA,IACV,iBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,WAAS;AAAA,IACT,OAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,IACT;AAAA,GACF;AAEJ;AAEA,YAAY,cAAc;AAC1B,MAAM,sBAAsB,kCAAS,WAAW;AAChD,oBAAoB,YAAY;AAGhC,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -4,33 +4,27 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
11
10
  };
12
- var __reExport = (target, module2, copyDefault, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
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 });
17
16
  }
18
- return target;
17
+ return to;
19
18
  };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
- return (module2, temp) => {
25
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
- };
27
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ 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));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
22
  var src_exports = {};
29
23
  __export(src_exports, {
30
24
  default: () => import_DSAppPicker.default
31
25
  });
26
+ module.exports = __toCommonJS(src_exports);
32
27
  var React = __toESM(require("react"));
33
- __reExport(src_exports, require("./DSAppPicker"));
28
+ __reExport(src_exports, require("./DSAppPicker"), module.exports);
34
29
  var import_DSAppPicker = __toESM(require("./DSAppPicker"));
35
- module.exports = __toCommonJS(src_exports);
36
30
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
4
  "sourcesContent": ["export * from './DSAppPicker';\n\nexport { default } from './DSAppPicker';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AAEd,yBAAwB;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc,0BAAd;AAEA,yBAAwB;",
6
6
  "names": []
7
7
  }
@@ -4,31 +4,25 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
7
  var __export = (target, all) => {
9
8
  for (var name in all)
10
9
  __defProp(target, name, { get: all[name], enumerable: true });
11
10
  };
12
- var __reExport = (target, module2, copyDefault, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
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 });
17
16
  }
18
- return target;
17
+ return to;
19
18
  };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
- return (module2, temp) => {
25
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
- };
27
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
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);
28
21
  var propTypes_exports = {};
29
22
  __export(propTypes_exports, {
30
23
  propTypes: () => propTypes
31
24
  });
25
+ module.exports = __toCommonJS(propTypes_exports);
32
26
  var React = __toESM(require("react"));
33
27
  var import_react_desc = require("react-desc");
34
28
  var import_ds_icons = require("@elliemae/ds-icons");
@@ -46,5 +40,4 @@ const propTypes = {
46
40
  onClick: import_react_desc.PropTypes.func.description("Custom onClick for Trigger component."),
47
41
  onClickOutside: import_react_desc.PropTypes.func.description("Callback event when the user clicks outside the App Picker.")
48
42
  };
49
- module.exports = __toCommonJS(propTypes_exports);
50
43
  //# sourceMappingURL=propTypes.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/propTypes.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
4
  "sourcesContent": ["import { PropTypes } from 'react-desc';\nimport { MenuPicker } from '@elliemae/ds-icons';\n\nexport const propTypes = {\n apps: PropTypes.array.description(\n 'Main items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]',\n ).isRequired,\n customApps: PropTypes.array.description(\n 'Custom items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]',\n ),\n sectionTitle: PropTypes.string.description('main section title').defaultValue('APPLICATIONS'),\n customSectionTitle: PropTypes.string.description('custom section title').defaultValue('CUSTOM APPLICATIONS'),\n icon: PropTypes.func.description('trigger button s icon').defaultValue(MenuPicker),\n renderTrigger: PropTypes.func.description('Custom trigger component.'),\n actionRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'Ref containing a focusToIndex method. This method allows you to focus any App inside the AppPicker.',\n ),\n isOpen: PropTypes.bool.description('Wether the AppPicker should be open or not.'),\n onClose: PropTypes.func.description('Callback function when the AppPicker closes'),\n onKeyDown: PropTypes.func.description('OnKeyDown handler callback.'),\n onClick: PropTypes.func.description('Custom onClick for Trigger component.'),\n onClickOutside: PropTypes.func.description('Callback event when the user clicks outside the App Picker.'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAC1B,sBAA2B;AAEpB,MAAM,YAAY;AAAA,EACvB,MAAM,4BAAU,MAAM,YACpB,sGACA;AAAA,EACF,YAAY,4BAAU,MAAM,YAC1B;AAAA,EAEF,cAAc,4BAAU,OAAO,YAAY,sBAAsB,aAAa;AAAA,EAC9E,oBAAoB,4BAAU,OAAO,YAAY,wBAAwB,aAAa;AAAA,EACtF,MAAM,4BAAU,KAAK,YAAY,yBAAyB,aAAa;AAAA,EACvE,eAAe,4BAAU,KAAK,YAAY;AAAA,EAC1C,WAAW,4BAAU,UAAU,CAAC,4BAAU,MAAM,4BAAU,MAAM,EAAE,SAAS,4BAAU,SAAS,YAC5F;AAAA,EAEF,QAAQ,4BAAU,KAAK,YAAY;AAAA,EACnC,SAAS,4BAAU,KAAK,YAAY;AAAA,EACpC,WAAW,4BAAU,KAAK,YAAY;AAAA,EACtC,SAAS,4BAAU,KAAK,YAAY;AAAA,EACpC,gBAAgB,4BAAU,KAAK,YAAY;AAAA;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAC1B,sBAA2B;AAEpB,MAAM,YAAY;AAAA,EACvB,MAAM,4BAAU,MAAM,YACpB,oGACF,EAAE;AAAA,EACF,YAAY,4BAAU,MAAM,YAC1B,sGACF;AAAA,EACA,cAAc,4BAAU,OAAO,YAAY,oBAAoB,EAAE,aAAa,cAAc;AAAA,EAC5F,oBAAoB,4BAAU,OAAO,YAAY,sBAAsB,EAAE,aAAa,qBAAqB;A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