@vertigis/react-ui 9.13.0 → 10.1.0

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 (114) hide show
  1. package/AdapterDateFns/index.d.ts +3 -0
  2. package/AdapterDateFns/index.js +3 -0
  3. package/AdapterLuxon/index.d.ts +3 -0
  4. package/AdapterLuxon/index.js +3 -0
  5. package/AdapterMoment/index.d.ts +3 -0
  6. package/AdapterMoment/index.js +3 -0
  7. package/Checkbox/Checkbox.d.ts +3 -2
  8. package/ColorInput/ColorInput.d.ts +57 -0
  9. package/ColorInput/ColorInput.js +122 -0
  10. package/ColorInput/index.d.ts +2 -0
  11. package/ColorInput/index.js +2 -0
  12. package/CopyableText/CopyableText.d.ts +35 -0
  13. package/CopyableText/CopyableText.js +80 -0
  14. package/CopyableText/index.d.ts +2 -0
  15. package/CopyableText/index.js +2 -0
  16. package/DataGrid/index.d.ts +1 -0
  17. package/DataGrid/index.js +1 -0
  18. package/DatePicker/index.d.ts +3 -0
  19. package/DatePicker/index.js +3 -0
  20. package/DateRangePicker/index.d.ts +3 -0
  21. package/DateRangePicker/index.js +3 -0
  22. package/DateTimePicker/index.d.ts +3 -0
  23. package/DateTimePicker/index.js +3 -0
  24. package/FormControl/FormControl.d.ts +42 -0
  25. package/FormControl/FormControl.js +30 -0
  26. package/FormControl/index.d.ts +2 -2
  27. package/FormControl/index.js +2 -2
  28. package/FormLabel/FormLabel.d.ts +1 -1
  29. package/FormLabel/FormLabel.js +2 -2
  30. package/FormLabelTextField/FormLabelTextField.d.ts +15 -0
  31. package/FormLabelTextField/FormLabelTextField.js +34 -0
  32. package/FormLabelTextField/index.d.ts +2 -0
  33. package/FormLabelTextField/index.js +2 -0
  34. package/IconButton/IconButton.d.ts +1 -1
  35. package/IconMenu/IconMenu.d.ts +37 -0
  36. package/IconMenu/IconMenu.js +21 -0
  37. package/IconMenu/index.d.ts +2 -0
  38. package/IconMenu/index.js +2 -0
  39. package/InlineFormControl/InlineFormControl.d.ts +38 -0
  40. package/InlineFormControl/InlineFormControl.js +44 -0
  41. package/InlineFormControl/index.d.ts +2 -0
  42. package/InlineFormControl/index.js +2 -0
  43. package/InlineHelp/InlineHelp.d.ts +48 -0
  44. package/InlineHelp/InlineHelp.js +41 -0
  45. package/InlineHelp/index.d.ts +2 -0
  46. package/InlineHelp/index.js +2 -0
  47. package/LicenseInfo/index.d.ts +1 -0
  48. package/LicenseInfo/index.js +1 -0
  49. package/LicenseInfo/index.ts +1 -0
  50. package/Link/Link.d.ts +4 -7
  51. package/Link/Link.js +2 -3
  52. package/Loader/Loader.d.ts +33 -0
  53. package/Loader/Loader.js +75 -0
  54. package/Loader/index.d.ts +2 -0
  55. package/Loader/index.js +2 -0
  56. package/LocalizationProvider/index.d.ts +3 -0
  57. package/LocalizationProvider/index.js +3 -0
  58. package/Markdown/Markdown.d.ts +9 -10
  59. package/Markdown/Markdown.js +2 -1
  60. package/MenuItemSecondaryAction/MenuItemSecondaryAction.d.ts +2 -2
  61. package/MenuItemSecondaryAction/MenuItemSecondaryAction.js +4 -5
  62. package/Radio/Radio.d.ts +3 -2
  63. package/Switch/Switch.d.ts +1 -1
  64. package/Tab/Tab.d.ts +3 -3
  65. package/Tab/Tab.js +1 -1
  66. package/TableCell/TableCell.d.ts +1 -1
  67. package/Tabs/Tabs.d.ts +1 -1
  68. package/Tabs/Tabs.js +1 -1
  69. package/TimePicker/index.d.ts +3 -0
  70. package/TimePicker/index.js +3 -0
  71. package/ToggleButton/ToggleButton.d.ts +1 -1
  72. package/colors/blue.d.ts +1 -1
  73. package/colors/burntOrange.d.ts +1 -1
  74. package/colors/darkBurntOrange.d.ts +1 -1
  75. package/colors/darkRed.d.ts +1 -1
  76. package/colors/green.d.ts +1 -1
  77. package/colors/grey.d.ts +1 -1
  78. package/colors/orange.d.ts +1 -1
  79. package/colors/purple.d.ts +1 -1
  80. package/colors/red.d.ts +1 -1
  81. package/colors/teal.d.ts +1 -1
  82. package/colors/woodlandGreen.d.ts +1 -1
  83. package/icons/BufferIdentify.js +2 -2
  84. package/icons/BufferMeasure.js +2 -2
  85. package/icons/BufferShape.js +2 -2
  86. package/icons/SwapView.d.ts +4 -0
  87. package/icons/SwapView.js +3 -0
  88. package/icons/ViewSwitchList.js +2 -2
  89. package/icons/ViewSwitchTable.js +2 -2
  90. package/icons/index.d.ts +1 -0
  91. package/icons/index.js +1 -0
  92. package/icons/utils/createSvgIcon.d.ts +5 -4
  93. package/icons/utils/createSvgIcon.js +4 -3
  94. package/package.json +14 -5
  95. package/styles/CacheProvider.d.ts +1 -1
  96. package/styles/createTheme.js +27 -3
  97. package/styles/index.js +1 -1
  98. package/styles/themeAugmentation.d.ts +22 -0
  99. package/utils/color.d.ts +11 -0
  100. package/utils/color.js +39 -0
  101. package/utils/generateId.d.ts +1 -0
  102. package/utils/generateId.js +1 -0
  103. package/utils/html.d.ts +16 -0
  104. package/utils/html.js +105 -0
  105. package/utils/intl.d.ts +9 -6
  106. package/utils/intl.js +9 -6
  107. package/utils/markdown.d.ts +11 -3
  108. package/utils/markdown.js +11 -1
  109. package/utils/react.d.ts +15 -0
  110. package/utils/react.js +42 -0
  111. package/utils/url.d.ts +19 -0
  112. package/utils/url.js +74 -0
  113. package/CircularProgress/CircularProgress.d.ts +0 -2
  114. package/CircularProgress/CircularProgress.js +0 -2
