@codezee/sixtify-brahma 0.2.148 → 0.2.150

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.
Files changed (24) hide show
  1. package/package.json +3 -1
  2. package/packages/shared-components/dist/AgGrid/hooks/index.d.ts +1 -0
  3. package/packages/shared-components/dist/AgGrid/hooks/index.d.ts.map +1 -1
  4. package/packages/shared-components/dist/AgGrid/hooks/index.js +1 -0
  5. package/packages/shared-components/dist/AgGrid/hooks/useAgGridKeyboardShortcuts.d.ts +8 -0
  6. package/packages/shared-components/dist/AgGrid/hooks/useAgGridKeyboardShortcuts.d.ts.map +1 -0
  7. package/packages/shared-components/dist/AgGrid/hooks/useAgGridKeyboardShortcuts.js +37 -0
  8. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/FacetedFilter.d.ts.map +1 -1
  9. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/FacetedFilter.js +17 -6
  10. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.d.ts +2 -2
  11. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.d.ts.map +1 -1
  12. package/packages/shared-components/dist/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.js +1 -1
  13. package/packages/shared-components/dist/SmartGrid/Components/FilterStatusPanel.d.ts.map +1 -1
  14. package/packages/shared-components/dist/SmartGrid/Components/FilterStatusPanel.js +6 -2
  15. package/packages/shared-components/dist/SmartGrid/utils/helper.d.ts.map +1 -1
  16. package/packages/shared-components/dist/SmartGrid/utils/helper.js +2 -1
  17. package/packages/shared-components/dist/codeSnippetBox/CodeSnippetBox.d.ts +4 -3
  18. package/packages/shared-components/dist/codeSnippetBox/CodeSnippetBox.d.ts.map +1 -1
  19. package/packages/shared-components/dist/codeSnippetBox/CodeSnippetBox.js +38 -2
  20. package/packages/shared-components/dist/codeSnippetBox/CodeSnippetBox.styled.d.ts.map +1 -1
  21. package/packages/shared-components/dist/codeSnippetBox/CodeSnippetBox.styled.js +3 -10
  22. package/packages/shared-components/dist/utils/regex.d.ts +1 -0
  23. package/packages/shared-components/dist/utils/regex.d.ts.map +1 -1
  24. package/packages/shared-components/dist/utils/regex.js +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codezee/sixtify-brahma",
3
- "version": "0.2.148",
3
+ "version": "0.2.150",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hardikranpariya/sixtify-brahma.git"
@@ -112,6 +112,7 @@
112
112
  "@tiptap/starter-kit": "^3.4.4",
113
113
  "@tiptap/suggestion": "^3.4.4",
114
114
  "@types/file-saver": "^2.0.7",
115
+ "@types/react-syntax-highlighter": "^15.5.13",
115
116
  "ag-grid-community": "^34.3.1",
116
117
  "ag-grid-react": "^34.3.1",
117
118
  "axios": "^1.7.2",
@@ -132,6 +133,7 @@
132
133
  "react-i18next": "^14.1.2",
133
134
  "react-multi-carousel": "^2.8.5",
134
135
  "react-phone-input-2": "^2.15.1",
136
+ "react-syntax-highlighter": "^16.1.0",
135
137
  "react-toastify": "^10.0.5",
136
138
  "react-webcam": "7.2.0",
137
139
  "styled-components": "^6.1.11",
@@ -3,4 +3,5 @@ export * from "./useAgGridSummaryRow";
3
3
  export * from "./useAgGridSummaryRowUpdate";
4
4
  export * from "./useAgGridRowSelectionConfig";
5
5
  export * from "./useAgGridFilteredData";
6
+ export * from "./useAgGridKeyboardShortcuts";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC"}
@@ -19,3 +19,4 @@ __exportStar(require("./useAgGridSummaryRow"), exports);
19
19
  __exportStar(require("./useAgGridSummaryRowUpdate"), exports);
20
20
  __exportStar(require("./useAgGridRowSelectionConfig"), exports);
21
21
  __exportStar(require("./useAgGridFilteredData"), exports);
