@hortiview/default-components 1.4.4 → 1.5.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.
- package/README.md +51 -0
- package/dist/components/DefaultAllowedComponent/DefaultAllowedComponent.d.ts +11 -0
- package/dist/components/DefaultAllowedComponent/DefaultAllowedComponent.js +11 -0
- package/dist/components/DefaultFormNumber/DefaultFormNumber.js +12 -1496
- package/dist/components/DefaultFormSelect/DefaultFormSelect.js +9 -178
- package/dist/components/DefaultLoadingSpinner/DefaultLoadingSpinner.js +6 -6
- package/dist/components/GenericTable/GenericTable.js +12 -18731
- package/dist/components/HealthChecks/DataBaseHealthCheck.js +2 -2
- package/dist/components/HealthChecks/DefaultHealthCheck.js +4 -4
- package/dist/components/HealthChecks/IotServiceHealthCheck.js +5 -5
- package/dist/components/HealthChecks/PlatformHealthCheck.js +4 -4
- package/dist/components/ImpatienceLoadingSpinner/ImpatienceLoadingSpinner.js +9 -9
- package/dist/components/InternationalizationWrapper/InternationalizationWrapper.js +4 -4
- package/dist/components/OfflineView/OfflineView.js +9 -9
- package/dist/i18n.js +1696 -5
- package/dist/{i18nInstance-D_96ADqd.js → i18nInstance-CYqpK5II.js} +2 -2
- package/dist/locales/en-US.js +16 -14
- package/dist/locales/en-US.json.d.ts +3 -0
- package/dist/locales/es-MX.js +16 -14
- package/dist/locales/es-MX.json.d.ts +3 -0
- package/dist/locales/tr-TR.js +17 -15
- package/dist/locales/tr-TR.json.d.ts +3 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +24 -22
- package/dist/useTranslation-DGtUf8nl.js +101 -0
- package/package.json +3 -32
- package/dist/Iconify-aUog1Oez.js +0 -83
- package/dist/InfoCard-BxjAQiFE.js +0 -58
- package/dist/LoadingSpinner-DBMjIfY1.js +0 -502
- package/dist/OfflineView-NUM9WE0F-BI9rnget.js +0 -46
- package/dist/assets/DefaultFormNumber.css +0 -1
- package/dist/assets/DefaultFormSelect.css +0 -1
- package/dist/assets/GenericTable.css +0 -1
- package/dist/assets/Iconify.css +0 -1
- package/dist/assets/InfoCard.css +0 -1
- package/dist/assets/LoadingSpinner.css +0 -1
- package/dist/assets/OfflineView-NUM9WE0F.css +0 -1
- package/dist/component-DsB0poTj-DgsYK0_R.js +0 -570
- package/dist/correct-is-regexp-logic-BBlm4UpN-CvII841s.js +0 -493
- package/dist/i18n-CCQpJsQK.js +0 -1707
- package/dist/index.es-B0QNuIUR-Bte5aF5M.js +0 -360
- package/dist/index.es-CIsLNz4j-ZEEcPmTs.js +0 -79
- package/dist/index.es-CvHDFF6V-CjZvA03R.js +0 -2004
- package/dist/index.es-DiONypF4-eT98Y3u_.js +0 -844
- package/dist/index.es-DnEIFMjv-DuuORGfo.js +0 -1044
- package/dist/index.es-NEYPxnlS-C8xQv2De.js +0 -860
- package/dist/index.es-fV9oWpEf-BXuhoGtE.js +0 -14374
- package/dist/isTypedArray-Dw_IY7Zq-wj3MphCb.js +0 -210
- package/dist/slicedToArray-h0Nnkd_P-C4SkVJMK.js +0 -432
- package/dist/useHelperText-B7OMZXvE.js +0 -391
- package/dist/useTranslation-B_lNCuLm.js +0 -5343
package/README.md
CHANGED
|
@@ -68,6 +68,7 @@ This library provides form components using [react-hook-form](https://react-hook
|
|
|
68
68
|
1. [PlatformHealthCheck](#platformhealthcheck)
|
|
69
69
|
1. [ImpatienceLoadingSpinner](#impatienceloadingspinner)
|
|
70
70
|
1. [OfflineView](#offlineview)
|
|
71
|
+
1. [DefaultAllowedComponent](#defaultallowedcomponent)
|
|
71
72
|
|
|
72
73
|
## Available Components
|
|
73
74
|
|
|
@@ -221,3 +222,53 @@ import { OfflineView } from '@hortiview/default-components';
|
|
|
221
222
|
|
|
222
223
|
<OfflineView />;
|
|
223
224
|
```
|
|
225
|
+
|
|
226
|
+
### DefaultAllowedComponent
|
|
227
|
+
|
|
228
|
+
The `DefaultAllowedComponent` is a permission-aware wrapper that displays its children only if the user has the required permissions for a given entity. It uses the default disclaimer text with internationalization support. This component is useful for conditionally rendering content based on user rights in the HortiView platform.
|
|
229
|
+
|
|
230
|
+
**Note:**
|
|
231
|
+
Wrap your usage in `SharedComponentsPermissionProvider` to provide the permission context. The default disclaimer text is automatically internationalized when `useChangeDefaultComponentsLanguage` is used.
|
|
232
|
+
|
|
233
|
+
**Props:**
|
|
234
|
+
|
|
235
|
+
- `neededPermissions`: Array of permissions required to view the content (e.g., `[HVMainPermissions.FarmsRead]`).
|
|
236
|
+
- `entityIds`: The entity ID for which permissions are checked (e.g., `'farm-org-123'`).
|
|
237
|
+
- `disclaimer`: If true, shows a disclaimer when permissions are missing.
|
|
238
|
+
- `children`: The content to render if the user has the required permissions.
|
|
239
|
+
|
|
240
|
+
**Usage Example:**
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
import { DefaultAllowedComponent } from '@hortiview/default-components';
|
|
244
|
+
import {
|
|
245
|
+
InfoCard,
|
|
246
|
+
HVMainPermissions,
|
|
247
|
+
SharedComponentsPermissionProvider,
|
|
248
|
+
ModulePadding,
|
|
249
|
+
} from '@hortiview/shared-components';
|
|
250
|
+
|
|
251
|
+
const userPermissions = {
|
|
252
|
+
'farm-org-123': [HVMainPermissions.FarmsRead, HVMainPermissions.FarmsUpdate],
|
|
253
|
+
};
|
|
254
|
+
const activeOrganizationId = 'farm-org-123';
|
|
255
|
+
|
|
256
|
+
<SharedComponentsPermissionProvider
|
|
257
|
+
userPermissions={userPermissions}
|
|
258
|
+
activeOrganizationId={activeOrganizationId}
|
|
259
|
+
>
|
|
260
|
+
<DefaultAllowedComponent
|
|
261
|
+
neededPermissions={[HVMainPermissions.FarmsRead]}
|
|
262
|
+
entityIds='farm-org-123'
|
|
263
|
+
disclaimer={false}
|
|
264
|
+
>
|
|
265
|
+
<ModulePadding>
|
|
266
|
+
<InfoCard
|
|
267
|
+
title='You can see this content because you have the required FarmsRead permission!'
|
|
268
|
+
subtitle='Permission Granted'
|
|
269
|
+
type='done'
|
|
270
|
+
/>
|
|
271
|
+
</ModulePadding>
|
|
272
|
+
</DefaultAllowedComponent>
|
|
273
|
+
</SharedComponentsPermissionProvider>;
|
|
274
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Allowed } from '@hortiview/shared-components';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
|
|
4
|
+
export type DefaultAllowedComponentProps = Omit<React.ComponentProps<typeof Allowed>, 'disclaimerText'>;
|
|
5
|
+
/**
|
|
6
|
+
* Default allowed component for the HortiView frontend.
|
|
7
|
+
* It provides a default disclaimer text using internationalization.
|
|
8
|
+
* @param param0
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare const DefaultAllowedComponent: ({ ...props }: DefaultAllowedComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Allowed as e } from "@hortiview/shared-components";
|
|
3
|
+
import { InternationalizationWrapper as n } from "../InternationalizationWrapper/InternationalizationWrapper.js";
|
|
4
|
+
import { u as i } from "../../useTranslation-DGtUf8nl.js";
|
|
5
|
+
const s = ({ ...r }) => {
|
|
6
|
+
const { t } = i();
|
|
7
|
+
return /* @__PURE__ */ o(n, { children: /* @__PURE__ */ o(e, { ...r, disclaimerText: t("allowedComponent.disclaimerText") }) });
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
s as DefaultAllowedComponent
|
|
11
|
+
};
|