@hortiview/shared-components 2.11.1 → 2.12.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 (41) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +135 -3
  3. package/dist/components/Allowed/Allowed.d.ts +21 -0
  4. package/dist/components/Allowed/Allowed.js +13 -0
  5. package/dist/components/Allowed/Allowed.test.d.ts +1 -0
  6. package/dist/components/Allowed/Allowed.test.js +49 -0
  7. package/dist/components/AllowedButton/AllowedButton.d.ts +51 -0
  8. package/dist/components/AllowedButton/AllowedButton.js +28 -0
  9. package/dist/components/AllowedButton/AllowedButton.test.d.ts +1 -0
  10. package/dist/components/AllowedButton/AllowedButton.test.js +126 -0
  11. package/dist/components/AllowedIconButton/AllowedIconButton.d.ts +43 -0
  12. package/dist/components/AllowedIconButton/AllowedIconButton.js +23 -0
  13. package/dist/components/AllowedIconButton/AllowedIconButton.test.d.ts +1 -0
  14. package/dist/components/AllowedIconButton/AllowedIconButton.test.js +121 -0
  15. package/dist/components/Filter/Filter.js +7 -4
  16. package/dist/components/FormComponents/FormDatePicker/FormDatePicker.js +2 -10
  17. package/dist/components/FormComponents/FormNumber/CustomTextField.js +1 -1
  18. package/dist/components/GenericTable/GenericTable.js +7 -4
  19. package/dist/components/ModulePadding/ModulePadding.js +7 -4
  20. package/dist/components/PermissionChecks/PermissionService.d.ts +35 -0
  21. package/dist/components/PermissionChecks/PermissionService.js +28 -0
  22. package/dist/components/PermissionChecks/PermissionService.test.d.ts +1 -0
  23. package/dist/components/PermissionChecks/PermissionService.test.js +83 -0
  24. package/dist/components/PermissionChecks/mockedPermissions.d.ts +24 -0
  25. package/dist/components/PermissionChecks/mockedPermissions.js +299 -0
  26. package/dist/components/SharedComponentsPermissionProvider/PermissionContext.d.ts +17 -0
  27. package/dist/components/SharedComponentsPermissionProvider/PermissionContext.js +11 -0
  28. package/dist/components/SharedComponentsPermissionProvider/SharedComponentsPermissionProvider.d.ts +32 -0
  29. package/dist/components/SharedComponentsPermissionProvider/SharedComponentsPermissionProvider.js +17 -0
  30. package/dist/components/Stepper/components/StepperHeader.js +4 -12
  31. package/dist/index-CuHybtft.js +51 -0
  32. package/dist/{isString-BNaBRq3S.js → isString-BifemsUQ.js} +1 -1
  33. package/dist/main.d.ts +8 -0
  34. package/dist/main.js +74 -58
  35. package/dist/{omit-uTAyrUTm.js → omit-Tf2F0V8l.js} +183 -183
  36. package/dist/services/UtilService.js +16 -13
  37. package/dist/test-utils.d.ts +82 -0
  38. package/dist/test-utils.js +32 -0
  39. package/dist/types/Permission.d.ts +153 -0
  40. package/dist/types/Permission.js +4 -0
  41. package/package.json +2 -1
@@ -0,0 +1,17 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { PermissionContext as s } from "./PermissionContext.js";
3
+ const m = ({
4
+ children: r,
5
+ userPermissions: o,
6
+ activeOrganizationId: e
7
+ }) => /* @__PURE__ */ i(
8
+ s.Provider,
9
+ {
10
+ value: { userPermissions: o, activeOrganizationId: e },
11
+ "data-testid": "shared-components-permission-provider",
12
+ children: r
13
+ }
14
+ );
15
+ export {
16
+ m as SharedComponentsPermissionProvider
17
+ };
@@ -2,7 +2,7 @@ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
2
  import { G as s } from "../../../index.es-C1SajYlm.js";
3
3
  import { T as n } from "../../../index.es-NEYPxnlS.js";
4
4
  import { s as t } from "../../../stepper.module-c-CWmpkt.js";