22
+ __exportStar(require("./useAgGridKeyboardShortcuts"), exports);
@@ -0,0 +1,8 @@
1
+ import type { AgGridReact } from "ag-grid-react";
2
+ import type { RefObject } from "react";
3
+ type UseAgGridKeyboardShortcutsArgs<T = unknown> = {
4
+ gridRef: RefObject<AgGridReact<T>>;
5
+ };
6
+ export declare const useAgGridKeyboardShortcuts: <T = unknown>({ gridRef, }: UseAgGridKeyboardShortcutsArgs<T>) => void;
7
+ export {};
8
+ //# sourceMappingURL=useAgGridKeyboardShortcuts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAgGridKeyboardShortcuts.d.ts","sourceRoot":"","sources":["../../../src/AgGrid/hooks/useAgGridKeyboardShortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,KAAK,8BAA8B,CAAC,CAAC,GAAG,OAAO,IAAI;IACjD,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,CAAC,GAAG,OAAO,EAAE,cAErD,8BAA8B,CAAC,CAAC,CAAC,SAoCnC,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAgGridKeyboardShortcuts = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const useAgGridKeyboardShortcuts = ({ gridRef, }) => {
6
+ (0, utils_1.useGlobalKeyboardShortcut)({
7
+ key: "a",
8
+ modifierKeys: "ctrl",
9
+ onTrigger: () => {
10
+ if (!gridRef.current?.api) {
11
+ return;
12
+ }
13
+ const api = gridRef.current.api;
14
+ api.forEachNodeAfterFilterAndSort((node) => {
15
+ if (node.displayed && node.data) {
16
+ node.setSelected(true);
17
+ }
18
+ });
19
+ },
20
+ });
21
+ (0, utils_1.useGlobalKeyboardShortcut)({
22
+ key: "a",
23
+ modifierKeys: "alt",
24
+ onTrigger: () => {
25
+ if (!gridRef.current?.api) {
26
+ return;
27
+ }
28
+ const api = gridRef.current.api;
29
+ api.forEachNodeAfterFilterAndSort((node) => {
30
+ if (node.displayed && node.data) {
31
+ node.setSelected(false);
32
+ }
33
+ });
34
+ },
35
+ });
36
+ };
37
+ exports.useAgGridKeyboardShortcuts = useAgGridKeyboardShortcuts;
@@ -1 +1 @@
1
- {"version":3,"file":"FacetedFilter.d.ts","sourceRoot":"","sources":["../../../../src/SmartGrid/Components/FacetedFilter/FacetedFilter.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAUpD,KAAK,kBAAkB,CAAC,CAAC,IAAI;IAC3B,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAG,8BAG/B,kBAAkB,CAAC,CAAC,CAAC,4CAoTvB,CAAC"}
1
+ {"version":3,"file":"FacetedFilter.d.ts","sourceRoot":"","sources":["../../../../src/SmartGrid/Components/FacetedFilter/FacetedFilter.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAUpD,KAAK,kBAAkB,CAAC,CAAC,IAAI;IAC3B,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAG,8BAG/B,kBAAkB,CAAC,CAAC,CAAC,4CAkUvB,CAAC"}
@@ -131,18 +131,29 @@ const FacetedFilter = ({ header, resetAllFilters, }) => {
131
131
  handleReset();
132
132
  }
133
133
  }, [resetAllFilters]);