package/utils/intl.js CHANGED
@@ -7,9 +7,10 @@
7
7
  // functions.
8
8
  /**
9
9
  * Formats a date for display. The time portion will not appear in the output.
10
+ *
10
11
  * @param date The Date value to format.
11
12
  * @param locale An optional locale to use. If not specified, the browser's
12
- * locale will be used.
13
+ * locale will be used.
13
14
  * @param options Additional options that control how the date is formatted.
14
15
  */
15
16
  export function formatDate(date, options, locale = navigator.language) {
@@ -17,9 +18,10 @@ export function formatDate(date, options, locale = navigator.language) {
17
18
  }
18
19
  /**
19
20
  * Formats a time for display. The date portion will not appear in the output.
21
+ *
20
22
  * @param date The Date value to format.
21
23
  * @param locale An optional locale to use. If not specified, the browser's
22
- * locale will be used.
24
+ * locale will be used.
23
25
  * @param options Additional options that control how the time is formatted.
24
26
  */
25
27
  export function formatTime(date, options, locale = navigator.language) {
@@ -27,20 +29,21 @@ export function formatTime(date, options, locale = navigator.language) {
27
29
  }
28
30
  /**
29
31
  * Formats a date and time for display.
32
+ *
30
33
  * @param date The Date value to format.
31
34
  * @param locale An optional locale to use. If not specified, the browser's
32
- * locale will be used.
33
- * @param options Additional options that control how the date & time are
34
- * formatted.
35
+ * locale will be used.
36
+ * @param options Additional options that control how the date & time are formatted.
35
37
  */
36
38
  export function formatDateTime(date, options, locale = navigator.language) {
37
39
  return date ? date.toLocaleString(locale, options) : "";
38
40
  }
39
41
  /**
40
42
  * Formats a number for display.
43
+ *
41
44
  * @param number The number to format.
42
45
  * @param locale An optional locale to use. If not specified, the browser's
43
- * locale will be used.
46
+ * locale will be used.
44
47
  * @param options Additional options that control how the number is formatted.
45
48
  */
46
49
  export function formatNumber(number, options, locale = navigator.language) {
@@ -5,9 +5,9 @@ export interface MarkdownToHtmlOptions {
5
5
  /**
6
6
  * If specified, produces HTML that is valid to place within an HTML element
7
7
  * that only supports inline content (called "phrasing content" in the HTML5
8
- * spec). Example elements that only support phrasing content are <span> and
9
- * <h2>. In this mode, any block-level elements resulting from the Markdown
10
- * conversion will be stripped. The default is `false`.
8
+ * spec). Example elements that only support phrasing content are <span>
9
+ * and<h2>. In this mode, any block-level elements resulting from the
10
+ * Markdown conversion will be stripped. The default is `false`.
11
11
  */
12
12
  inline?: boolean;
13
13
  /**
@@ -21,6 +21,14 @@ export interface MarkdownToHtmlOptions {
21
21
  */
22
22
  escapeHtml?: boolean;
23
23
  }
24
+ /**
25
+ * Converts markdown text into HTML. The resulting HTML is sanitized and safe to
26
+ * insert into the DOM.
27
+ *
28
+ * @param markdown The markdown text to convert.
29
+ * @param options Options that affect how the text is converted.
30
+ */
31
+ export declare function markdownToSafeHtml(markdown: string, options?: MarkdownToHtmlOptions): string;
24
32
  /**
25
33
  * Converts markdown text into HTML.
26
34
  *
package/utils/markdown.js CHANGED
@@ -1,15 +1,25 @@
1
1
  import escapeHtml from "lodash.escape";
2
2
  import { marked } from "marked";
3
+ import { sanitizeHtml } from "./html.js";
3
4
  /**
4
5
  * A custom marked renderer that escapes HTML in the original markdown.
5
6
  */
6
7
  class EscapeHtmlRenderer extends marked.Renderer {
7
8
  html(html) {
8
- /* eslint-disable @typescript-eslint/no-unsafe-call */
9
9
  return escapeHtml(html);
10
10
  }
11
11
  }
12
12
  EscapeHtmlRenderer.instance = new EscapeHtmlRenderer();
13
+ /**
14
+ * Converts markdown text into HTML. The resulting HTML is sanitized and safe to
15
+ * insert into the DOM.
16
+ *
17
+ * @param markdown The markdown text to convert.
18
+ * @param options Options that affect how the text is converted.
19
+ */
20
+ export function markdownToSafeHtml(markdown, options) {
21
+ return sanitizeHtml(markdownToHtml(markdown, options));
22
+ }
13
23
  /**
14
24
  * Converts markdown text into HTML.
15
25
  *
@@ -0,0 +1,15 @@
1
+ import type { MutableRefObject, Ref, RefCallback } from "react";
2
+ /**
3
+ * Produces a unique ID that can be used for the HTML `id` attribute. Will use
4
+ * the provided value if defined (typically obtained from the calling
5
+ * component's `id` prop), otherwise one will be generated. The ID will remain
6
+ * the same between renders (even if `idProp` changes).
7
+ */
8
+ export declare function useId(idProp?: string): string;
9
+ /**
10
+ * Combines multiple refs into a single ref.
11
+ *
12
+ * Useful when a component needs a ref to one of its own elements, but also
13
+ * supports forwarding a ref from its parent component.
14
+ */
15
+ export declare function mergeRefs<T>(...refs: (RefCallback<T> | MutableRefObject<T | null> | null)[]): Ref<T>;
package/utils/react.js ADDED
@@ -0,0 +1,42 @@
1
+ import { useState } from "react";
2
+ /**
3
+ * Generate a random 10 digit id.
4
+ *
5
+ * @param prefix An optional prefix to prepend to the generated id.
6
+ * @internal
7
+ */
8
+ export function _generateId(prefix) {
9
+ const randomId = Math.random().toString(36).substr(2, 10);
10
+ if (!prefix) {
11
+ return randomId;
12
+ }
13
+ return `${prefix}-${randomId}`;
14
+ }
15
+ /**
16
+ * Produces a unique ID that can be used for the HTML `id` attribute. Will use
17
+ * the provided value if defined (typically obtained from the calling
18
+ * component's `id` prop), otherwise one will be generated. The ID will remain
19
+ * the same between renders (even if `idProp` changes).
20
+ */
21
+ export function useId(idProp) {
22
+ const [id] = useState(() => idProp ?? _generateId());
23
+ return id;
24
+ }
25
+ /**
26
+ * Combines multiple refs into a single ref.
27
+ *
28
+ * Useful when a component needs a ref to one of its own elements, but also
29
+ * supports forwarding a ref from its parent component.
30
+ */
31
+ export function mergeRefs(...refs) {
32
+ return (value) => {
33
+ refs.forEach(ref => {
34
+ if (typeof ref === "function") {
35
+ ref(value);
36
+ }
37
+ else if (ref) {
38
+ ref.current = value;
39
+ }
40
+ });
41
+ };
42
+ }
package/utils/url.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Clears the hash string.
3
+ */
4
+ export declare function clearHashParams(): void;
5
+ /**
6
+ * Returns the decoded hash parameter value for a given key.
7
+ *
8
+ * @param key The key used to return a value.
9
+ */
10
+ export declare function getHashParam(key: string): string | undefined;
11
+ export declare function getQueryStringParam(key: string): string | undefined;
12
+ /**
13
+ * Builds and sets the hash string.
14
+ *
15
+ * @param kvp An object with hash parameters as key/value pairs.
16
+ */
17
+ export declare function setHashParams(kvp: {
18
+ [key: string]: string;
19
+ }): void;
package/utils/url.js ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Clears the hash string.
3
+ */
4
+ export function clearHashParams() {
5
+ history.replaceState(null, document.title, getUrlWithoutHash());
6
+ }
7
+ /**
8
+ * Returns the decoded hash parameter value for a given key.
9
+ *
10
+ * @param key The key used to return a value.
11
+ */
12
+ export function getHashParam(key) {
13
+ return getKeyValuePairs()[key];
14
+ }
15
+ export function getQueryStringParam(key) {
16
+ const params = new URL(window.location.href).searchParams;
17
+ const value = params.get(key);
18
+ // Prefer undefined over null
19
+ return typeof value === "string" ? value : undefined;
20
+ }
21
+ /**
22
+ * Returns the hash string.
23
+ */
24
+ function getHashParamString() {
25
+ return location.hash.substring(1);
26
+ }
27
+ /**
28
+ * Returns an object with hash parameters as key/value pairs.
29
+ */
30
+ function getKeyValuePairs() {
31
+ const kvp = {};
32
+ if (hasHashParams()) {
33
+ const params = getHashParamString().split("&");
34
+ for (const param of params) {
35
+ const keyPair = param.split("=");
36
+ kvp[decodeURIComponent(keyPair[0])] = decodeURIComponent(keyPair[1]);
37
+ }
38
+ }
39
+ return kvp;
40
+ }
41
+ /**
42
+ * Returns the URL without the hash string.
43
+ */
44
+ function getUrlWithoutHash() {
45
+ return `${location.protocol}//${location.host}${location.pathname}${location.search}`;
46
+ }
47
+ /**
48
+ * Whether the window currently has a hash string.
49
+ */
50
+ function hasHashParams() {
51
+ return !!location.hash;
52
+ }
53
+ /**
54
+ * Builds and sets the hash string.
55
+ *
56
+ * @param kvp An object with hash parameters as key/value pairs.
57
+ */
58
+ export function setHashParams(kvp) {
59
+ const hashParamList = [];
60
+ for (const key of Object.keys(kvp)) {
61
+ hashParamList.push(`${encodeURIComponent(key)}=${encodeURIComponent(kvp[key])}`);
62
+ }
63
+ const hashParamString = `#${hashParamList.join("&")}`;
64
+ setHashParamsString(hashParamString);
65
+ }
66
+ /**
67
+ * Sets the hash string.
68
+ *
69
+ * @param paramsString The string to be set as the hash string.
70
+ */
71
+ function setHashParamsString(paramsString) {
72
+ paramsString = paramsString.startsWith("#") ? paramsString : `#${paramsString}`;
73
+ history.replaceState(null, document.title, getUrlWithoutHash() + paramsString);
74
+ }
@@ -1,2 +0,0 @@
1
- export { default } from "@mui/material/CircularProgress";
2
- export * from "@mui/material/CircularProgress";
@@ -1,2 +0,0 @@
1
- export { default } from "@mui/material/CircularProgress";
2
- export * from "@mui/material/CircularProgress";