5
- import { StepperIndicator as o } from "./StepperIndicator.js";
5
+ import { StepperIndicator as l } from "./StepperIndicator.js";
6
6
  const y = ({
7
7
  stepperType: d,
8
8
  steps: e,
@@ -34,17 +34,9 @@ const y = ({
34
34
  s,
35
35
  {
36
36
  className: t.stepperDescriptionText,
37
- primaryAlign: "flex-start",
37
+ primaryAlign: "start",
38
38
  secondaryAlign: "center",
39
- children: /* @__PURE__ */ r(
40
- n,
41
- {
42
- "data-testid": "description-stepper-header-description",
43
- themeColor: "secondary-font",
44
- level: 2,
45
- children: e[i].title ?? ""
46
- }
47
- )
39
+ children: /* @__PURE__ */ r(n, { "data-testid": "description-stepper-header-description", level: 2, children: e[i].title ?? "" })
48
40
  }
49
41
  )
50
42
  ]
@@ -60,7 +52,7 @@ const y = ({
60
52
  direction: "vertical",
61
53
  fullWidth: !0,
62
54
  children: [
63
- /* @__PURE__ */ r(o, { steps: e, currentStep: i }),
55
+ /* @__PURE__ */ r(l, { steps: e, currentStep: i }),
64
56
  /* @__PURE__ */ r(
65
57
  n,
66
58
  {
@@ -0,0 +1,51 @@
1
+ class o extends Error {
2
+ }
3
+ o.prototype.name = "InvalidTokenError";
4
+ function i(t) {
5
+ return decodeURIComponent(atob(t).replace(/(.)/g, (e, r) => {
6
+ let n = r.charCodeAt(0).toString(16).toUpperCase();
7
+ return n.length < 2 && (n = "0" + n), "%" + n;
8
+ }));
9
+ }
10
+ function s(t) {
11
+ let e = t.replace(/-/g, "+").replace(/_/g, "/");
12
+ switch (e.length % 4) {
13
+ case 0:
14
+ break;
15
+ case 2:
16
+ e += "==";
17
+ break;
18
+ case 3:
19
+ e += "=";
20
+ break;
21
+ default:
22
+ throw new Error("base64 string is not of the correct length");
23
+ }
24
+ try {
25
+ return i(e);
26
+ } catch {
27
+ return atob(e);
28
+ }
29
+ }
30
+ function d(t, e) {
31
+ if (typeof t != "string")
32
+ throw new o("Invalid token specified: must be a string");
33
+ e || (e = {});
34
+ const r = e.header === !0 ? 0 : 1, n = t.split(".")[r];
35
+ if (typeof n != "string")
36
+ throw new o(`Invalid token specified: missing part #${r + 1}`);
37
+ let c;
38
+ try {
39
+ c = s(n);
40
+ } catch (a) {
41
+ throw new o(`Invalid token specified: invalid base64 for part #${r + 1} (${a.message})`);
42
+ }
43
+ try {
44
+ return JSON.parse(c);
45
+ } catch (a) {
46
+ throw new o(`Invalid token specified: invalid json for part #${r + 1} (${a.message})`);
47
+ }
48
+ }
49
+ export {
50
+ d as j
51
+ };
@@ -1,5 +1,5 @@
1
1
  import { g as s } from "./_commonjsHelpers-BkfeUUK-.js";
2
- import { r as c } from "./omit-uTAyrUTm.js";
2
+ import { r as c } from "./omit-Tf2F0V8l.js";
3
3
  import { a as b, r as u, b as f } from "./isArray-DN9s620O.js";
4
4
  var p = c();
5
5
  const O = /* @__PURE__ */ s(p);
package/dist/main.d.ts CHANGED
@@ -58,3 +58,11 @@ export type { BaseListElement, ListElement } from './types/ListElement';
58
58
  export { DATE_FORMAT, DATE_TIME_FORMAT, TIME_FORMAT } from './types/Time';
59
59
  export { AVAILABLE_COUNTRY_KEYS, AVAILABLE_LOCALES, ENGLISH_LANGUAGE_ID, GERMAN_LANGUAGE_ID, LANGUAGE_CODES_MAPPER, LANGUAGE_ID_MAPPER, SPANISH_LANGUAGE_ID, TURKISH_LANGUAGE_ID, } from './types/Languages';
60
60
  export type { AVAILABLE_LANGUAGE_CODES, LANGUAGE_COUNTRY_CODES } from './types/Languages';
61
+ export { Allowed } from './components/Allowed/Allowed';
62
+ export { AllowedButton } from './components/AllowedButton/AllowedButton';
63
+ export { AllowedIconButton } from './components/AllowedIconButton/AllowedIconButton';
64
+ export { getPermissionsFromModulePermissionToken, useIsAllowed, } from './components/PermissionChecks/PermissionService';
65
+ export { SharedComponentsPermissionProvider } from './components/SharedComponentsPermissionProvider/SharedComponentsPermissionProvider';
66
+ export { createPermissionWrapper, renderWithPermissions } from './test-utils';
67
+ export { HVMainPermissions } from './types/Permission';
68
+ export type { HVPermissions, ModulePermissionTokenParsed, PermissionsByEntity, } from './types/Permission';
package/dist/main.js CHANGED
@@ -1,26 +1,26 @@
1
1
  import { A as e } from "./AlertBanner-C6wpAQMj.js";
2
2
  import { LinkBanner as m } from "./components/AlertBanner/LinkBanner.js";
3
3
  import { BaseView as f } from "./components/BaseView/BaseView.js";
4
- import { BasicHeading as a } from "./components/BasicHeading/BasicHeading.js";
5
- import { BlockView as A } from "./components/BlockView/BlockView.js";
6
- import { ChipCard as n } from "./components/ChipCard/ChipCard.js";
7
- import { ContextMenu as E } from "./components/ContextMenu/ContextMenu.js";
8
- import { DeleteModal as L } from "./components/DeleteModal/DeleteModal.js";
9
- import { DetailContentWrapper as c } from "./components/DetailContentWrapper/DetailContentWrapper.js";
10
- import { Disclaimer as F } from "./components/Disclaimer/Disclaimer.js";
4
+ import { BasicHeading as i } from "./components/BasicHeading/BasicHeading.js";
5
+ import { BlockView as n } from "./components/BlockView/BlockView.js";
6
+ import { ChipCard as A } from "./components/ChipCard/ChipCard.js";
7
+ import { ContextMenu as d } from "./components/ContextMenu/ContextMenu.js";
8
+ import { DeleteModal as c } from "./components/DeleteModal/DeleteModal.js";
9
+ import { DetailContentWrapper as I } from "./components/DetailContentWrapper/DetailContentWrapper.js";
10
+ import { Disclaimer as _ } from "./components/Disclaimer/Disclaimer.js";
11
11
  import { EmptyView as T } from "./components/EmptyView/EmptyView.js";
12
12
  import { Filter as D } from "./components/Filter/Filter.js";
13
- import { FormattedNumberDisplay as M } from "./components/FormattedNumberDisplay/FormattedNumberDisplay.js";
13
+ import { FormattedNumberDisplay as P } from "./components/FormattedNumberDisplay/FormattedNumberDisplay.js";
14
14
  import { GenericTable as B } from "./components/GenericTable/GenericTable.js";
15
- import { HashTabView as O } from "./components/HashTabView/HashTabView.js";
16
- import { HeaderFilter as u } from "./components/HeaderFilter/HeaderFilter.js";
17
- import { Iconify as U } from "./components/Iconify/Iconify.js";
18
- import { InfoCard as H } from "./components/InfoCard/InfoCard.js";
19
- import { InfoGroup as w } from "./components/InfoGroup/InfoGroup.js";
15
+ import { HashTabView as g } from "./components/HashTabView/HashTabView.js";
16
+ import { HeaderFilter as w } from "./components/HeaderFilter/HeaderFilter.js";
17
+ import { Iconify as b } from "./components/Iconify/Iconify.js";
18
+ import { InfoCard as V } from "./components/InfoCard/InfoCard.js";
19
+ import { InfoGroup as U } from "./components/InfoGroup/InfoGroup.js";
20
20
  import { ListArea as k } from "./components/ListArea/ListArea.js";
21
21
  import { LoadingSpinner as y } from "./components/LoadingSpinner/Default/LoadingSpinner.js";
22
- import { Modal as K } from "./components/Modal/Modal.js";
23
- import { ModulePadding as W } from "./components/ModulePadding/ModulePadding.js";
22
+ import { Modal as Y } from "./components/Modal/Modal.js";
23
+ import { ModulePadding as z } from "./components/ModulePadding/ModulePadding.js";
24
24
  import { O as j } from "./OfflineView-NUM9WE0F.js";
25
25
  import { OnboardingBanner as J } from "./components/OnboardingBanner/OnboardingBanner.js";
26
26
  import { OverflowTooltip as Z } from "./components/OverflowTooltip/OverflowTooltip.js";
@@ -28,84 +28,100 @@ import { ScrollbarX as rr, ScrollbarY as or } from "./components/Scrollbar/Scrol
28
28
  import { SearchBar as tr } from "./components/SearchBar/SearchBar.js";
29
29
  import { Select as pr } from "./components/Select/Select.js";
30
30
  import { StepperHeader as xr } from "./components/Stepper/components/StepperHeader.js";
31
- import { StepperIndicator as ir } from "./components/Stepper/components/StepperIndicator.js";
31
+ import { StepperIndicator as ar } from "./components/Stepper/components/StepperIndicator.js";
32
32
  import { Stepper as lr } from "./components/Stepper/Stepper.js";
33
- import { VerticalDivider as dr } from "./components/VerticalDivider/VerticalDivider.js";
33
+ import { VerticalDivider as sr } from "./components/VerticalDivider/VerticalDivider.js";
34
34
  import { FormCheckBox as Sr } from "./components/FormComponents/FormCheckBox/FormCheckBox.js";
35
- import { FormDatePicker as _r } from "./components/FormComponents/FormDatePicker/FormDatePicker.js";
36
- import { FormNumber as sr } from "./components/FormComponents/FormNumber/FormNumber.js";
37
- import { FormRadio as Ir } from "./components/FormComponents/FormRadio/FormRadio.js";
35
+ import { FormDatePicker as Er } from "./components/FormComponents/FormDatePicker/FormDatePicker.js";
36
+ import { FormNumber as Lr } from "./components/FormComponents/FormNumber/FormNumber.js";
37
+ import { FormRadio as Fr } from "./components/FormComponents/FormRadio/FormRadio.js";
38
38
  import { FormSelect as Gr } from "./components/FormComponents/FormSelect/FormSelect.js";
39
- import { FormSlider as Nr } from "./components/FormComponents/FormSlider/FormSlider.js";
40
- import { FormText as gr } from "./components/FormComponents/FormText/FormText.js";
41
- import { FormToggle as Cr } from "./components/FormComponents/FormToggle/FormToggle.js";
42
- import { SafeForm as br } from "./components/SafeForm/SafeForm.js";
43
- import { AvailableCustomIcons as Rr } from "./enums/AvailableCustomIcons.js";
44
- import { ThemeColor as Vr } from "./enums/ThemeColor.js";
45
- import { u as Pr } from "./useBreakpoints-MzTZ0tCT.js";
39
+ import { FormSlider as Mr } from "./components/FormComponents/FormSlider/FormSlider.js";
40
+ import { FormText as ur } from "./components/FormComponents/FormText/FormText.js";
41
+ import { FormToggle as Nr } from "./components/FormComponents/FormToggle/FormToggle.js";
42
+ import { SafeForm as Cr } from "./components/SafeForm/SafeForm.js";
43
+ import { AvailableCustomIcons as Or } from "./enums/AvailableCustomIcons.js";
44
+ import { ThemeColor as Rr } from "./enums/ThemeColor.js";
45
+ import { u as Hr } from "./useBreakpoints-MzTZ0tCT.js";
46
46
  import { capitalizeFirstLetters as hr, getFormattedDateTime as kr, getNumberAsLocaleString as vr, trimLeadingAndTrailingSpaces as yr } from "./services/UtilService.js";
47
- import { DATE_FORMAT as Kr, DATE_TIME_FORMAT as zr, TIME_FORMAT as Wr } from "./types/Time.js";
47
+ import { DATE_FORMAT as Yr, DATE_TIME_FORMAT as Kr, TIME_FORMAT as zr } from "./types/Time.js";
48
48
  import { AVAILABLE_COUNTRY_KEYS as jr, AVAILABLE_LOCALES as qr, ENGLISH_LANGUAGE_ID as Jr, GERMAN_LANGUAGE_ID as Qr, LANGUAGE_CODES_MAPPER as Zr, LANGUAGE_ID_MAPPER as $r, SPANISH_LANGUAGE_ID as ro, TURKISH_LANGUAGE_ID as oo } from "./types/Languages.js";
49
+ import { Allowed as to } from "./components/Allowed/Allowed.js";
50
+ import { AllowedButton as po } from "./components/AllowedButton/AllowedButton.js";
51
+ import { AllowedIconButton as xo } from "./components/AllowedIconButton/AllowedIconButton.js";
52
+ import { getPermissionsFromModulePermissionToken as ao, useIsAllowed as no } from "./components/PermissionChecks/PermissionService.js";
53
+ import { SharedComponentsPermissionProvider as Ao } from "./components/SharedComponentsPermissionProvider/SharedComponentsPermissionProvider.js";
54
+ import { createPermissionWrapper as So, renderWithPermissions as co } from "./test-utils.js";
55
+ import { HVMainPermissions as Io } from "./types/Permission.js";
49
56
  export {
50
57
  jr as AVAILABLE_COUNTRY_KEYS,
51
58
  qr as AVAILABLE_LOCALES,
52
59
  e as AlertBanner,
53
- Rr as AvailableCustomIcons,
60
+ to as Allowed,
61
+ po as AllowedButton,
62
+ xo as AllowedIconButton,
63
+ Or as AvailableCustomIcons,
54
64
  f as BaseView,
55
- a as BasicHeading,
56
- A as BlockView,
57
- n as ChipCard,
58
- E as ContextMenu,
59
- Kr as DATE_FORMAT,
60
- zr as DATE_TIME_FORMAT,
61
- L as DeleteModal,
62
- c as DetailContentWrapper,
63
- F as Disclaimer,
65
+ i as BasicHeading,
66
+ n as BlockView,
67
+ A as ChipCard,
68
+ d as ContextMenu,
69
+ Yr as DATE_FORMAT,
70
+ Kr as DATE_TIME_FORMAT,
71
+ c as DeleteModal,
72
+ I as DetailContentWrapper,
73
+ _ as Disclaimer,
64
74
  Jr as ENGLISH_LANGUAGE_ID,
65
75
  T as EmptyView,
66
76
  D as Filter,
67
77
  Sr as FormCheckBox,
68
- _r as FormDatePicker,
69
- sr as FormNumber,
70
- Ir as FormRadio,
78
+ Er as FormDatePicker,
79
+ Lr as FormNumber,
80
+ Fr as FormRadio,
71
81
  Gr as FormSelect,
72
- Nr as FormSlider,
73
- gr as FormText,
74
- Cr as FormToggle,
75
- M as FormattedNumberDisplay,
82
+ Mr as FormSlider,
83
+ ur as FormText,
84
+ Nr as FormToggle,
85
+ P as FormattedNumberDisplay,
76
86
  Qr as GERMAN_LANGUAGE_ID,
77
87
  B as GenericTable,
78
- O as HashTabView,
79
- u as HeaderFilter,
80
- U as Iconify,
81
- H as InfoCard,
82
- w as InfoGroup,
88
+ Io as HVMainPermissions,
89
+ g as HashTabView,
90
+ w as HeaderFilter,
91
+ b as Iconify,
92
+ V as InfoCard,
93
+ U as InfoGroup,
83
94
  Zr as LANGUAGE_CODES_MAPPER,
84
95
  $r as LANGUAGE_ID_MAPPER,
85
96
  m as LinkBanner,
86
97
  k as ListArea,
87
98
  y as LoadingSpinner,
88
- K as Modal,
89
- W as ModulePadding,
99
+ Y as Modal,
100
+ z as ModulePadding,
90
101
  j as OfflineView,
91
102
  J as OnboardingBanner,
92
103
  Z as OverflowTooltip,
93
104
  ro as SPANISH_LANGUAGE_ID,
94
- br as SafeForm,
105
+ Cr as SafeForm,
95
106
  rr as ScrollbarX,
96
107
  or as ScrollbarY,
97
108
  tr as SearchBar,
98
109
  pr as Select,
110
+ Ao as SharedComponentsPermissionProvider,
99
111
  lr as Stepper,
100
112
  xr as StepperHeader,
101
- ir as StepperIndicator,
102
- Wr as TIME_FORMAT,
113
+ ar as StepperIndicator,
114
+ zr as TIME_FORMAT,
103
115
  oo as TURKISH_LANGUAGE_ID,
104
- Vr as ThemeColor,
105
- dr as VerticalDivider,
116
+ Rr as ThemeColor,
117
+ sr as VerticalDivider,
106
118
  hr as capitalizeFirstLetters,
119
+ So as createPermissionWrapper,
107
120
  kr as getFormattedDateTime,
108
121
  vr as getNumberAsLocaleString,
122
+ ao as getPermissionsFromModulePermissionToken,
123
+ co as renderWithPermissions,
109
124
  yr as trimLeadingAndTrailingSpaces,
110
- Pr as useBreakpoints
125
+ Hr as useBreakpoints,
126
+ no as useIsAllowed
111
127
  };