@knaw-huc/panoptes-react-blocks 0.0.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 (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +666 -0
  3. package/dist/components/blocks/external-link/index.d.ts +8 -0
  4. package/dist/components/blocks/json/JsonBlockRenderer.d.ts +5 -0
  5. package/dist/components/blocks/json/index.d.ts +18 -0
  6. package/dist/components/blocks/json/schemaSelectors.d.ts +7 -0
  7. package/dist/components/blocks/label/index.d.ts +8 -0
  8. package/dist/components/blocks/link/index.d.ts +13 -0
  9. package/dist/components/blocks/map/index.d.ts +17 -0
  10. package/dist/components/blocks/markdown/index.d.ts +8 -0
  11. package/dist/components/blocks/screen/FormColumn.d.ts +7 -0
  12. package/dist/components/blocks/screen/FormElement.d.ts +7 -0
  13. package/dist/components/blocks/screen/FormRow.d.ts +7 -0
  14. package/dist/components/blocks/screen/ScreenActions.d.ts +1 -0
  15. package/dist/components/blocks/screen/ScreenForm.d.ts +1 -0
  16. package/dist/components/blocks/screen/ScreenLinks.d.ts +1 -0
  17. package/dist/components/blocks/screen/ScreenRenderer.d.ts +1 -0
  18. package/dist/components/blocks/screen/ScreenSidebar.d.ts +6 -0
  19. package/dist/components/blocks/screen/ScreenTabs.d.ts +1 -0
  20. package/dist/components/blocks/screen/context/ItemDataContext.d.ts +7 -0
  21. package/dist/components/blocks/screen/context/ScreenContext.d.ts +16 -0
  22. package/dist/components/blocks/screen/hooks/index.d.ts +3 -0
  23. package/dist/components/blocks/screen/hooks/useElementState.d.ts +8 -0
  24. package/dist/components/blocks/screen/hooks/useItemData.d.ts +1 -0
  25. package/dist/components/blocks/screen/hooks/useScreenContext.d.ts +2 -0
  26. package/dist/components/blocks/screen/hooks/useScreenState.d.ts +3 -0
  27. package/dist/components/blocks/screen/index.d.ts +6 -0
  28. package/dist/components/blocks/screen/schema/binding.d.ts +8 -0
  29. package/dist/components/blocks/screen/schema/index.d.ts +3 -0
  30. package/dist/components/blocks/screen/schema/types.d.ts +100 -0
  31. package/dist/components/blocks/toggle/index.d.ts +8 -0
  32. package/dist/components/ghostline/Ghostline.d.ts +1 -0
  33. package/dist/index.cjs +37 -0
  34. package/dist/index.d.ts +20 -0
  35. package/dist/index.js +37518 -0
  36. package/dist/panoptes-react-blocks.css +1 -0
  37. package/package.json +57 -0
@@ -0,0 +1,18 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ export type JsonPrimitive = string | number | boolean | null;
3
+ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
4
+ export type JsonObject = {
5
+ [key: string]: JsonValue;
6
+ };
7
+ export type JsonArray = JsonValue[];
8
+ export type JsonData = JsonValue;
9
+ export type JsonSchema = JsonObject;
10
+ export interface JsonBlock extends Block {
11
+ type: "json";
12
+ value: JsonData;
13
+ config: JsonSchema;
14
+ }
15
+ declare const RenderJsonBlock: ({ block }: {
16
+ block: Block;
17
+ }) => import("react/jsx-runtime").JSX.Element;
18
+ export default RenderJsonBlock;
@@ -0,0 +1,7 @@
1
+ import { JsonSchema } from './index.tsx';
2
+ export declare function deepGet(obj: any, path: string, defaultValue?: any): any;
3
+ export declare const omitProperty: (schema: JsonSchema, propertyName: string) => boolean;
4
+ export declare const isLink: (schema: JsonSchema, propertyName: string) => boolean;
5
+ export declare const isExternalLink: (schema: JsonSchema, propertyName: string) => boolean;
6
+ export declare const isMarkdownHTML: (schema: JsonSchema, propertyName: string) => boolean;
7
+ export declare const getLinkTo: (schema: JsonSchema, propertyName: string) => string;
@@ -0,0 +1,8 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ export interface LabelBlock extends Block {
3
+ type: 'label';
4
+ value: string;
5
+ }
6
+ export default function LabelBlockRenderer({ block }: {
7
+ block: Block;
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ export interface LinkBlockConfig {
3
+ url: string;
4
+ }
5
+ export interface LinkBlock extends Block {
6
+ type: 'link';
7
+ value: string;
8
+ config?: LinkBlockConfig;
9
+ model?: Record<string, unknown>;
10
+ }
11
+ export default function LinkBlockRenderer({ block }: {
12
+ block: Block;
13
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ export interface MapBlockConfig {
3
+ zoom?: number;
4
+ tileUrl?: string;
5
+ }
6
+ export type MapBlockValue = {
7
+ latitude: number;
8
+ longitude: number;
9
+ };
10
+ export interface MapBlock extends Block {
11
+ type: "map";
12
+ value: MapBlockValue;
13
+ config?: MapBlockConfig;
14
+ }
15
+ export default function MapBlockRenderer({ block }: {
16
+ block: Block;
17
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ export interface MarkDownBlock extends Block {
3
+ type: 'markdown';
4
+ value: string;
5
+ }
6
+ export default function MarkdownBlockRenderer({ block }: {
7
+ block: Block;
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { ColumnDefinition } from './schema';
2
+ interface FormColumnProps {
3
+ column: ColumnDefinition;
4
+ groupId?: string;
5
+ }
6
+ export default function FormColumn({ column, groupId }: FormColumnProps): import("react/jsx-runtime").JSX.Element | null;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ElementDefinition } from './schema';
2
+ interface FormElementProps {
3
+ element: ElementDefinition;
4
+ groupId?: string;
5
+ }
6
+ export default function FormElement({ element, groupId }: FormElementProps): import("react/jsx-runtime").JSX.Element | null;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { RowDefinition } from './schema';
2
+ interface FormRowProps {
3
+ row: RowDefinition;
4
+ inheritedGroupId?: string;
5
+ }
6
+ export default function FormRow({ row, inheritedGroupId }: FormRowProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1 @@
1
+ export default function ScreenActions(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export default function ScreenForm(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export default function ScreenLinks(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export default function ScreenRenderer(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { SidebarDefinition } from './schema';
2
+ interface ScreenSidebarProps {
3
+ sidebar: SidebarDefinition;
4
+ }
5
+ export default function ScreenSidebar({ sidebar }: ScreenSidebarProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1 @@
1
+ export default function ScreenTabs(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ declare const ItemDataContext: import('react').Context<Record<string, unknown> | null>;
3
+ export declare function ItemDataProvider({ item, children }: {
4
+ item: Record<string, unknown>;
5
+ children: ReactNode;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ export default ItemDataContext;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ import { ScreenDefinition } from '../schema';
3
+ export interface ScreenContextValue {
4
+ screenDefinition: ScreenDefinition;
5
+ data: Record<string, unknown>;
6
+ activeTabId: string;
7
+ setActiveTabId: (tabId: string) => void;
8
+ }
9
+ declare const ScreenContext: import('react').Context<ScreenContextValue | null>;
10
+ export interface ScreenProviderProps {
11
+ screenDefinition: ScreenDefinition;
12
+ data: Record<string, unknown>;
13
+ children: ReactNode;
14
+ }
15
+ export declare function ScreenProvider({ screenDefinition, data, children }: ScreenProviderProps): import("react/jsx-runtime").JSX.Element;
16
+ export default ScreenContext;
@@ -0,0 +1,3 @@
1
+ export { default as useElementState } from './useElementState';
2
+ export { default as useScreenContext } from './useScreenContext';
3
+ export { default as useScreenState } from './useScreenState';
@@ -0,0 +1,8 @@
1
+ import { ElementDefinition } from '../schema';
2
+ export default function useElementState(element: ElementDefinition, groupId?: string): {
3
+ value: unknown;
4
+ hidden: boolean;
5
+ label: string | undefined;
6
+ infoLabel: string | undefined;
7
+ config: Record<string, unknown> | undefined;
8
+ };
@@ -0,0 +1 @@
1
+ export declare function useItemData(): Record<string, unknown> | null;
@@ -0,0 +1,2 @@
1
+ import { ScreenContextValue } from '../context/ScreenContext.tsx';
2
+ export default function useScreenContext(): ScreenContextValue;
@@ -0,0 +1,3 @@
1
+ export default function useScreenState(): {
2
+ getValue: (expression: string) => unknown;
3
+ };
@@ -0,0 +1,6 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ interface RenderScreenBlockProps {
3
+ block: Block;
4
+ }
5
+ declare const RenderScreenBlock: ({ block }: RenderScreenBlockProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default RenderScreenBlock;
@@ -0,0 +1,8 @@
1
+ export interface ParsedBinding {
2
+ source: 'data' | 'itemData';
3
+ path: string[];
4
+ rawPath: string;
5
+ }
6
+ export declare function isBindingExpression(value: string): boolean;
7
+ export declare function parseBinding(expression: string): ParsedBinding;
8
+ export declare function getNestedValue(obj: unknown, path: string[]): unknown;
@@ -0,0 +1,3 @@
1
+ export type { ScreenDefinition, ScreenType, TabDefinition, OperationListItem, OperationDefinition, LinkDefinition, ActionDefinition, ActivationType, ConfirmationDefinition, ConfirmationLabels, FormDefinition, RowDefinition, DisplayType, ColumnDefinition, ElementDefinition, SidebarDefinition, SidebarSectionDefinition, SidebarNavItemDefinition, ScreenBlock, ScreenBlockValue, } from './types';
2
+ export { isBindingExpression, parseBinding, getNestedValue, } from './binding';
3
+ export type { ParsedBinding } from './binding';
@@ -0,0 +1,100 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ export interface ScreenDefinition {
3
+ id: string;
4
+ label?: string;
5
+ activeTabId?: string;
6
+ screenType: ScreenType;
7
+ tabs?: TabDefinition[];
8
+ links?: LinkDefinition[];
9
+ actions: ActionDefinition[];
10
+ form: FormDefinition;
11
+ sidebar?: SidebarDefinition;
12
+ }
13
+ export interface SidebarDefinition {
14
+ id: string;
15
+ width?: string;
16
+ sections: SidebarSectionDefinition[];
17
+ }
18
+ export interface SidebarSectionDefinition {
19
+ id: string;
20
+ items: SidebarNavItemDefinition[];
21
+ }
22
+ export interface SidebarNavItemDefinition {
23
+ id: string;
24
+ icon: string;
25
+ label?: string;
26
+ operation: OperationDefinition;
27
+ active?: boolean;
28
+ }
29
+ export type ScreenType = 'normal';
30
+ export interface TabDefinition {
31
+ id: string;
32
+ label?: string;
33
+ operation?: OperationDefinition;
34
+ operationList?: OperationListItem[];
35
+ }
36
+ export interface OperationListItem {
37
+ id: string;
38
+ label?: string;
39
+ operation: OperationDefinition;
40
+ }
41
+ export interface OperationDefinition {
42
+ operationId: string;
43
+ parameters: Record<string, string | number | boolean>;
44
+ }
45
+ export interface LinkDefinition {
46
+ id: string;
47
+ label: string;
48
+ operation?: OperationDefinition;
49
+ href?: string;
50
+ }
51
+ export interface ActionDefinition {
52
+ id: string;
53
+ label?: string;
54
+ activate: ActivationType;
55
+ confirmation: ConfirmationDefinition;
56
+ operation: OperationDefinition;
57
+ }
58
+ export type ActivationType = 'always' | 'onDirty' | 'onValid' | 'onDirtyAndValid';
59
+ export interface ConfirmationDefinition {
60
+ askConfirmation: 'always' | 'never' | 'onDirty';
61
+ labels?: ConfirmationLabels;
62
+ }
63
+ export interface ConfirmationLabels {
64
+ title?: string;
65
+ message?: string;
66
+ ok?: string;
67
+ cancel?: string;
68
+ }
69
+ export interface FormDefinition {
70
+ rows: RowDefinition[];
71
+ }
72
+ export interface RowDefinition {
73
+ displayType?: DisplayType;
74
+ label?: string;
75
+ groupId?: string;
76
+ collapsible?: boolean;
77
+ defaultCollapsed?: boolean;
78
+ elements?: ElementDefinition[];
79
+ columns?: ColumnDefinition[];
80
+ rows?: RowDefinition[];
81
+ }
82
+ export type DisplayType = 'header' | 'group' | 'footer' | 'row';
83
+ export interface ColumnDefinition {
84
+ elements: ElementDefinition[];
85
+ }
86
+ export interface ElementDefinition {
87
+ value: string | string[] | Record<string, string>;
88
+ hidden?: boolean;
89
+ addIndeterminate?: boolean;
90
+ label?: string;
91
+ infoLabel?: string;
92
+ type?: string;
93
+ config?: Record<string, unknown>;
94
+ }
95
+ export type ScreenBlockValue = Record<string, unknown>;
96
+ export interface ScreenBlock extends Block {
97
+ type: 'screen';
98
+ value: ScreenBlockValue;
99
+ config: ScreenDefinition;
100
+ }
@@ -0,0 +1,8 @@
1
+ import { Block } from '@knaw-huc/panoptes-react';
2
+ export interface ToggleBlock extends Block {
3
+ type: 'toggle';
4
+ value: boolean;
5
+ }
6
+ export default function ToggleBlockRenderer({ block }: {
7
+ block: Block;
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function GhostLine(): import("react/jsx-runtime").JSX.Element;