@coveord/plasma-mantine 55.6.0 → 55.7.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.
Files changed (96) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/.turbo/turbo-test.log +54 -52
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/cjs/components/code-editor/CodeEditor.d.ts +7 -0
  5. package/dist/cjs/components/code-editor/CodeEditor.d.ts.map +1 -1
  6. package/dist/cjs/components/code-editor/CodeEditor.js +6 -3
  7. package/dist/cjs/components/code-editor/CodeEditor.js.map +1 -1
  8. package/dist/cjs/components/index.d.ts +1 -0
  9. package/dist/cjs/components/index.d.ts.map +1 -1
  10. package/dist/cjs/components/index.js +1 -0
  11. package/dist/cjs/components/index.js.map +1 -1
  12. package/dist/cjs/components/modal/Modal.d.ts +11 -0
  13. package/dist/cjs/components/modal/Modal.d.ts.map +1 -0
  14. package/dist/cjs/components/modal/Modal.js +32 -0
  15. package/dist/cjs/components/modal/Modal.js.map +1 -0
  16. package/dist/cjs/components/modal/Modal.module.css +9 -0
  17. package/dist/cjs/components/modal/ModalFooter.d.ts +20 -0
  18. package/dist/cjs/components/modal/ModalFooter.d.ts.map +1 -0
  19. package/dist/cjs/components/modal/ModalFooter.js +46 -0
  20. package/dist/cjs/components/modal/ModalFooter.js.map +1 -0
  21. package/dist/cjs/components/modal/index.d.ts +3 -0
  22. package/dist/cjs/components/modal/index.d.ts.map +1 -0
  23. package/dist/cjs/components/modal/index.js +9 -0
  24. package/dist/cjs/components/modal/index.js.map +1 -0
  25. package/dist/cjs/components/prompt/Prompt.d.ts +3 -3
  26. package/dist/cjs/components/prompt/Prompt.d.ts.map +1 -1
  27. package/dist/cjs/components/prompt/Prompt.js +14 -16
  28. package/dist/cjs/components/prompt/Prompt.js.map +1 -1
  29. package/dist/cjs/components/sticky-footer/StickyFooter.d.ts +2 -0
  30. package/dist/cjs/components/sticky-footer/StickyFooter.d.ts.map +1 -1
  31. package/dist/cjs/components/sticky-footer/StickyFooter.js.map +1 -1
  32. package/dist/cjs/components/table/use-url-synced-state.d.ts.map +1 -1
  33. package/dist/cjs/components/table/use-url-synced-state.js +29 -19
  34. package/dist/cjs/components/table/use-url-synced-state.js.map +1 -1
  35. package/dist/cjs/index.d.ts +1 -1
  36. package/dist/cjs/index.d.ts.map +1 -1
  37. package/dist/cjs/index.js +3 -0
  38. package/dist/cjs/index.js.map +1 -1
  39. package/dist/esm/components/code-editor/CodeEditor.d.ts +7 -0
  40. package/dist/esm/components/code-editor/CodeEditor.d.ts.map +1 -1
  41. package/dist/esm/components/code-editor/CodeEditor.js +4 -2
  42. package/dist/esm/components/code-editor/CodeEditor.js.map +1 -1
  43. package/dist/esm/components/index.d.ts +1 -0
  44. package/dist/esm/components/index.d.ts.map +1 -1
  45. package/dist/esm/components/index.js +1 -0
  46. package/dist/esm/components/index.js.map +1 -1
  47. package/dist/esm/components/modal/Modal.d.ts +11 -0
  48. package/dist/esm/components/modal/Modal.d.ts.map +1 -0
  49. package/dist/esm/components/modal/Modal.js +20 -0
  50. package/dist/esm/components/modal/Modal.js.map +1 -0
  51. package/dist/esm/components/modal/Modal.module.css +9 -0
  52. package/dist/esm/components/modal/ModalFooter.d.ts +20 -0
  53. package/dist/esm/components/modal/ModalFooter.d.ts.map +1 -0
  54. package/dist/esm/components/modal/ModalFooter.js +32 -0
  55. package/dist/esm/components/modal/ModalFooter.js.map +1 -0
  56. package/dist/esm/components/modal/index.d.ts +3 -0
  57. package/dist/esm/components/modal/index.d.ts.map +1 -0
  58. package/dist/esm/components/modal/index.js +4 -0
  59. package/dist/esm/components/modal/index.js.map +1 -0
  60. package/dist/esm/components/prompt/Prompt.d.ts +3 -3
  61. package/dist/esm/components/prompt/Prompt.d.ts.map +1 -1
  62. package/dist/esm/components/prompt/Prompt.js +9 -7
  63. package/dist/esm/components/prompt/Prompt.js.map +1 -1
  64. package/dist/esm/components/sticky-footer/StickyFooter.d.ts +2 -0
  65. package/dist/esm/components/sticky-footer/StickyFooter.d.ts.map +1 -1
  66. package/dist/esm/components/sticky-footer/StickyFooter.js.map +1 -1
  67. package/dist/esm/components/table/use-url-synced-state.d.ts.map +1 -1
  68. package/dist/esm/components/table/use-url-synced-state.js +26 -18
  69. package/dist/esm/components/table/use-url-synced-state.js.map +1 -1
  70. package/dist/esm/index.d.ts +1 -1
  71. package/dist/esm/index.d.ts.map +1 -1
  72. package/dist/esm/index.js +1 -1
  73. package/dist/esm/index.js.map +1 -1
  74. package/package.json +25 -25
  75. package/src/components/code-editor/CodeEditor.tsx +8 -1
  76. package/src/components/index.ts +1 -0
  77. package/src/components/modal/Modal.module.css +9 -0
  78. package/src/components/modal/Modal.tsx +33 -0
  79. package/src/components/modal/ModalFooter.tsx +47 -0
  80. package/src/components/modal/__tests__/Modal.spec.tsx +25 -0
  81. package/src/components/modal/__tests__/ModalFooter.spec.tsx +35 -0
  82. package/src/components/modal/index.ts +2 -0
  83. package/src/components/prompt/Prompt.tsx +9 -8
  84. package/src/components/sticky-footer/StickyFooter.tsx +2 -0
  85. package/src/components/table/__tests__/use-url-synced-state.unit.spec.ts +189 -138
  86. package/src/components/table/use-url-synced-state.ts +36 -18
  87. package/src/index.ts +2 -0
  88. package/dist/cjs/components/prompt/PromptFooter.d.ts +0 -6
  89. package/dist/cjs/components/prompt/PromptFooter.d.ts.map +0 -1
  90. package/dist/cjs/components/prompt/PromptFooter.js +0 -27
  91. package/dist/cjs/components/prompt/PromptFooter.js.map +0 -1
  92. package/dist/esm/components/prompt/PromptFooter.d.ts +0 -6
  93. package/dist/esm/components/prompt/PromptFooter.d.ts.map +0 -1
  94. package/dist/esm/components/prompt/PromptFooter.js +0 -9
  95. package/dist/esm/components/prompt/PromptFooter.js.map +0 -1
  96. package/src/components/prompt/PromptFooter.tsx +0 -10