134
- return ((0, jsx_runtime_1.jsxs)("div", { style: { position: "relative" }, children: [(0, jsx_runtime_1.jsxs)(material_1.IconButton, { ref: buttonRef, onClick: () => setIsOpen(!isOpen), sx: { padding: 0, position: "relative" }, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { toolTipLabel: "Faceted Filter", children: (0, jsx_runtime_1.jsx)(icons_material_1.FilterListRounded, {}) }), activeFilterCount > 0 && ((0, jsx_runtime_1.jsx)("span", { style: {
134
+ const hasActiveFilter = activeFilterCount > 0;
135
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { position: "relative" }, children: [(0, jsx_runtime_1.jsxs)(material_1.IconButton, { ref: buttonRef, onClick: () => setIsOpen(!isOpen), sx: {
136
+ padding: "2px",
137
+ position: "relative",
138
+ backgroundColor: hasActiveFilter
139
+ ? (0, material_1.lighten)(butterflyBlue[900], 0.7)
140
+ : "transparent",
141
+ "&:hover": {
142
+ backgroundColor: hasActiveFilter
143
+ ? (0, material_1.lighten)(butterflyBlue[900], 0.7)
144
+ : (0, material_1.lighten)(iron[500], 0.7),
145
+ }
146
+ }, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { toolTipLabel: "Faceted Filter", children: (0, jsx_runtime_1.jsx)(icons_material_1.FilterListRounded, {}) }), hasActiveFilter && ((0, jsx_runtime_1.jsx)("span", { style: {
135
147
  backgroundColor: butterflyBlue[900],
136
- border: `2px solid ${iron[600]}`,
137
148
  borderRadius: "50%",
138
149
  color: iron[600],
139
150
  fontSize: "10px",
140
151
  fontWeight: "bold",
141
- height: "6px",
152
+ height: "7px",
142
153
  position: "absolute",
143
- right: 0,
144
- top: 1,
145
- width: "6px",
154
+ right: 4,
155
+ top: 4,
156
+ width: "7px",
146
157
  } }))] }), isOpen && ((0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, { onClickAway: handleClickAway, children: (0, jsx_runtime_1.jsxs)("div", { ref: popoverRef, style: {
147
158
  backgroundColor: iron[600],
148
159
  borderRadius: "6px",
@@ -1,7 +1,7 @@
1
1
  type VirtualCheckboxListProps = {
2
2
  checkedMap: Record<string, boolean>;
3
- onToggle: (value: string) => void;
4
- options: string[];
3
+ onToggle: (value: string | number) => void;
4
+ options: (string | number)[];
5
5
  };
6
6
  export declare const VirtualCheckboxList: import("react").MemoExoticComponent<({ checkedMap, onToggle, options }: VirtualCheckboxListProps) => import("react/jsx-runtime").JSX.Element>;
7
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualCheckboxList.d.ts","sourceRoot":"","sources":["../../../../src/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.tsx"],"names":[],"mappings":"AAIA,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,mBAAmB,0EACM,wBAAwB,6CA2K7D,CAAC"}
1
+ {"version":3,"file":"VirtualCheckboxList.d.ts","sourceRoot":"","sources":["../../../../src/SmartGrid/Components/FacetedFilter/VirtualCheckboxList.tsx"],"names":[],"mappings":"AAIA,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC3C,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,0EACM,wBAAwB,6CA2K7D,CAAC"}
@@ -95,7 +95,7 @@ exports.VirtualCheckboxList = (0, react_1.memo)(({ checkedMap, onToggle, options
95
95
  overflow: "hidden",
96
96
  textOverflow: "ellipsis",
97
97
  width: "150px",
98
- }, children: (0, helper_1.formatDateValue)(value) })] }, value));
98
+ }, children: typeof value === "string" ? (0, helper_1.formatDateValue)(value) : value })] }, value));
99
99
  }) }) }) }));
100
100
  });
101
101
  exports.VirtualCheckboxList.displayName = "VirtualCheckboxList";
@@ -1 +1 @@
1
- {"version":3,"file":"FilterStatusPanel.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/Components/FilterStatusPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC/B,eAAe,EAAE,QAAQ,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAG,6BAGnC,sBAAsB,CAAC,CAAC,CAAC,4CA2I3B,CAAC"}
1
+ {"version":3,"file":"FilterStatusPanel.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/Components/FilterStatusPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC/B,eAAe,EAAE,QAAQ,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAG,6BAGnC,sBAAsB,CAAC,CAAC,CAAC,4CAiJ3B,CAAC"}
@@ -30,7 +30,7 @@ const FilterStatusPanel = ({ clearAllFilters, table, }) => {
30
30
  // Handle primitive filters (string/number)
31
31
  if (typeof filter === "string" || typeof filter === "number") {
32
32
  return {
33
- facets: filter !== "" ? [String(filter)] : [],
33
+ facets: filter !== "" ? [filter] : [],
34
34
  search: [],
35
35
  };
36
36
  }
@@ -51,7 +51,11 @@ const FilterStatusPanel = ({ clearAllFilters, table, }) => {
51
51
  const filter = header.column.getFilterValue();
52
52
  const { facets, search } = extractFilterValues(filter);
53
53
  const hasValues = facets.length > 0 || search.length > 0;
54
- return hasValues ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, { flexDirection: "row", gap: "3px", children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", fontWeight: 600, children: [header.column.columnDef.header, ":"] }), facets.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: { color: butterflyBlue[900] }, children: facets.map(helper_1.formatDateValue).join(", ") })), facets.length > 0 && search.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: "," })), search.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: { color: brown[900] }, children: search.join(", ") }))] }, header.id)) : null;
54
+ return hasValues ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, { flexDirection: "row", gap: "3px", children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", fontWeight: 600, children: [header.column.columnDef.header, ":"] }), facets.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: { color: butterflyBlue[900] }, children: facets
55
+ .map((value) => typeof value === "string"
56
+ ? (0, helper_1.formatDateValue)(value)
57
+ : value)
58
+ .join(", ") })), facets.length > 0 && search.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: "," })), search.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: { color: brown[900] }, children: search.join(", ") }))] }, header.id)) : null;
55
59
  })
56
60
  .filter(Boolean);
57
61
  // Don't render if no filters applied
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/utils/helper.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,WAQ5C,CAAC"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/SmartGrid/utils/helper.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,WAQ5C,CAAC"}
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatDateValue = void 0;
4
4
  const luxon_1 = require("luxon");