@@ -11,14 +11,22 @@ Object.defineProperty(exports, "useUrlSyncedState", {
11
11
  var _instanceof = require("@swc/helpers/_/_instanceof");
12
12
  var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
13
13
  var _react = require("react");
14
+ var slice = Function.prototype.call.bind(Array.prototype.slice);
14
15
  /**
15
- * Get the index of the ? in a URL that denotes the start of the "search".
16
- * Performs a nested search for '#/', to detect hash router urls and take the params of the hash in that case.
16
+ * Split a url into its parts.
17
17
  *
18
- * @param url The URL to search.
19
- * @returns The location of the question mark, or `-1` if not found.
20
- */ var indexOfSearch = function(url) {
21
- return url.indexOf('?', url.indexOf('#/') + 1);
18
+ * @param href The url to extract the parts from.
19
+ * @returns The separate parts, all are an empty string if not present.
20
+ */ var extractParts = function(href) {
21
+ return slice(/^([^?#]*)(\?[^#]*|)(#[^?]*|)(\?.*|)$/.exec(href !== null && href !== void 0 ? href : ''), 1, 5);
22
+ };
23
+ /**
24
+ * The index of the search parameter to use, e.g. hashSearch for hash routes (hash starts with '#/').
25
+ *
26
+ * @param parts: The url parts, as returned by `extractParts`.
27
+ * @returns The index of the search parameter to use (1 or 3).
28
+ */ var searchIndex = function(parts) {
29
+ return /^#\//.test(parts[2]) ? 3 : 1;
22
30
  };
23
31
  /**
24
32
  * Read the **current** search params from `window.location`, with support for detecting React's HashRouter.
@@ -26,9 +34,8 @@ var _react = require("react");
26
34
  *
27
35
  * @returns The `URLSearchParams` instance, and a function that can be used to get an updated href.
28
36
  */ var getSearchParams = function() {
29
- var href = window.location.href;
30
- var searchStart = indexOfSearch(href);
31
- return new URLSearchParams(searchStart < 0 ? undefined : href.substring(searchStart));
37
+ var parts = extractParts(window.location.href);
38
+ return new URLSearchParams(parts[searchIndex(parts)]);
32
39
  };
33
40
  /**
34
41
  * Apply the search params to the current location, using `replaceState` (no navigation history).
@@ -37,13 +44,12 @@ var _react = require("react");
37
44
  * @param params The parameters to apply.
38
45
  */ var applySearchParams = function(params) {
39
46
  var currentHref = window.location.href;
40
- var index = indexOfSearch(currentHref);
41
- var nextHref = index < 0 ? currentHref : currentHref.substring(0, index);
42
- if (params.size > 0) {
43
- nextHref = nextHref.concat('?', params.toString());
44
- }
45
- if (nextHref !== currentHref) {
46
- window.history.replaceState(null, '', nextHref);
47
+ var parts = extractParts(currentHref);
48
+ var search = params.size > 0 ? "?".concat(params.toString()) : '';
49
+ var index = searchIndex(parts);
50
+ if (parts[index] !== search) {
51
+ parts[index] = search;
52
+ window.history.replaceState(null, '', parts.join(''));
47
53
  }
48
54
  };
49
55
  var getInitialState = function(options) {
@@ -59,14 +65,18 @@ var useUrlSyncedState = function(options) {
59
65
  var initialStateSerialized = (0, _react.useMemo)(function() {
60
66
  var stateMap = new Map();
61
67
  var initialize = null;
68
+ var needsApply = false;
62
69
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
63
70
  try {
64
71
  for(var _iterator = options.serializer(getInitialState(options))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
65
72
  var _step_value = _sliced_to_array._(_step.value, 3), key = _step_value[0], value = _step_value[1], alwaysEmit = _step_value[2];
66
73
  stateMap.set(key, value);
67
- if (alwaysEmit && value) {
74
+ if (sync && alwaysEmit && value) {
68
75
  initialize !== null && initialize !== void 0 ? initialize : initialize = getSearchParams();
69
- initialize.set(key, value);
76
+ if (!initialize.has(key)) {
77
+ needsApply = true;
78
+ initialize.set(key, value);
79
+ }
70
80
  }
71
81
  }
72
82
  } catch (err) {
@@ -83,7 +93,7 @@ var useUrlSyncedState = function(options) {
83
93
  }
84
94
  }
85
95
  }
86
- if (initialize) {
96
+ if (needsApply) {
87
97
  applySearchParams(initialize);
88
98
  }
89
99
  return stateMap;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/table/use-url-synced-state.ts"],"sourcesContent":["import {Dispatch, SetStateAction, useMemo, useState} from 'react';\n\n/**\n * A search param entry defines the encoded value of a search parameter as `[key, value, alwaysEmit?]`.\n * The third entry is an optional boolean that defaults to `false`.\n * Setting `alwaysEmit` to `true` means any non-nullish value is always written to the search params,\n * even if it matches the initial value. It is also written on initialization.\n */\nexport type SearchParamEntry = [string, string | null | undefined, boolean?];\n\n/**\n * Get the index of the ? in a URL that denotes the start of the \"search\".\n * Performs a nested search for '#/', to detect hash router urls and take the params of the hash in that case.\n *\n * @param url The URL to search.\n * @returns The location of the question mark, or `-1` if not found.\n */\nconst indexOfSearch = (url: string): number => url.indexOf('?', url.indexOf('#/') + 1);\n\n/**\n * Read the **current** search params from `window.location`, with support for detecting React's HashRouter.\n * Also returns a method that will yield the href (string) value, after any changes made on the params object.\n *\n * @returns The `URLSearchParams` instance, and a function that can be used to get an updated href.\n */\nconst getSearchParams = (): URLSearchParams => {\n const href = window.location.href;\n const searchStart = indexOfSearch(href);\n return new URLSearchParams(searchStart < 0 ? undefined : href.substring(searchStart));\n};\n\n/**\n * Apply the search params to the current location, using `replaceState` (no navigation history).\n * Note that only parameters in the `params` argument will be set, any other current params will be removed.\n *\n * @param params The parameters to apply.\n */\nconst applySearchParams = (params: URLSearchParams): void => {\n const currentHref = window.location.href;\n const index = indexOfSearch(currentHref);\n let nextHref = index < 0 ? currentHref : currentHref.substring(0, index);\n if (params.size > 0) {\n nextHref = nextHref.concat('?', params.toString());\n }\n if (nextHref !== currentHref) {\n window.history.replaceState(null, '', nextHref);\n }\n};\n\nexport interface UseUrlSyncedStateOptions<T> {\n /**\n * The initial state to use, if there would be no search params to deserialize from.\n * These values are also treated as defaults, and if the current state matches the initialState,\n * no value will be written to the search params.\n */\n initialState: T | (() => T);\n /**\n * The serializer function is used to determine how the state is translated to url search parameters.\n * Called each time the state changes.\n * Note that the serializer should always return entries for keys it controls, also if the current value is \"unset\" (`null` or empty).\n * This ensures params get removed from the search when they are being unset.\n *\n * @param stateValue The new state value to serialize.\n * @returns An iterable of `[key, value]` to set as url search parameters.\n * @example (filterValue) => [['filter', filterValue]] // ?filter=filterValue\n */\n serializer: (stateValue: T) => Iterable<SearchParamEntry>;\n /**\n * The deserializer function is used to determine how the url parameters influence the initial state.\n * May return a partial state, values that are not deserialed are taken from the `initialState`.\n * Called only once when initializing the state.\n * @param params All the search parameters of the current url.\n * @param initialState The initialState, can be used to take defaults from.\n * @returns The initial state based on the current url.\n * @example (params) => params.get('filter') ?? '',\n */\n deserializer: (params: URLSearchParams, initialState: T) => T;\n /**\n * Whether the state should be synced with the url, defaults to `true`.\n * When set to `false`, the hook behaves just like a regular `useState` hook from react.\n */\n sync?: boolean;\n}\n\nconst getInitialState = <T>(options: UseUrlSyncedStateOptions<T>): T =>\n options.initialState instanceof Function ? options.initialState() : options.initialState;\n\nexport const useUrlSyncedState = <T>(options: UseUrlSyncedStateOptions<T>) => {\n const sync = options.sync !== false;\n const [state, setState] = useState<T>(() => {\n const initialState = getInitialState(options);\n return sync ? options.deserializer(getSearchParams(), initialState) : initialState;\n });\n // Capture the initial state as a map (first render only!), to compare values and see if they should be set to the params.\n const initialStateSerialized = useMemo(() => {\n const stateMap = new Map<string, string>();\n let initialize: URLSearchParams | null = null;\n for (const [key, value, alwaysEmit] of options.serializer(getInitialState(options))) {\n stateMap.set(key, value);\n if (alwaysEmit && value) {\n initialize ??= getSearchParams();\n initialize.set(key, value);\n }\n }\n if (initialize) {\n applySearchParams(initialize);\n }\n return stateMap;\n }, []);\n\n const enhancedSetState = useMemo<Dispatch<SetStateAction<T>>>(() => {\n if (!sync) {\n return setState;\n }\n return (updater: SetStateAction<T>) => {\n setState((old) => {\n const newValue = updater instanceof Function ? updater(old) : updater;\n\n const search = getSearchParams();\n for (const [key, value, alwaysEmit] of options.serializer(newValue)) {\n if (value && (alwaysEmit || !Object.is(initialStateSerialized.get(key), value))) {\n search.set(key, value);\n } else {\n search.delete(key);\n }\n }\n applySearchParams(search);\n\n return newValue;\n });\n };\n }, [sync]);\n\n return [state, enhancedSetState] as const;\n};\n"],"names":["useUrlSyncedState","indexOfSearch","url","indexOf","getSearchParams","href","window","location","searchStart","URLSearchParams","undefined","substring","applySearchParams","params","currentHref","index","nextHref","size","concat","toString","history","replaceState","getInitialState","options","Function","initialState","sync","useState","deserializer","state","setState","initialStateSerialized","useMemo","stateMap","Map","initialize","serializer","key","value","alwaysEmit","set","enhancedSetState","updater","old","newValue","search","Object","is","get","delete"],"mappings":";;;;+BAuFaA;;;eAAAA;;;;;qBAvF6C;AAU1D;;;;;;CAMC,GACD,IAAMC,gBAAgB,SAACC;WAAwBA,IAAIC,OAAO,CAAC,KAAKD,IAAIC,OAAO,CAAC,QAAQ;;AAEpF;;;;;CAKC,GACD,IAAMC,kBAAkB;IACpB,IAAMC,OAAOC,OAAOC,QAAQ,CAACF,IAAI;IACjC,IAAMG,cAAcP,cAAcI;IAClC,OAAO,IAAII,gBAAgBD,cAAc,IAAIE,YAAYL,KAAKM,SAAS,CAACH;AAC5E;AAEA;;;;;CAKC,GACD,IAAMI,oBAAoB,SAACC;IACvB,IAAMC,cAAcR,OAAOC,QAAQ,CAACF,IAAI;IACxC,IAAMU,QAAQd,cAAca;IAC5B,IAAIE,WAAWD,QAAQ,IAAID,cAAcA,YAAYH,SAAS,CAAC,GAAGI;IAClE,IAAIF,OAAOI,IAAI,GAAG,GAAG;QACjBD,WAAWA,SAASE,MAAM,CAAC,KAAKL,OAAOM,QAAQ;IACnD;IACA,IAAIH,aAAaF,aAAa;QAC1BR,OAAOc,OAAO,CAACC,YAAY,CAAC,MAAM,IAAIL;IAC1C;AACJ;AAqCA,IAAMM,kBAAkB,SAAIC;WACxBA,AAAoB,aAAYC,CAAhCD,QAAQE,YAAY,EAAYD,YAAWD,QAAQE,YAAY,KAAKF,QAAQE,YAAY;;AAErF,IAAMzB,oBAAoB,SAAIuB;IACjC,IAAMG,OAAOH,QAAQG,IAAI,KAAK;IAC9B,IAA0BC,+BAAAA,IAAAA,eAAQ,EAAI;QAClC,IAAMF,eAAeH,gBAAgBC;QACrC,OAAOG,OAAOH,QAAQK,YAAY,CAACxB,mBAAmBqB,gBAAgBA;IAC1E,QAHOI,QAAmBF,cAAZG,WAAYH;IAI1B,0HAA0H;IAC1H,IAAMI,yBAAyBC,IAAAA,cAAO,EAAC;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["../../../../src/components/table/use-url-synced-state.ts"],"sourcesContent":["import {Dispatch, SetStateAction, useMemo, useState} from 'react';\n\n/**\n * A search param entry defines the encoded value of a search parameter as `[key, value, alwaysEmit?]`.\n * The third entry is an optional boolean that defaults to `false`.\n * Setting `alwaysEmit` to `true` means any non-nullish value is always written to the search params,\n * even if it matches the initial value. It is also written on initialization.\n */\nexport type SearchParamEntry = [string, string | null | undefined, boolean?];\n\n/** A URL split into an array of length 4, as [pathname, search, hash, hashSearch] */\ntype UrlParts = [string, string, string, string];\n\nconst slice = Function.prototype.call.bind(Array.prototype.slice) as <T>(\n from: ArrayLike<T>,\n start?: number,\n end?: number,\n) => T[];\n\n/**\n * Split a url into its parts.\n *\n * @param href The url to extract the parts from.\n * @returns The separate parts, all are an empty string if not present.\n */\nconst extractParts = (href: string) => slice(/^([^?#]*)(\\?[^#]*|)(#[^?]*|)(\\?.*|)$/.exec(href ?? ''), 1, 5) as UrlParts;\n\n/**\n * The index of the search parameter to use, e.g. hashSearch for hash routes (hash starts with '#/').\n *\n * @param parts: The url parts, as returned by `extractParts`.\n * @returns The index of the search parameter to use (1 or 3).\n */\nconst searchIndex = (parts: UrlParts): 1 | 3 => (/^#\\//.test(parts[2]) ? 3 : 1);\n\n/**\n * Read the **current** search params from `window.location`, with support for detecting React's HashRouter.\n * Also returns a method that will yield the href (string) value, after any changes made on the params object.\n *\n * @returns The `URLSearchParams` instance, and a function that can be used to get an updated href.\n */\nconst getSearchParams = (): URLSearchParams => {\n const parts = extractParts(window.location.href);\n return new URLSearchParams(parts[searchIndex(parts)]);\n};\n\n/**\n * Apply the search params to the current location, using `replaceState` (no navigation history).\n * Note that only parameters in the `params` argument will be set, any other current params will be removed.\n *\n * @param params The parameters to apply.\n */\nconst applySearchParams = (params: URLSearchParams): void => {\n const currentHref = window.location.href;\n const parts = extractParts(currentHref);\n const search = params.size > 0 ? `?${params.toString()}` : '';\n const index = searchIndex(parts);\n if (parts[index] !== search) {\n parts[index] = search;\n window.history.replaceState(null, '', parts.join(''));\n }\n};\n\nexport interface UseUrlSyncedStateOptions<T> {\n /**\n * The initial state to use, if there would be no search params to deserialize from.\n * These values are also treated as defaults, and if the current state matches the initialState,\n * no value will be written to the search params.\n */\n initialState: T | (() => T);\n /**\n * The serializer function is used to determine how the state is translated to url search parameters.\n * Called each time the state changes.\n * Note that the serializer should always return entries for keys it controls, also if the current value is \"unset\" (`null` or empty).\n * This ensures params get removed from the search when they are being unset.\n *\n * @param stateValue The new state value to serialize.\n * @returns An iterable of `[key, value]` to set as url search parameters.\n * @example (filterValue) => [['filter', filterValue]] // ?filter=filterValue\n */\n serializer: (stateValue: T) => Iterable<SearchParamEntry>;\n /**\n * The deserializer function is used to determine how the url parameters influence the initial state.\n * May return a partial state, values that are not deserialed are taken from the `initialState`.\n * Called only once when initializing the state.\n * @param params All the search parameters of the current url.\n * @param initialState The initialState, can be used to take defaults from.\n * @returns The initial state based on the current url.\n * @example (params) => params.get('filter') ?? '',\n */\n deserializer: (params: URLSearchParams, initialState: T) => T;\n /**\n * Whether the state should be synced with the url, defaults to `true`.\n * When set to `false`, the hook behaves just like a regular `useState` hook from react.\n */\n sync?: boolean;\n}\n\nconst getInitialState = <T>(options: UseUrlSyncedStateOptions<T>): T =>\n options.initialState instanceof Function ? options.initialState() : options.initialState;\n\nexport const useUrlSyncedState = <T>(options: UseUrlSyncedStateOptions<T>) => {\n const sync = options.sync !== false;\n const [state, setState] = useState<T>(() => {\n const initialState = getInitialState(options);\n return sync ? options.deserializer(getSearchParams(), initialState) : initialState;\n });\n // Capture the initial state as a map (first render only!), to compare values and see if they should be set to the params.\n const initialStateSerialized = useMemo(() => {\n const stateMap = new Map<string, string>();\n let initialize: URLSearchParams | null = null;\n let needsApply = false;\n for (const [key, value, alwaysEmit] of options.serializer(getInitialState(options))) {\n stateMap.set(key, value);\n if (sync && alwaysEmit && value) {\n initialize ??= getSearchParams();\n if (!initialize.has(key)) {\n needsApply = true;\n initialize.set(key, value);\n }\n }\n }\n if (needsApply) {\n applySearchParams(initialize);\n }\n return stateMap;\n }, []);\n\n const enhancedSetState = useMemo<Dispatch<SetStateAction<T>>>(() => {\n if (!sync) {\n return setState;\n }\n return (updater: SetStateAction<T>) => {\n setState((old) => {\n const newValue = updater instanceof Function ? updater(old) : updater;\n\n const search = getSearchParams();\n for (const [key, value, alwaysEmit] of options.serializer(newValue)) {\n if (value && (alwaysEmit || !Object.is(initialStateSerialized.get(key), value))) {\n search.set(key, value);\n } else {\n search.delete(key);\n }\n }\n applySearchParams(search);\n\n return newValue;\n });\n };\n }, [sync]);\n\n return [state, enhancedSetState] as const;\n};\n"],"names":["useUrlSyncedState","slice","Function","prototype","call","bind","Array","extractParts","href","exec","searchIndex","parts","test","getSearchParams","window","location","URLSearchParams","applySearchParams","params","currentHref","search","size","toString","index","history","replaceState","join","getInitialState","options","initialState","sync","useState","deserializer","state","setState","initialStateSerialized","useMemo","stateMap","Map","initialize","needsApply","serializer","key","value","alwaysEmit","set","has","enhancedSetState","updater","old","newValue","Object","is","get","delete"],"mappings":";;;;+BAqGaA;;;eAAAA;;;;;qBArG6C;AAa1D,IAAMC,QAAQC,SAASC,SAAS,CAACC,IAAI,CAACC,IAAI,CAACC,MAAMH,SAAS,CAACF,KAAK;AAMhE;;;;;CAKC,GACD,IAAMM,eAAe,SAACC;WAAiBP,MAAM,uCAAuCQ,IAAI,CAACD,iBAAAA,kBAAAA,OAAQ,KAAK,GAAG;;AAEzG;;;;;CAKC,GACD,IAAME,cAAc,SAACC;WAA4B,OAAOC,IAAI,CAACD,KAAK,CAAC,EAAE,IAAI,IAAI;;AAE7E;;;;;CAKC,GACD,IAAME,kBAAkB;IACpB,IAAMF,QAAQJ,aAAaO,OAAOC,QAAQ,CAACP,IAAI;IAC/C,OAAO,IAAIQ,gBAAgBL,KAAK,CAACD,YAAYC,OAAO;AACxD;AAEA;;;;;CAKC,GACD,IAAMM,oBAAoB,SAACC;IACvB,IAAMC,cAAcL,OAAOC,QAAQ,CAACP,IA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A;0BAAA;;;;QAUL,IAAIH,YAAY;YACZvB,kBAAkBsB;QACtB;QACA,OAAOF;IACX,GAAG,EAAE;IAEL,IAAMU,mBAAmBX,IAAAA,cAAO,EAA8B;QAC1D,IAAI,CAACN,MAAM;YACP,OAAOI;QACX;QACA,OAAO,SAACc;YACJd,SAAS,SAACe;gBACN,IAAMC,WAAWF,AAAO,aAAY9C,CAAnB8C,SAAmB9C,YAAW8C,QAAQC,OAAOD;gBAE9D,IAAM5B,SAASP;oBACV,kCAAA,2BAAA;;oBAAL,QAAK,YAAkCe,QAAQa,UAAU,CAACS,8BAArD,SAAA,6BAAA,QAAA,yBAAA,iCAAgE;wBAAhE,qCAAA,iBAAOR,sBAAKC,wBAAOC;wBACpB,IAAID,SAAUC,CAAAA,cAAc,CAACO,OAAOC,EAAE,CAACjB,uBAAuBkB,GAAG,CAACX,MAAMC,MAAK,GAAI;4BAC7EvB,OAAOyB,GAAG,CAACH,KAAKC;wBACpB,OAAO;4BACHvB,OAAOkC,MAAM,CAACZ;wBAClB;oBACJ;;oBANK;oBAAA;;;6BAAA,6BAAA;4BAAA;;;4BAAA;kCAAA;;;;gBAOLzB,kBAAkBG;gBAElB,OAAO8B;YACX;QACJ;IACJ,GAAG;QAACpB;KAAK;IAET,OAAO;QAACG;QAAOc;KAAiB;AACpC"}
@@ -11,7 +11,7 @@ export { type NotificationsProps } from '@mantine/notifications';
11
11
  export * from '@tanstack/table-core';
12
12
  export * from './components';
13
13
  export { noop };
14
- export { ActionIcon, BrowserPreview, Button, CopyToClipboard, Header, Menu, PasswordInput, Select, Table, type ActionIconProps, type ButtonProps, type CopyToClipboardProps, type HeaderProps, type MenuItemProps, type TableProps, type TableState, } from './components';
14
+ export { ActionIcon, BrowserPreview, Button, CopyToClipboard, Header, Menu, Modal, PasswordInput, Select, Table, type ActionIconProps, type ButtonProps, type CopyToClipboardProps, type HeaderProps, type MenuItemProps, type ModalFactory, type TableProps, type TableState, } from './components';
15
15
  export * from './theme';
16
16
  declare module '@mantine/core' {
17
17
  interface MantineThemeColorsOverride {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,IAAI,EAAC,MAAM,eAAe,CAAC;AACvD,OAAO,EAAC,KAAK,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAC,KAAK,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAC,KAAK,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC/D,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,IAAI,EAAC,CAAC;AAGd,OAAO,EACH,UAAU,EACV,cAAc,EACd,MAAM,EACN,eAAe,EACf,MAAM,EACN,IAAI,EACJ,aAAa,EACb,MAAM,EACN,KAAK,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,UAAU,GAClB,MAAM,cAAc,CAAC;AAEtB,cAAc,SAAS,CAAC;AAExB,OAAO,QAAQ,eAAe,CAAC;IAC3B,UAAiB,0BAA0B;QACvC,MAAM,EAAE,MAAM,CAAC,MAAM,OAAO,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC;KACjF;CACJ;AAED,OAAO,QAAQ,uBAAuB,CAAC;IACnC,UAAU,UAAU,CAAC,KAAK,SAAS,OAAO,EAAE,MAAM;QAC9C;;;;WAIG;QACH,aAAa,EAAE,OAAO,CAAC;KAC1B;CACJ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GED
@@ -27,6 +27,9 @@ _export(exports, {
27
27
  Menu: function() {
28
28
  return _components.Menu;
29
29
  },
30
+ Modal: function() {
31
+ return _components.Modal;
32
+ },
30
33
  Pagination: function() {
31
34
  return _core.Pagination;
32
35
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {MantineColorsTuple, noop} from '@mantine/core';\nimport {type RowData} from '@tanstack/table-core';\nimport {type PlasmaColors} from './theme/PlasmaColors';\n\nexport * from '@mantine/carousel';\nexport * from '@mantine/core';\nexport {Pagination} from '@mantine/core';\nexport * from '@mantine/form';\nexport * from '@mantine/hooks';\nexport * from '@mantine/notifications';\nexport {type NotificationsProps} from '@mantine/notifications';\nexport * from '@tanstack/table-core';\nexport * from './components';\nexport {noop};\n\n// explicitly overriding mantine components\nexport {\n ActionIcon,\n BrowserPreview,\n Button,\n CopyToClipboard,\n Header,\n Menu,\n PasswordInput,\n Select,\n Table,\n type ActionIconProps,\n type ButtonProps,\n type CopyToClipboardProps,\n type HeaderProps,\n type MenuItemProps,\n type TableProps,\n type TableState,\n} from './components';\n\nexport * from './theme';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n colors: Record<keyof typeof PlasmaColors | (string & {}), MantineColorsTuple>;\n }\n}\n\ndeclare module '@tanstack/react-table' {\n interface ColumnMeta<TData extends RowData, TValue> {\n /**\n * Whether the column is a control column.\n * Control columns are columns that are not part of the data but are used to control the table.\n * For example, a column that contains checkboxes to select rows.\n */\n controlColumn: boolean;\n }\n}\n"],"names":["ActionIcon","BrowserPreview","Button","CopyToClipboard","Header","Menu","Pagination","PasswordInput","Select","Table","noop"],"mappings":";;;;;;;;;;;IAiBIA,UAAU;eAAVA,sBAAU;;IACVC,cAAc;eAAdA,0BAAc;;IACdC,MAAM;eAANA,kBAAM;;IACNC,eAAe;eAAfA,2BAAe;;IACfC,MAAM;eAANA,kBAAM;;IACNC,IAAI;eAAJA,gBAAI;;IAhBAC,UAAU;eAAVA,gBAAU;;IAiBdC,aAAa;eAAbA,yBAAa;;IACbC,MAAM;eAANA,kBAAM;;IACNC,KAAK;eAALA,iBAAK;;IAZDC,IAAI;eAAJA,UAAI;;;;mCAb2B;uBAIzB;uBAGA;uBACA;uBACA;uBAEA;yCACA;uBAuBA"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {MantineColorsTuple, noop} from '@mantine/core';\nimport {type RowData} from '@tanstack/table-core';\nimport {type PlasmaColors} from './theme/PlasmaColors';\n\nexport * from '@mantine/carousel';\nexport * from '@mantine/core';\nexport {Pagination} from '@mantine/core';\nexport * from '@mantine/form';\nexport * from '@mantine/hooks';\nexport * from '@mantine/notifications';\nexport {type NotificationsProps} from '@mantine/notifications';\nexport * from '@tanstack/table-core';\nexport * from './components';\nexport {noop};\n\n// explicitly overriding mantine components\nexport {\n ActionIcon,\n BrowserPreview,\n Button,\n CopyToClipboard,\n Header,\n Menu,\n Modal,\n PasswordInput,\n Select,\n Table,\n type ActionIconProps,\n type ButtonProps,\n type CopyToClipboardProps,\n type HeaderProps,\n type MenuItemProps,\n type ModalFactory,\n type TableProps,\n type TableState,\n} from './components';\n\nexport * from './theme';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n colors: Record<keyof typeof PlasmaColors | (string & {}), MantineColorsTuple>;\n }\n}\n\ndeclare module '@tanstack/react-table' {\n interface ColumnMeta<TData extends RowData, TValue> {\n /**\n * Whether the column is a control column.\n * Control columns are columns that are not part of the data but are used to control the table.\n * For example, a column that contains checkboxes to select rows.\n */\n controlColumn: boolean;\n }\n}\n"],"names":["ActionIcon","BrowserPreview","Button","CopyToClipboard","Header","Menu","Modal","Pagination","PasswordInput","Select","Table","noop"],"mappings":";;;;;;;;;;;IAiBIA,UAAU;eAAVA,sBAAU;;IACVC,cAAc;eAAdA,0BAAc;;IACdC,MAAM;eAANA,kBAAM;;IACNC,eAAe;eAAfA,2BAAe;;IACfC,MAAM;eAANA,kBAAM;;IACNC,IAAI;eAAJA,gBAAI;;IACJC,KAAK;eAALA,iBAAK;;IAjBDC,UAAU;eAAVA,gBAAU;;IAkBdC,aAAa;eAAbA,yBAAa;;IACbC,MAAM;eAANA,kBAAM;;IACNC,KAAK;eAALA,iBAAK;;IAbDC,IAAI;eAAJA,UAAI;;;;mCAb2B;uBAIzB;uBAGA;uBACA;uBACA;uBAEA;yCACA;uBAyBA"}
@@ -1,4 +1,5 @@
1
1
  import { InputWrapperProps, StackProps } from '@mantine/core';
2
+ import { editor as monacoEditor } from 'monaco-editor';
2
3
  import { FunctionComponent } from 'react';
3
4
  interface CodeEditorProps extends Omit<InputWrapperProps, 'inputContainer' | 'inputWrapperOrder' | 'classNames' | 'styles' | 'vars' | 'onChange'>, Omit<StackProps, 'onChange'> {
4
5
  /**
@@ -43,6 +44,12 @@ interface CodeEditorProps extends Omit<InputWrapperProps, 'inputContainer' | 'in
43
44
  * @default 'local'
44
45
  */
45
46
  monacoLoader?: 'cdn' | 'local';
47
+ /**
48
+ * Options to pass to the monaco editor.
49
+ * Currently only supporting [`tabSize`](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html#tabSize).
50
+ *
51
+ */
52
+ options?: Pick<monacoEditor.IStandaloneEditorConstructionOptions, 'tabSize'>;
46
53
  }
47
54
  export declare const CodeEditor: FunctionComponent<CodeEditorProps>;
48
55
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKH,iBAAiB,EAIjB,UAAU,EAKb,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAC,iBAAiB,EAA8B,MAAM,OAAO,CAAC;AAQrE,UAAU,eACN,SAAQ,IAAI,CACJ,iBAAiB,EACjB,gBAAgB,GAAG,mBAAmB,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CACzF,EACD,IAAI,CAAC,UAA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Q,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IACrF,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,IAAI,CAAC;IAClB,+CAA+C;IAC/C,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB,qDAAqD;IACrD,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,oCAAoC,EAAE,SAAS,CAAC,CAAC;CAChF;AASD,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAmLzD,CAAC"}
@@ -16,7 +16,9 @@ const defaultProps = {
16
16
  minHeight: 300
17
17
  };
18
18
  export const CodeEditor = (props)=>{
19
- const { language, defaultValue, onChange, onCopy, onSearch, onFocus, value, label, required, labelProps, error, errorProps, description, descriptionProps, minHeight, maxHeight, disabled, monacoLoader, ...others } = useProps('CodeEditor', defaultProps, props);
19
+ const { language, defaultValue, onChange, onCopy, onSearch, onFocus, value, label, required, labelProps, error, errorProps, description, descriptionProps, minHeight, maxHeight, disabled, monacoLoader, options: { tabSize } = {
20
+ tabSize: 2
21
+ }, ...others } = useProps('CodeEditor', defaultProps, props);
20
22
  const [loaded, setLoaded] = useState(false);
21
23
  const [_value, handleChange] = useUncontrolled({
22
24
  value,
@@ -140,7 +142,7 @@ export const CodeEditor = (props)=>{
140
142
  formatOnPaste: true,
141
143
  fontSize: px(theme.fontSizes.xs),
142
144
  readOnly: disabled,
143
- tabSize: 2
145
+ tabSize
144
146
  },
145
147
  value: _value,
146
148
  onChange: handleChange,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n Group,\n Input,\n InputWrapperProps,\n Loader,\n Space,\n Stack,\n StackProps,\n px,\n useMantineColorScheme,\n useMantineTheme,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {Monaco, loader} from '@monaco-editor/react';\nimport {editor as monacoEditor} from 'monaco-editor';\nimport {FunctionComponent, useEffect, useRef, useState} from 'react';\n\nimport cx from 'clsx';\nimport {useParentHeight} from '../../hooks';\nimport {CopyToClipboard} from '../copyToClipboard';\nimport CodeEditorClasses from './CodeEditor.module.css';\nimport {XML} from './languages/xml';\nimport {Search} from './search';\ninterface CodeEditorProps\n extends Omit<\n InputWrapperProps,\n 'inputContainer' | 'inputWrapperOrder' | 'classNames' | 'styles' | 'vars' | 'onChange'\n >,\n Omit<StackProps, 'onChange'> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml' | (string & unknown);\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the search icon is clicked */\n onSearch?(): void;\n /** Called whenever the copy icon is clicked */\n onCopy?(): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onCopy,\n onSearch,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const registerThemes = (monaco: Monaco) => {\n monaco.editor.defineTheme('light-disabled', {\n base: 'vs',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': theme.colors.gray[2],\n },\n });\n monaco.editor.defineTheme('vs-dark-disabled', {\n base: 'vs-dark',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': theme.colors.navy[7],\n },\n });\n };\n\n const handleSearch = () => {\n if (editorRef.current) {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n onSearch?.();\n }\n };\n\n const [hasMonacoError, setHasMonacoError] = useState(false);\n const renderErrorOutline = !!error || hasMonacoError;\n const theme = useMantineTheme();\n const {colorScheme} = useMantineColorScheme();\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const handleValidate = (markers: monacoEditor.IMarker[]) => {\n setHasMonacoError(\n markers.some((marker) => marker.severity === loader.__getMonacoInstance().MarkerSeverity.Error),\n );\n };\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _buttons = (\n <Group justify=\"right\" gap={0}>\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} onCopy={() => onCopy?.()} />\n </Group>\n );\n let editorTheme = colorScheme === 'light' ? 'light' : 'vs-dark';\n if (disabled) {\n editorTheme += '-disabled';\n }\n\n const _editor = loaded ? (\n <Box\n p=\"md\"\n pl=\"xs\"\n className={cx(\n CodeEditorClasses.editor,\n {[CodeEditorClasses.valid]: !renderErrorOutline},\n {[CodeEditorClasses.error]: renderErrorOutline},\n {[CodeEditorClasses.disabled]: disabled},\n )}\n data-testid=\"editor-wrapper\"\n >\n <Editor\n onValidate={handleValidate}\n defaultLanguage={language}\n theme={editorTheme}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs) as number,\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n editorRef.current = editor;\n registerLanguages(monaco);\n registerThemes(monaco);\n editor.onDidFocusEditorText(() => onFocus?.());\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={CodeEditorClasses.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack justify=\"flex-start\" gap={0} h={Math.max(parentHeight, minHeight)} mah={maxHeight} ref={ref} {...others}>\n {_header}\n {_buttons}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["Box","Center","Group","Input","Loader","Space","Stack","px","useMantineColorScheme","useMantineTheme","useProps","useUncontrolled","Editor","loader","useEffect","useRef","useState","cx","useParentHeight","CopyToClipboard","CodeEditorClasses","XML","Search","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onCopy","onSearch","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","loaded","setLoaded","_value","handleChange","finalValue","parentHeight","ref","editorRef","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","registerThemes","editor","defineTheme","base","inherit","rules","colors","theme","gray","navy","handleSearch","current","focus","trigger","hasMonacoError","setHasMonacoError","renderErrorOutline","colorScheme","handleValidate","markers","some","marker","severity","__getMonacoInstance","MarkerSeverity","Error","_label","Label","_description","Description","_error","mt","h","_header","_buttons","justify","gap","editorTheme","_editor","p","pl","className","valid","data-testid","onValidate","defaultLanguage","options","minimap","enabled","wordWrap","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","Math","max","mah"],"mappings":";AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,EAAE,EACFC,qBAAqB,EACrBC,eAAe,EACfC,QAAQ,QACL,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,OAAOC,UAAiBC,MAAM,QAAO,uBAAuB;AAE5D,SAA2BC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAO,QAAQ;AAErE,OAAOC,QAAQ,OAAO;AACtB,SAAQC,eAAe,QAAO,cAAc;AAC5C,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;IACtD,IAAIjC,UAAU;QACVqD,eAAe;IACnB;IAEA,MAAMC,UAAUpD,uBACZ,KAAC7C;QACGkG,GAAE;QACFC,IAAG;QACHC,WAAWnF,GACPG,kBAAkBwC,MAAM,EACxB;YAAC,CAACxC,kBAAkBiF,KAAK,CAAC,EAAE,CAAC1B;QAAkB,GAC/C;YAAC,CAACvD,kBAAkBkB,KAAK,CAAC,EAAEqC;QAAkB,GAC9C;YAAC,CAACvD,kBAAkBuB,QAAQ,CAAC,EAAEA;QAAQ;QAE3C2D,eAAY;kBAEZ,cAAA,KAAC1F;YACG2F,YAAY1B;YACZ2B,iBAAiBhF;YACjB0C,OAAO8B;YACPS,SAAS;gBACLC,SAAS;oBAACC,SAAS;gBAAK;gBACxBC,UAAU;gBACVC,sBAAsB;gBACtBC,eAAe;gBACfC,UAAUxG,GAAG2D,MAAM8C,SAAS,CAACC,EAAE;gBAC/BC,UAAUvE;gBACVwE,SAAS;YACb;YACAjF,OAAOa;YACPjB,UAAUkB;YACVoE,SAAS,CAACxD,QAAQJ;gBACdJ,UAAUkB,OAAO,GAAGV;gBACpBH,kBAAkBD;gBAClBG,eAAeH;gBACfI,OAAOyD,oBAAoB,CAAC,IAAMpF;gBAClC2B,OAAO0D,mBAAmB,CAAC;oBACvB,MAAM1D,OAAO2D,SAAS,CAAC,gCAAgCC,GAAG;gBAC9D;YACJ;;uBAIR,KAACvH;QAAOmG,WAAWhF,kBAAkBwC,MAAM;kBACvC,cAAA,KAACxD;;IAIT,qBACI,MAACE;QAAMwF,SAAQ;QAAaC,KAAK;QAAGJ,GAAG8B,KAAKC,GAAG,CAACxE,cAAcvB;QAAYgG,KAAKjF;QAAWS,KAAKA;QAAM,GAAGP,MAAM;;YACzGgD;YACAC;YACAI;YACAR;;;AAGb,EAAE"}
1
+ {"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n Group,\n Input,\n InputWrapperProps,\n Loader,\n Space,\n Stack,\n StackProps,\n px,\n useMantineColorScheme,\n useMantineTheme,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {Monaco, loader} from '@monaco-editor/react';\nimport {editor as monacoEditor} from 'monaco-editor';\nimport {FunctionComponent, useEffect, useRef, useState} from 'react';\n\nimport cx from 'clsx';\nimport {useParentHeight} from '../../hooks';\nimport {CopyToClipboard} from '../copyToClipboard';\nimport CodeEditorClasses from './CodeEditor.module.css';\nimport {XML} from './languages/xml';\nimport {Search} from './search';\ninterface CodeEditorProps\n extends Omit<\n InputWrapperProps,\n 'inputContainer' | 'inputWrapperOrder' | 'classNames' | 'styles' | 'vars' | 'onChange'\n >,\n Omit<StackProps, 'onChange'> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml' | (string & unknown);\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the search icon is clicked */\n onSearch?(): void;\n /** Called whenever the copy icon is clicked */\n onCopy?(): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n /**\n * Options to pass to the monaco editor.\n * Currently only supporting [`tabSize`](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html#tabSize).\n *\n */\n options?: Pick<monacoEditor.IStandaloneEditorConstructionOptions, 'tabSize'>;\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onCopy,\n onSearch,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n options: {tabSize} = {tabSize: 2},\n ...others\n } = useProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const registerThemes = (monaco: Monaco) => {\n monaco.editor.defineTheme('light-disabled', {\n base: 'vs',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': theme.colors.gray[2],\n },\n });\n monaco.editor.defineTheme('vs-dark-disabled', {\n base: 'vs-dark',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': theme.colors.navy[7],\n },\n });\n };\n\n const handleSearch = () => {\n if (editorRef.current) {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n onSearch?.();\n }\n };\n\n const [hasMonacoError, setHasMonacoError] = useState(false);\n const renderErrorOutline = !!error || hasMonacoError;\n const theme = useMantineTheme();\n const {colorScheme} = useMantineColorScheme();\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const handleValidate = (markers: monacoEditor.IMarker[]) => {\n setHasMonacoError(\n markers.some((marker) => marker.severity === loader.__getMonacoInstance().MarkerSeverity.Error),\n );\n };\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _buttons = (\n <Group justify=\"right\" gap={0}>\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} onCopy={() => onCopy?.()} />\n </Group>\n );\n let editorTheme = colorScheme === 'light' ? 'light' : 'vs-dark';\n if (disabled) {\n editorTheme += '-disabled';\n }\n\n const _editor = loaded ? (\n <Box\n p=\"md\"\n pl=\"xs\"\n className={cx(\n CodeEditorClasses.editor,\n {[CodeEditorClasses.valid]: !renderErrorOutline},\n {[CodeEditorClasses.error]: renderErrorOutline},\n {[CodeEditorClasses.disabled]: disabled},\n )}\n data-testid=\"editor-wrapper\"\n >\n <Editor\n onValidate={handleValidate}\n defaultLanguage={language}\n theme={editorTheme}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs) as number,\n readOnly: disabled,\n tabSize,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n editorRef.current = editor;\n registerLanguages(monaco);\n registerThemes(monaco);\n editor.onDidFocusEditorText(() => onFocus?.());\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={CodeEditorClasses.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack justify=\"flex-start\" gap={0} h={Math.max(parentHeight, minHeight)} mah={maxHeight} ref={ref} {...others}>\n {_header}\n {_buttons}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["Box","Center","Group","Input","Loader","Space","Stack","px","useMantineColorScheme","useMantineTheme","useProps","useUncontrolled","Editor","loader","useEffect","useRef","useState","cx","useParentHeight","CopyToClipboard","CodeEditorClasses","XML","Search","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onCopy","onSearch","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","options","tabSize","others","loaded","setLoaded","_value","handleChange","finalValue","parentHeight","ref","editorRef","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","registerThemes","editor","defineTheme","base","inherit","rules","colors","theme","gray","navy","handleSearch","current","focus","trigger","hasMonacoError","setHasMonacoError","renderErrorOutline","colorScheme","handleValidate","markers","some","marker","severity","__getMonacoInstance","MarkerSeverity","Error","_label","Label","_description","Description","_error","mt","h","_header","_buttons","justify","gap","editorTheme","_editor","p","pl","className","valid","data-testid","onValidate","defaultLanguage","minimap","enabled","wordWrap","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","Math","max","mah"],"mappings":";AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,EAAE,EACFC,qBAAqB,EACrBC,eAAe,EACfC,QAAQ,QACL,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,OAAOC,UAAiBC,MAAM,QAAO,uBAAuB;AAE5D,SAA2BC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAO,QAAQ;AAErE,OAAOC,QAAQ,OAAO;AACtB,SAAQC,eAAe,QAAO,cAAc;AAC5C,SAAQC,eAAe,QAAO,qBAAqB;AACnD,OAAOC,uBAAuB,0BAA0B;AACxD,SAAQC,GAAG,QAAO,kBAAkB;AACpC,SAAQC,MAAM,QAAO,WAAW;AAyDhC,MAAMC,eAAyC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GAAE;QACFC,IAAG;QACHC,WAAWrF,GACPG,kBAAkB0C,MAAM,EACxB;YAAC,CAAC1C,kBAAkBmF,KAAK,CAAC,EAAE,CAAC1B;QAAkB,GAC/C;YAAC,CAACzD,kBAAkBkB,KAAK,CAAC,EAAEuC;QAAkB,GAC9C;YAAC,CAACzD,kBAAkBuB,QAAQ,CAAC,EAAEA;QAAQ;QAE3C6D,eAAY;kBAEZ,cAAA,KAAC5F;YACG6F,YAAY1B;YACZ2B,iBAAiBlF;YACjB4C,OAAO8B;YACPtD,SAAS;gBACL+D,SAAS;oBAACC,SAAS;gBAAK;gBACxBC,UAAU;gBACVC,sBAAsB;gBACtBC,eAAe;gBACfC,UAAUzG,GAAG6D,MAAM6C,SAAS,CAACC,EAAE;gBAC/BC,UAAUxE;gBACVE;YACJ;YACAX,OAAOe;YACPnB,UAAUoB;YACVkE,SAAS,CAACtD,QAAQJ;gBACdJ,UAAUkB,OAAO,GAAGV;gBACpBH,kBAAkBD;gBAClBG,eAAeH;gBACfI,OAAOuD,oBAAoB,CAAC,IAAMpF;gBAClC6B,OAAOwD,mBAAmB,CAAC;oBACvB,MAAMxD,OAAOyD,SAAS,CAAC,gCAAgCC,GAAG;gBAC9D;YACJ;;uBAIR,KAACvH;QAAOqG,WAAWlF,kBAAkB0C,MAAM;kBACvC,cAAA,KAAC1D;;IAIT,qBACI,MAACE;QAAM0F,SAAQ;QAAaC,KAAK;QAAGJ,GAAG4B,KAAKC,GAAG,CAACtE,cAAczB;QAAYgG,KAAKjF;QAAWW,KAAKA;QAAM,GAAGP,MAAM;;YACzGgD;YACAC;YACAI;YACAR;;;AAGb,EAAE"}
@@ -10,6 +10,7 @@ export * from './ellipsis-text';
10
10
  export * from './header';
11
11
  export * from './inline-confirm';
12
12
  export * from './menu';
13
+ export * from './modal';
13
14
  export * from './prompt';
14
15
  export * from './read-only';
15
16
  export * from './sticky-footer';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -10,6 +10,7 @@ export * from './ellipsis-text';
10
10
  export * from './header';
11
11
  export * from './inline-confirm';
12
12
  export * from './menu';
13
+ export * from './modal';
13
14
  export * from './prompt';
14
15
  export * from './read-only';
15
16
  export * from './sticky-footer';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from './action-icon';\nexport * from './blank-slate';\nexport * from './browser-preview';\nexport * from './button';\nexport * from './code-editor';\nexport * from './collection';\nexport * from './copyToClipboard';\nexport * from './date-range-picker';\nexport * from './ellipsis-text';\nexport * from './header';\nexport * from './inline-confirm';\nexport * from './menu';\nexport * from './prompt';\nexport * from './read-only';\nexport * from './sticky-footer';\nexport * from './table';\nexport * from './child-form';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,oBAAoB;AAClC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,mBAAmB;AACjC,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,cAAc;AAC5B,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,eAAe"}
1
+ {"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from './action-icon';\nexport * from './blank-slate';\nexport * from './browser-preview';\nexport * from './button';\nexport * from './code-editor';\nexport * from './collection';\nexport * from './copyToClipboard';\nexport * from './date-range-picker';\nexport * from './ellipsis-text';\nexport * from './header';\nexport * from './inline-confirm';\nexport * from './menu';\nexport * from './modal';\nexport * from './prompt';\nexport * from './read-only';\nexport * from './sticky-footer';\nexport * from './table';\nexport * from './child-form';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,oBAAoB;AAClC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,mBAAmB;AACjC,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,cAAc;AAC5B,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,eAAe"}
@@ -0,0 +1,11 @@
1
+ import { ModalFactory as MantineModalFactory } from '@mantine/core';
2
+ import { ModalFooter as PlasmaModalFooter } from './ModalFooter';
3
+ type PlasmaModalFactory = Omit<MantineModalFactory, 'staticComponents'> & {
4
+ staticComponents: MantineModalFactory['staticComponents'] & {
5
+ Footer: typeof PlasmaModalFooter;
6
+ };
7
+ };
8
+ export declare const Modal: import("@mantine/core").MantineComponent<PlasmaModalFactory>;
9
+ export type ModalFactory = PlasmaModalFactory;
10
+ export {};
11
+ //# sourceMappingURL=Modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,YAAY,IAAI,mBAAmB,EAEtC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,WAAW,IAAI,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAG/D,KAAK,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,GAAG;IACtE,gBAAgB,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,GAAG;QACxD,MAAM,EAAE,OAAO,iBAAiB,CAAC;KACpC,CAAC;CACL,CAAC;AAiBF,eAAO,MAAM,KAAK,8DAAc,CAAC;AAEjC,MAAM,MAAM,YAAY,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { factory, Modal as MantineModal } from '@mantine/core';
3
+ import { ModalFooter as PlasmaModalFooter } from './ModalFooter';
4
+ const PlasmaModal = factory((props, ref)=>/*#__PURE__*/ _jsx(MantineModal, {
5
+ ref: ref,
6
+ ...props
7
+ }));
8
+ PlasmaModal.displayName = '@coveord/plasma-mantine/Modal';
9
+ PlasmaModal.Root = MantineModal.Root;
10
+ PlasmaModal.Body = MantineModal.Body;
11
+ PlasmaModal.Overlay = MantineModal.Overlay;
12
+ PlasmaModal.Content = MantineModal.Content;
13
+ PlasmaModal.Header = MantineModal.Header;
14
+ PlasmaModal.Title = MantineModal.Title;
15
+ PlasmaModal.CloseButton = MantineModal.CloseButton;
16
+ PlasmaModal.Stack = MantineModal.Stack;
17
+ PlasmaModal.Footer = PlasmaModalFooter;
18
+ export const Modal = PlasmaModal;
19
+
20
+ //# sourceMappingURL=Modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/modal/Modal.tsx"],"sourcesContent":["import {\n factory,\n Modal as MantineModal,\n ModalFactory as MantineModalFactory,\n ModalProps as MantineModalProps,\n} from '@mantine/core';\nimport {ModalFooter as PlasmaModalFooter} from './ModalFooter';\n\n// Need to redeclare the factory to override and add footer to the props type\ntype PlasmaModalFactory = Omit<MantineModalFactory, 'staticComponents'> & {\n staticComponents: MantineModalFactory['staticComponents'] & {\n Footer: typeof PlasmaModalFooter;\n };\n};\n\nconst PlasmaModal = factory<PlasmaModalFactory>((props: MantineModalProps, ref) => (\n <MantineModal ref={ref} {...props} />\n));\n\nPlasmaModal.displayName = '@coveord/plasma-mantine/Modal';\nPlasmaModal.Root = MantineModal.Root;\nPlasmaModal.Body = MantineModal.Body;\nPlasmaModal.Overlay = MantineModal.Overlay;\nPlasmaModal.Content = MantineModal.Content;\nPlasmaModal.Header = MantineModal.Header;\nPlasmaModal.Title = MantineModal.Title;\nPlasmaModal.CloseButton = MantineModal.CloseButton;\nPlasmaModal.Stack = MantineModal.Stack;\nPlasmaModal.Footer = PlasmaModalFooter;\n\nexport const Modal = PlasmaModal;\n\nexport type ModalFactory = PlasmaModalFactory;\n"],"names":["factory","Modal","MantineModal","ModalFooter","PlasmaModalFooter","PlasmaModal","props","ref","displayName","Root","Body","Overlay","Content","Header","Title","CloseButton","Stack","Footer"],"mappings":";AAAA,SACIA,OAAO,EACPC,SAASC,YAAY,QAGlB,gBAAgB;AACvB,SAAQC,eAAeC,iBAAiB,QAAO,gBAAgB;AAS/D,MAAMC,cAAcL,QAA4B,CAACM,OAA0BC,oBACvE,KAACL;QAAaK,KAAKA;QAAM,GAAGD,KAAK;;AAGrCD,YAAYG,WAAW,GAAG;AAC1BH,YAAYI,IAAI,GAAGP,aAAaO,IAAI;AACpCJ,YAAYK,IAAI,GAAGR,aAAaQ,IAAI;AACpCL,YAAYM,OAAO,GAAGT,aAAaS,OAAO;AAC1CN,YAAYO,OAAO,GAAGV,aAAaU,OAAO;AAC1CP,YAAYQ,MAAM,GAAGX,aAAaW,MAAM;AACxCR,YAAYS,KAAK,GAAGZ,aAAaY,KAAK;AACtCT,YAAYU,WAAW,GAAGb,aAAaa,WAAW;AAClDV,YAAYW,KAAK,GAAGd,aAAac,KAAK;AACtCX,YAAYY,MAAM,GAAGb;AAErB,OAAO,MAAMH,QAAQI,YAAY"}
@@ -0,0 +1,9 @@
1
+ .footer {
2
+ border-top: 1px solid var(--mantine-color-gray-3);
3
+ }
4
+
5
+ .modalFooterSticky {
6
+ padding-bottom: 0;
7
+ margin: var(--mb-padding) calc(-1 * var(--mb-padding)) calc(var(--mantine-spacing-md) - var(--mb-padding))
8
+ calc(-1 * var(--mb-padding));
9
+ }
@@ -0,0 +1,20 @@
1
+ import { Factory } from '@mantine/core';
2
+ import { StickyFooterProps, StickyFooterStylesNames } from '../sticky-footer';
3
+ export interface ModalFooterProps extends Omit<StickyFooterProps, 'variant'> {
4
+ /**
5
+ * If the footer is sticky, its margin will be adjusted to counteract the padding of the Modal.Body, ensuring the footer visually sticks to the bottom of the modal.
6
+ */
7
+ sticky?: boolean;
8
+ }
9
+ export type ModalFooterStylesNames = StickyFooterStylesNames;
10
+ export type ModalFooterFactory = Factory<{
11
+ props: ModalFooterProps;
12
+ ref: HTMLDivElement;
13
+ stylesNames: ModalFooterStylesNames;
14
+ }>;
15
+ export declare const ModalFooter: import("@mantine/core").MantineComponent<{
16
+ props: ModalFooterProps;
17
+ ref: HTMLDivElement;
18
+ stylesNames: ModalFooterStylesNames;
19
+ }>;
20
+ //# sourceMappingURL=ModalFooter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalFooter.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/ModalFooter.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAe,iBAAiB,EAAE,uBAAuB,EAAC,MAAM,kBAAkB,CAAC;AAG1F,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC;IACxE;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;IACrC,KAAK,EAAE,gBAAgB,CAAC;IACxB,GAAG,EAAE,cAAc,CAAC;IACpB,WAAW,EAAE,sBAAsB,CAAC;CACvC,CAAC,CAAC;AAOH,eAAO,MAAM,WAAW;WAVb,gBAAgB;SAClB,cAAc;iBACN,sBAAsB;EA4BrC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef, useEffect } from 'react';
3
+ import clsx from 'clsx';
4
+ import { factory } from '@mantine/core';
5
+ import { StickyFooter } from '../sticky-footer';
6
+ import classes from './Modal.module.css';
7
+ const ensuresFooterHasEvenHeight = (footer)=>{
8
+ const remainder = footer.offsetHeight % 2;
9
+ footer.style.height = `${footer.offsetHeight - remainder + 2}px`;
10
+ };
11
+ export const ModalFooter = factory(({ sticky, ...props }, ref)=>{
12
+ const _ref = useRef();
13
+ const footerRef = ref || _ref;
14
+ useEffect(()=>{
15
+ if (typeof footerRef !== 'function' && footerRef.current) {
16
+ ensuresFooterHasEvenHeight(footerRef.current);
17
+ }
18
+ // if ref === 'function', this is a callback ref. Haven't found any solution for adjusting the height in this case
19
+ }, [
20
+ ref,
21
+ props.h
22
+ ]);
23
+ return /*#__PURE__*/ _jsx(StickyFooter, {
24
+ className: clsx(classes.footer, {
25
+ [classes.modalFooterSticky]: !!sticky
26
+ }),
27
+ ref: footerRef,
28
+ ...props
29
+ });
30
+ });
31
+
32
+ //# sourceMappingURL=ModalFooter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/modal/ModalFooter.tsx"],"sourcesContent":["import {useRef, useEffect} from 'react';\nimport clsx from 'clsx';\nimport {Factory, factory} from '@mantine/core';\nimport {StickyFooter, StickyFooterProps, StickyFooterStylesNames} from '../sticky-footer';\nimport classes from './Modal.module.css';\n\nexport interface ModalFooterProps extends Omit<StickyFooterProps, 'variant'> {\n /**\n * If the footer is sticky, its margin will be adjusted to counteract the padding of the Modal.Body, ensuring the footer visually sticks to the bottom of the modal.\n */\n sticky?: boolean;\n}\n\nexport type ModalFooterStylesNames = StickyFooterStylesNames;\n\nexport type ModalFooterFactory = Factory<{\n props: ModalFooterProps;\n ref: HTMLDivElement;\n stylesNames: ModalFooterStylesNames;\n}>;\n\nconst ensuresFooterHasEvenHeight = (footer: HTMLElement) => {\n const remainder = footer.offsetHeight % 2;\n footer.style.height = `${footer.offsetHeight - remainder + 2}px`;\n};\n\nexport const ModalFooter = factory<ModalFooterFactory>(({sticky, ...props}, ref) => {\n const _ref = useRef<HTMLDivElement>();\n\n const footerRef = ref || _ref;\n\n useEffect(() => {\n if (typeof footerRef !== 'function' && footerRef.current) {\n ensuresFooterHasEvenHeight(footerRef.current);\n }\n\n // if ref === 'function', this is a callback ref. Haven't found any solution for adjusting the height in this case\n }, [ref, props.h]);\n\n return (\n <StickyFooter\n className={clsx(classes.footer, {[classes.modalFooterSticky]: !!sticky})}\n ref={footerRef}\n {...props}\n />\n );\n});\n"],"names":["useRef","useEffect","clsx","factory","StickyFooter","classes","ensuresFooterHasEvenHeight","footer","remainder","offsetHeight","style","height","ModalFooter","sticky","props","ref","_ref","footerRef","current","h","className","modalFooterSticky"],"mappings":";AAAA,SAAQA,MAAM,EAAEC,SAAS,QAAO,QAAQ;AACxC,OAAOC,UAAU,OAAO;AACxB,SAAiBC,OAAO,QAAO,gBAAgB;AAC/C,SAAQC,YAAY,QAAmD,mBAAmB;AAC1F,OAAOC,aAAa,qBAAqB;AAiBzC,MAAMC,6BAA6B,CAACC;IAChC,MAAMC,YAAYD,OAAOE,YAAY,GAAG;IACxCF,OAAOG,KAAK,CAACC,MAAM,GAAG,GAAGJ,OAAOE,YAAY,GAAGD,YAAY,EAAE,EAAE,CAAC;AACpE;AAEA,OAAO,MAAMI,cAAcT,QAA4B,CAAC,EAACU,MAAM,EAAE,GAAGC,OAAM,EAAEC;IACxE,MAAMC,OAAOhB;IAEb,MAAMiB,YAAYF,OAAOC;IAEzBf,UAAU;QACN,IAAI,OAAOgB,cAAc,cAAcA,UAAUC,OAAO,EAAE;YACtDZ,2BAA2BW,UAAUC,OAAO;QAChD;IAEA,kHAAkH;IACtH,GAAG;QAACH;QAAKD,MAAMK,CAAC;KAAC;IAEjB,qBACI,KAACf;QACGgB,WAAWlB,KAAKG,QAAQE,MAAM,EAAE;YAAC,CAACF,QAAQgB,iBAAiB,CAAC,EAAE,CAAC,CAACR;QAAM;QACtEE,KAAKE;QACJ,GAAGH,KAAK;;AAGrB,GAAG"}
@@ -0,0 +1,3 @@
1
+ export * from './Modal';
2
+ export * from './ModalFooter';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './Modal';
2
+ export * from './ModalFooter';
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/modal/index.ts"],"sourcesContent":["export * from './Modal';\nexport * from './ModalFooter';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,gBAAgB"}
@@ -1,8 +1,8 @@
1
1
  import { Factory, ModalRootProps, ModalStylesNames, StylesApiProps } from '@mantine/core';
2
2
  import { ReactNode } from 'react';
3
+ import { Modal } from '../modal';
3
4
  import { PromptCancelButton, PromptCancelButtonStylesNamesVariant } from './PromptCancelButton';
4
5
  import { PromptConfirmButton, PromptConfirmButtonStylesNamesVariant } from './PromptConfirmButton';
5
- import { PromptFooter } from './PromptFooter';
6
6
  export type PromptVariant = 'success' | 'warning' | 'critical' | 'info';
7
7
  export type PromptVars = {
8
8
  root: '--prompt-icon-size';
@@ -28,7 +28,7 @@ export type PromptFactory = Factory<{
28
28
  staticComponents: {
29
29
  CancelButton: typeof PromptCancelButton;
30
30
  ConfirmButton: typeof PromptConfirmButton;
31
- Footer: typeof PromptFooter;
31
+ Footer: typeof Modal.Footer;
32
32
  };
33
33
  }>;
34
34
  export declare const Prompt: import("@mantine/core").MantineComponent<{
@@ -40,7 +40,7 @@ export declare const Prompt: import("@mantine/core").MantineComponent<{
40
40
  staticComponents: {
41
41
  CancelButton: typeof PromptCancelButton;
42
42
  ConfirmButton: typeof PromptConfirmButton;
43
- Footer: typeof PromptFooter;
43
+ Footer: typeof Modal.Footer;
44
44
  };
45
45
  }>;
46
46
  //# sourceMappingURL=Prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Prompt.d.ts","sourceRoot":"","sources":["../../../../src/components/prompt/Prompt.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIH,OAAO,EAGP,cAAc,EACd,gBAAgB,EAChB,cAAc,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAyB,SAAS,EAAC,MAAM,OAAO,CAAC;AAOxD,OAAO,EAAC,kBAAkB,EAAE,oCAAoC,EAAC,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAC,mBAAmB,EAAE,qCAAqC,EAAC,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,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ACxC,aAAa,EAAE,OAAO,mBAAmB,CAAC;QAC1C,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC;KAC/B;EAwEH,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Box, createVarsResolver, factory, Image, Modal, useProps, useStyles } from '@mantine/core';
2
+ import { Box, createVarsResolver, factory, Image, useProps, useStyles } from '@mantine/core';
3
3
  import { Children } from 'react';
4
+ import { Modal } from '../modal';
4
5
  import Critical from './icons/critical.svg';
5
6
  import Info from './icons/info.svg';
6
7
  import Success from './icons/success.svg';
@@ -9,7 +10,6 @@ import { PromptContextProvider } from './Prompt.context';
9
10
  import classes from './Prompt.module.css';
10
11
  import { PromptCancelButton } from './PromptCancelButton';
11
12
  import { PromptConfirmButton } from './PromptConfirmButton';
12
- import { PromptFooter } from './PromptFooter';
13
13
  const PROMPT_VARIANT_ICONS_SRC = {
14
14
  success: Success,
15
15
  warning: Warning,
@@ -44,9 +44,11 @@ export const Prompt = factory((_props, ref)=>{
44
44
  classNames,
45
45
  styles
46
46
  };
47
- const convertedChildren = Children.toArray(children);
48
- const otherChildren = convertedChildren.filter((child)=>child.type !== PromptFooter);
49
- const footer = convertedChildren.find((child)=>child.type === PromptFooter);
47
+ const footers = [];
48
+ const otherChildren = [];
49
+ Children.forEach(children, (child)=>{
50
+ (child.type === Modal.Footer ? footers : otherChildren).push(child);
51
+ });
50
52
  return /*#__PURE__*/ _jsx(PromptContextProvider, {
51
53
  value: {
52
54
  variant,
@@ -90,7 +92,7 @@ export const Prompt = factory((_props, ref)=>{
90
92
  children: otherChildren
91
93
  })
92
94
  }),
93
- footer
95
+ footers
94
96
  ]
95
97
  })
96
98
  ]
@@ -99,6 +101,6 @@ export const Prompt = factory((_props, ref)=>{
99
101
  });
100
102
  Prompt.CancelButton = PromptCancelButton;
101
103
  Prompt.ConfirmButton = PromptConfirmButton;
102
- Prompt.Footer = PromptFooter;
104
+ Prompt.Footer = Modal.Footer;
103
105
 
104
106
  //# sourceMappingURL=Prompt.js.map