5
+ const utils_1 = require("../../utils");
5
6
  const formatDateValue = (value) => {
6
7
  const date = luxon_1.DateTime.fromISO(value);
7
- if (date.isValid) {
8
+ if (date.isValid && utils_1.isoDateRegex.test(value)) {
8
9
  return date.toFormat("dd-MM-yyyy");
9
10
  }
10
11
  return value;
@@ -1,9 +1,10 @@
1
- import type { BoxProps } from "@mui/material";
2
1
  import type { ReactNode } from "react";
2
+ export type CodeSnippetBoxLanguage = "typescript" | "javascript" | "html" | "css" | "json" | "xml" | "yaml" | "markdown" | "plaintext";
3
3
  type CodeSnippetBoxProps = {
4
4
  children: ReactNode;
5
- component?: BoxProps["component"];
5
+ language?: CodeSnippetBoxLanguage;
6
+ isCopyable?: boolean;
6
7
  };
7
- export declare const CodeSnippetBox: ({ children, component, }: CodeSnippetBoxProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const CodeSnippetBox: ({ children, language, isCopyable, }: CodeSnippetBoxProps) => import("react/jsx-runtime").JSX.Element;
8
9
  export {};
9
10
  //# sourceMappingURL=CodeSnippetBox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSnippetBox.d.ts","sourceRoot":"","sources":["../../src/codeSnippetBox/CodeSnippetBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,0BAG5B,mBAAmB,4CAMrB,CAAC"}
1
+ {"version":3,"file":"CodeSnippetBox.d.ts","sourceRoot":"","sources":["../../src/codeSnippetBox/CodeSnippetBox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,MAAM,MAAM,sBAAsB,GAC9B,YAAY,GACZ,YAAY,GACZ,MAAM,GACN,KAAK,GACL,MAAM,GACN,KAAK,GACL,MAAM,GACN,UAAU,GACV,WAAW,CAAC;AAEhB,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,qCAI5B,mBAAmB,4CA6ErB,CAAC"}
@@ -2,8 +2,44 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CodeSnippetBox = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const icons_material_1 = require("@mui/icons-material");
6
+ const material_1 = require("@mui/material");
7
+ const react_1 = require("react");
8
+ const react_syntax_highlighter_1 = require("react-syntax-highlighter");
9
+ // eslint-disable-next-line import/no-internal-modules
10
+ const prism_1 = require("react-syntax-highlighter/dist/esm/styles/prism");
5
11
  const CodeSnippetBox_styled_1 = require("./CodeSnippetBox.styled");
6
- const CodeSnippetBox = ({ children, component = "pre", }) => {
7
- return ((0, jsx_runtime_1.jsx)(CodeSnippetBox_styled_1.StyledCodeSnippetBox, { component: component, children: children }));
12
+ const Button_1 = require("../Button");
13
+ const CodeSnippetBox = ({ children, language = "typescript", isCopyable = true, }) => {
14
+ const theme = (0, material_1.useTheme)();
15
+ const { mirage, iron } = theme.palette.app.color;
16
+ const [copied, setCopied] = (0, react_1.useState)(false);
17
+ const handleCopy = () => {
18
+ if (typeof children !== "string" || !isCopyable) {
19
+ return;
20
+ }
21
+ navigator.clipboard
22
+ .writeText(children)
23
+ .then(() => {
24
+ setCopied(true);
25
+ setTimeout(() => {
26
+ setCopied(false);
27
+ }, 2000);
28
+ })
29
+ .catch(() => {
30
+ // Silently fail
31
+ });
32
+ };
33
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { position: "relative" }, children: typeof children === "string" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isCopyable && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
34
+ position: "absolute",
35
+ top: theme.spacing(1),
36
+ right: theme.spacing(1),
37
+ zIndex: 1,
38
+ }, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: copied ? "Copied!" : "Copy code", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", onClick: handleCopy, variant: "text", sx: { color: iron[600], fontSize: "10px" }, startIcon: copied ? ((0, jsx_runtime_1.jsx)(icons_material_1.Check, { sx: { fontSize: "10px" } })) : ((0, jsx_runtime_1.jsx)(icons_material_1.ContentCopy, { sx: { fontSize: "10px" } })), children: copied ? "Copied!" : "Copy code" }) }) })), (0, jsx_runtime_1.jsx)(react_syntax_highlighter_1.Prism, { language: language, style: prism_1.vscDarkPlus, customStyle: {
39
+ margin: 0,
40
+ borderRadius: "5px",
41
+ padding: theme.spacing(2),
42
+ background: mirage[900],
43
+ }, PreTag: "div", children: children })] })) : ((0, jsx_runtime_1.jsx)(CodeSnippetBox_styled_1.StyledCodeSnippetBox, { children: children })) }));
8
44
  };
9
45
  exports.CodeSnippetBox = CodeSnippetBox;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSnippetBox.styled.d.ts","sourceRoot":"","sources":["../../src/codeSnippetBox/CodeSnippetBox.styled.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnD,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAAC,QAAQ,CA+BzD,CAAC"}
1
+ {"version":3,"file":"CodeSnippetBox.styled.d.ts","sourceRoot":"","sources":["../../src/codeSnippetBox/CodeSnippetBox.styled.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGnD,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAAC,QAAQ,CAwBzD,CAAC"}
@@ -5,7 +5,7 @@ const material_1 = require("@mui/material");
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  exports.StyledCodeSnippetBox = (0, styles_1.styled)(material_1.Box)(({ theme, }) => {
7
7
  const { app: { color }, } = theme.palette;
8
- const { slate, iron, claude } = color;
8
+ const { slate, iron } = color;
9
9
  return {
10
10
  backgroundColor: slate[900],
11
11
  borderRadius: "4px",
@@ -16,16 +16,9 @@ exports.StyledCodeSnippetBox = (0, styles_1.styled)(material_1.Box)(({ theme, })
16
16
  overflow: "auto",
17
17
  fontFamily: "SFMono-Regular, Menlo, Monaco, Consolas, monospace",
18
18
  lineHeight: 1.5,
19
- "& code": {
19
+ "& .react-syntax-highlighter-code-element": {
20
+ fontSize: "inherit",
20
21
  fontFamily: "inherit",
21
22
  },
22
- "& pre": {
23
- margin: 0,
24
- fontFamily: "inherit",
25
- },
26
- "& ::selection": {
27
- backgroundColor: claude[300],
28
- color: slate[900],
29
- },
30
23
  };
31
24
  });
@@ -3,4 +3,5 @@ export declare const isoDateRegex: RegExp;
3
3
  export declare const noSpecialCharacterRegex: RegExp;
4
4
  export declare const emailRegex: RegExp;
5
5
  export declare const timeRegex: RegExp;
6
+ export declare const accessorFnRegex: RegExp;
6
7
  //# sourceMappingURL=regex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["../../src/utils/regex.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,QAAkB,CAAC;AAE9C,eAAO,MAAM,YAAY,QAAwB,CAAC;AAElD,eAAO,MAAM,uBAAuB,QAAoB,CAAC;AAEzD,eAAO,MAAM,UAAU,QACmvB,CAAC;AAE3wB,eAAO,MAAM,SAAS,QAA6B,CAAC"}
1
+ {"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["../../src/utils/regex.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,QAAkB,CAAC;AAE9C,eAAO,MAAM,YAAY,QAAwB,CAAC;AAElD,eAAO,MAAM,uBAAuB,QAAoB,CAAC;AAEzD,eAAO,MAAM,UAAU,QACmvB,CAAC;AAE3wB,eAAO,MAAM,SAAS,QAA6B,CAAC;AAEpD,eAAO,MAAM,eAAe,QAAkF,CAAC"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timeRegex = exports.emailRegex = exports.noSpecialCharacterRegex = exports.isoDateRegex = exports.monthYearRegex = void 0;
3
+ exports.accessorFnRegex = exports.timeRegex = exports.emailRegex = exports.noSpecialCharacterRegex = exports.isoDateRegex = exports.monthYearRegex = void 0;
4
+ /* eslint-disable sonarjs/unnecessary-character-escapes */
5
+ /* eslint-disable no-useless-escape */
4
6
  /* eslint-disable sonarjs/single-character-alternation */
5
7
  /* eslint-disable sonarjs/concise-regex */
6
8
  /* eslint-disable sonarjs/sonar-no-control-regex */
@@ -12,3 +14,4 @@ exports.isoDateRegex = /^\d{4}-\d{2}-\d{2}$/;
12
14
  exports.noSpecialCharacterRegex = /^[a-zA-Z0-9 ]*$/;
13
15
  exports.emailRegex = /^(((?!.*[^\x00-\x7F])[^<>()[\]\\.,;:\s@"](\.[^<>()[\]\\.,;:\s@"])*){1,64}|(".{1,64}"))@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-zA-Z\-0-9]+(?:-[a-zA-Z\-0-9]+)*([.]{1,1}))){1,4}([a-zA-Z][a-zA-Z0-9]{1,}))|(?:\[(?:(?:(i|I)(p|P)(v)6:(?:(?:[a-zA-Z\-0-9]{1,4}(?::[a-zA-Z\-0-9]{1,4}){7})|(?:(?!(?:.*[a-zA-Z\-0-9][:\]]){7,})(?:[a-zA-Z\-0-9]{1,4}(?::[a-zA-Z\-0-9]{1,4}){0,5})?::(?:[a-zA-Z\-0-9]{1,4}(?::[a-zA-Z\-0-9]{1,4}){0,5})?)))|(?:(?:(i|I)(p|P)(v)6:(?:(?:[a-zA-Z\-0-9]{1,4}(?::[a-zA-Z\-0-9]{1,4}){5}:)|(?:(?!(?:.*[a-zA-Z\-0-9]:){5,})(?:[a-zA-Z\-0-9]{1,4}(?::[a-zA-Z\-0-9]{1,4}){0,3})?::(?:[a-zA-Z\-0-9]{1,4}(?::[a-zA-Z\-0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/;
14
16
  exports.timeRegex = /^\d{1,3}:\d{2}(:\d{2})?$/;
17
+ exports.accessorFnRegex = /([a-zA-Z0-9_$.\[\]]+)\s*!==\s*null\s*&&\s*\1\s*!==\s*void 0\s*\?\s*\1\s*:\s*/g;