@ostack.tech/ui 0.4.0 → 0.5.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.
- package/dist/locales/pt.js +1 -1
- package/dist/locales/pt.js.map +1 -1
- package/dist/ostack-ui.css +40 -10
- package/dist/ostack-ui.css.map +1 -1
- package/dist/ostack-ui.js +418 -49
- package/dist/ostack-ui.js.map +1 -1
- package/dist/types/components/DataTable/DataTable.d.ts +6 -0
- package/dist/types/components/DataTable/DataTableContext.d.ts +3 -1
- package/dist/types/components/Portal/Portal.d.ts +1 -1
- package/dist/types/components/Printer/Printer.d.ts +147 -0
- package/dist/types/components/Printer/PrinterContent.d.ts +22 -0
- package/dist/types/components/Printer/PrinterContentContext.d.ts +38 -0
- package/dist/types/components/Printer/PrinterContext.d.ts +30 -0
- package/dist/types/components/Printer/PrinterTrigger.d.ts +20 -0
- package/dist/types/components/Printer/index.d.ts +6 -0
- package/dist/types/components/Printer/usePrintClassNames.d.ts +5 -0
- package/dist/types/components/Select/SelectContext.d.ts +2 -4
- package/dist/types/components/Tabs/TabContent.d.ts +6 -1
- package/dist/types/components/Tabs/Tabs.d.ts +2 -0
- package/dist/types/components/Tabs/TabsContext.d.ts +15 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/providers/AlertDialogProvider/useAlertDialog.d.ts +2 -2
- package/dist/types/providers/ToastManagerProvider/useToastManager.d.ts +1 -1
- package/dist/types/utils/cx.d.ts +1 -1
- package/dist/types/utils/keyboardShortcut.d.ts +7 -1
- package/dist/types/utils/useCssVars.d.ts +3 -3
- package/package.json +3 -2
- package/scss/components/Card/_Card.scss +5 -6
- package/scss/components/Field/_Field.scss +1 -0
- package/scss/components/Spinner/_Spinner-variables.scss +3 -1
- package/scss/components/Spinner/_Spinner.scss +10 -1
- package/scss/components/Table/_Table.scss +6 -0
- package/scss/components/Tabs/_Tabs-variables.scss +16 -0
- package/scss/components/Tabs/_Tabs.scss +22 -5
- package/scss/index.scss +1 -0
- package/scss/scss/helpers/_print-utils.scss +13 -0
- package/scss/scss/utils/_spinner.scss +11 -5
|
@@ -228,6 +228,12 @@ export interface DataTableProps<T = any> extends ComponentPropsWithoutRef<"div">
|
|
|
228
228
|
* @default 5
|
|
229
229
|
*/
|
|
230
230
|
overscan?: number;
|
|
231
|
+
/**
|
|
232
|
+
* Whether to show all rows of the data table while it is being printed.
|
|
233
|
+
*
|
|
234
|
+
* @default false
|
|
235
|
+
*/
|
|
236
|
+
showAllRowsWhilePrinting?: boolean;
|
|
231
237
|
/** Reference to interact with the data table's API. */
|
|
232
238
|
apiRef?: Ref<DataTableApi<T> | undefined>;
|
|
233
239
|
}
|
|
@@ -17,6 +17,7 @@ export interface DataTableContextValue<T = any> {
|
|
|
17
17
|
estimatedRowHeight: number | ((index: number) => number);
|
|
18
18
|
overscan: number;
|
|
19
19
|
generatedId: string;
|
|
20
|
+
showAllRowsWhilePrinting?: boolean;
|
|
20
21
|
apiRef?: Ref<DataTableApi<T> | undefined>;
|
|
21
22
|
store: DataTableStore<T>;
|
|
22
23
|
}
|
|
@@ -106,7 +107,7 @@ export interface UseCreateDataTableContextOptions<T> extends Omit<DataTableConte
|
|
|
106
107
|
disabledSelections?: Key[];
|
|
107
108
|
}
|
|
108
109
|
/** Hook which creates the data table context value. */
|
|
109
|
-
export declare function useCreateDataTableContext<T>({ displayMode, columns, rows, getRows, rowKey, loadingCount, required, loading, renderRow, renderCell, dynamicRowHeight, estimatedRowHeight, overscan, apiRef, leafColumns, headCount, defaultOffset, offset, onOffsetChange, defaultLimit, limit, onLimitChange, defaultFilter, filter, onFilterChange, defaultSortBy, sortBy, defaultSortDirection, sortDirection, onSort, showSelectionColumn, defaultSelectedRows, selectedRows, onSelectedRowsChange, disabledSelections, }: UseCreateDataTableContextOptions<T>): {
|
|
110
|
+
export declare function useCreateDataTableContext<T>({ displayMode, columns, rows, getRows, rowKey, loadingCount, required, loading, renderRow, renderCell, dynamicRowHeight, estimatedRowHeight, overscan, showAllRowsWhilePrinting, apiRef, leafColumns, headCount, defaultOffset, offset, onOffsetChange, defaultLimit, limit, onLimitChange, defaultFilter, filter, onFilterChange, defaultSortBy, sortBy, defaultSortDirection, sortDirection, onSort, showSelectionColumn, defaultSelectedRows, selectedRows, onSelectedRowsChange, disabledSelections, }: UseCreateDataTableContextOptions<T>): {
|
|
110
111
|
displayMode: DataTableDisplayMode;
|
|
111
112
|
rowKey: string | number | symbol | ((row: any) => Key);
|
|
112
113
|
required: boolean | undefined;
|
|
@@ -117,6 +118,7 @@ export declare function useCreateDataTableContext<T>({ displayMode, columns, row
|
|
|
117
118
|
estimatedRowHeight: number | ((index: number) => number);
|
|
118
119
|
overscan: number;
|
|
119
120
|
generatedId: string;
|
|
121
|
+
showAllRowsWhilePrinting: boolean | undefined;
|
|
120
122
|
apiRef: Ref<DataTableApi<any> | undefined> | undefined;
|
|
121
123
|
store: Omit<import('zustand').StoreApi<DataTableState<T>>, "subscribe"> & {
|
|
122
124
|
subscribe: {
|
|
@@ -7,7 +7,7 @@ export interface PortalProps extends ComponentPropsWithoutRef<typeof PortalPrimi
|
|
|
7
7
|
* Portal component used to render a React subtree in a different part of the
|
|
8
8
|
* DOM.
|
|
9
9
|
*
|
|
10
|
-
* The rendered subtree is automatically
|
|
10
|
+
* The rendered subtree is automatically wrapped in a `Root` component, so that
|
|
11
11
|
* styles are rendered correctly.
|
|
12
12
|
*/
|
|
13
13
|
export declare const Portal: import('react').ForwardRefExoticComponent<PortalProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { UseReactToPrintOptions } from 'react-to-print';
|
|
3
|
+
/** Options that can be passed when calling `print`. */
|
|
4
|
+
export interface PrintOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Title of the `<iframe>` document, used by some browsers when saving as a
|
|
7
|
+
* file.
|
|
8
|
+
*/
|
|
9
|
+
documentTitle?: string;
|
|
10
|
+
/**
|
|
11
|
+
* [`size`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@page/size)
|
|
12
|
+
* to apply to print pages. This property can be used to specify custom page
|
|
13
|
+
* sizes and/or page orientation. By default, the browser default is used.
|
|
14
|
+
*/
|
|
15
|
+
pageSize?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Margin to apply to print pages. By default, no margin is specified and the
|
|
18
|
+
* browser default is used.
|
|
19
|
+
*/
|
|
20
|
+
pageMargin?: CSSProperties["margin"];
|
|
21
|
+
/**
|
|
22
|
+
* [`print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/print-color-adjust)
|
|
23
|
+
* CSS property.
|
|
24
|
+
*
|
|
25
|
+
* @default exact
|
|
26
|
+
*/
|
|
27
|
+
printColorAdjust?: CSSProperties["printColorAdjust"];
|
|
28
|
+
/**
|
|
29
|
+
* A list of fonts to load into the printing `<iframe>`.
|
|
30
|
+
*
|
|
31
|
+
* Useful when using custom fonts: the printing will be halted until all fonts
|
|
32
|
+
* are loaded to ensure that the content is able to use said fonts.
|
|
33
|
+
*/
|
|
34
|
+
fonts?: UseReactToPrintOptions["fonts"];
|
|
35
|
+
/**
|
|
36
|
+
* Copy shadow root content into the print `<iframe>`. Use with care when
|
|
37
|
+
* printing large documents as traversing these can be slow.
|
|
38
|
+
*
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
copyShadowRoots?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Set the
|
|
44
|
+
* [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
|
|
45
|
+
* attribute for allow-listing script and style elements for Content Security
|
|
46
|
+
* Policy (CSP).
|
|
47
|
+
*/
|
|
48
|
+
nonce?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Custom print function. By default, the `<iframe>` window's `print` function
|
|
51
|
+
* is called.
|
|
52
|
+
*/
|
|
53
|
+
printFn?: UseReactToPrintOptions["print"];
|
|
54
|
+
/** Properties to pass to the `<iframe>` used for printing. */
|
|
55
|
+
iframeProps?: UseReactToPrintOptions["printIframeProps"];
|
|
56
|
+
}
|
|
57
|
+
/** Properties of the printer component. */
|
|
58
|
+
export interface PrinterProps extends PrintOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Whether to render the printer content as if it were being printed. This
|
|
61
|
+
* property is expected to be used only for development/testing purposes.
|
|
62
|
+
*
|
|
63
|
+
* When `true`, this effectively causes the printer to “print” in the
|
|
64
|
+
* foreground, so the `printInForeground` property is ignored.
|
|
65
|
+
*
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
preview?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* By default, the provided `children` will be rendered twice while printing:
|
|
71
|
+
* once for the content displayed on screen; and another in a hidden
|
|
72
|
+
* “portalled” element for printing.
|
|
73
|
+
*
|
|
74
|
+
* By setting the property to `true`, the content visible on the screen itself
|
|
75
|
+
* will be printed. Note that this content will see `printing` set to `true`
|
|
76
|
+
* in the printer context while printing; so if the content behaves
|
|
77
|
+
* differently while printing, a user will notice it changing.
|
|
78
|
+
*
|
|
79
|
+
* This property has no effect when `preview` is set, since the previewed
|
|
80
|
+
* content is shown in the foreground.
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
printInForeground?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Function called just before printing starts, but after the content is ready
|
|
87
|
+
* to be copied over to an `<iframe>` for printing. If a promise is returned,
|
|
88
|
+
* printing is halted until it completes.
|
|
89
|
+
*
|
|
90
|
+
* @param event Before print event. Calling `event.preventDefault()` will
|
|
91
|
+
* prevent printing from occurring.
|
|
92
|
+
*/
|
|
93
|
+
onBeforePrint?: (event: Event) => void | Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Function called after printing finishes.
|
|
96
|
+
*
|
|
97
|
+
* @param event After print event. Calling `event.preventDefault()` will
|
|
98
|
+
* prevent focusing of the print trigger from occurring.
|
|
99
|
+
*/
|
|
100
|
+
onAfterPrint?: (event: Event) => void;
|
|
101
|
+
children?: ReactNode;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Component used to print content using the browser's printing functionality.
|
|
105
|
+
* The content is copied to a hidden `<iframe>` which is then printed by the
|
|
106
|
+
* browser.
|
|
107
|
+
*
|
|
108
|
+
* Content being printed is aware of the fact that it is being printed and can
|
|
109
|
+
* adapt its appearance accordingly. Use the `usePrinting` and
|
|
110
|
+
* `useStartPrintingTask` hooks to control the printing behaviour.
|
|
111
|
+
*
|
|
112
|
+
* Built on top of the
|
|
113
|
+
* [`react-to-print`](https://github.com/MatthewHerbst/react-to-print) package.
|
|
114
|
+
*
|
|
115
|
+
* **Note**: While printing, the content to print is typically (unless
|
|
116
|
+
* `printInForeground` is provided) rendered twice: once for the content visible
|
|
117
|
+
* on the screen and another in a hidden and “portalled” element for printing.
|
|
118
|
+
*
|
|
119
|
+
* It composes the following subcomponents:
|
|
120
|
+
*
|
|
121
|
+
* - `PrinterTrigger`: The button which, when pressed, triggers the printing.
|
|
122
|
+
* - `PrinterContent`: The content to be printed.
|
|
123
|
+
*
|
|
124
|
+
* Example usage:
|
|
125
|
+
*
|
|
126
|
+
* ```tsx
|
|
127
|
+
* import {
|
|
128
|
+
* Button,
|
|
129
|
+
* Printer,
|
|
130
|
+
* PrinterContent,
|
|
131
|
+
* PrinterTrigger,
|
|
132
|
+
* } from "@ostack.tech/ui";
|
|
133
|
+
*
|
|
134
|
+
* function ContentToPrint() {
|
|
135
|
+
* return (
|
|
136
|
+
* <Printer>
|
|
137
|
+
* <PrinterTrigger>
|
|
138
|
+
* <Button>Print</Button>
|
|
139
|
+
* </PrinterTrigger>
|
|
140
|
+
*
|
|
141
|
+
* <PrinterContent>Content to print…</PrinterContent>
|
|
142
|
+
* </Printer>
|
|
143
|
+
* );
|
|
144
|
+
* }
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare function Printer({ preview, printInForeground, documentTitle, pageSize, pageMargin, printColorAdjust, fonts, copyShadowRoots, nonce, printFn, onBeforePrint, onAfterPrint, iframeProps, children, }: PrinterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { Portal } from '../Portal';
|
|
3
|
+
/** Properties of the printer content. */
|
|
4
|
+
export interface PrinterContentProps extends ComponentPropsWithoutRef<"div"> {
|
|
5
|
+
/**
|
|
6
|
+
* Change the component to the HTML tag or custom component of the only child.
|
|
7
|
+
* This will merge the original component props with the props of the supplied
|
|
8
|
+
* element/component and change the underlying DOM node.
|
|
9
|
+
*/
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
/** Whether the provided `children` should only be rendered while printing. */
|
|
12
|
+
printOnly?: boolean;
|
|
13
|
+
/** Container of the portal. */
|
|
14
|
+
portalContainer?: ComponentPropsWithRef<typeof Portal>["container"];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Content to be printed.
|
|
18
|
+
*
|
|
19
|
+
* All “element” properties provided to this component will be forwarded to a
|
|
20
|
+
* wrapper element which **only** exists during printing.
|
|
21
|
+
*/
|
|
22
|
+
export declare const PrinterContent: import('react').ForwardRefExoticComponent<PrinterContentProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Value of the printer content context. */
|
|
2
|
+
export interface PrinterContextValue {
|
|
3
|
+
printing: boolean;
|
|
4
|
+
startPrintingTask?: () => void;
|
|
5
|
+
finishPrintingTask?: () => void;
|
|
6
|
+
}
|
|
7
|
+
/** Printer content context. */
|
|
8
|
+
export declare const PrinterContentContext: import('react').Context<PrinterContextValue>;
|
|
9
|
+
/**
|
|
10
|
+
* Hook providing access to the printer content context.
|
|
11
|
+
*
|
|
12
|
+
* **Note**: This hook **can** be called outside the printer context.
|
|
13
|
+
*/
|
|
14
|
+
export declare function usePrinterContentContext(): PrinterContextValue;
|
|
15
|
+
/**
|
|
16
|
+
* Returns whether the component calling this hook is currently being printed.
|
|
17
|
+
*
|
|
18
|
+
* **Note**: This hook **can** be called outside the printer context.
|
|
19
|
+
*/
|
|
20
|
+
export declare function usePrinting(): boolean;
|
|
21
|
+
/** Options for the `useStartPrintingTask` hook. */
|
|
22
|
+
export interface UseStartPrintingTaskOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Whether to enable the printing task.
|
|
25
|
+
*
|
|
26
|
+
* @default `true`
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Marks a printing task as having started and returns a function that should be
|
|
32
|
+
* called when it finishes. The printer will wait for any ongoing printing tasks
|
|
33
|
+
* before printing.
|
|
34
|
+
*
|
|
35
|
+
* **Note**: This hook **can** be called outside the printer context, in which
|
|
36
|
+
* case starting/finishing printing tasks will be no-ops but **won't** fail.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useStartPrintingTask({ enabled, }?: UseStartPrintingTaskOptions): () => void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { PrintOptions } from './Printer.tsx';
|
|
3
|
+
/** Value of the printer context. */
|
|
4
|
+
interface PrinterContextValue {
|
|
5
|
+
preview?: boolean;
|
|
6
|
+
printInForeground?: boolean;
|
|
7
|
+
printInProgress: boolean;
|
|
8
|
+
triggerRef: RefObject<HTMLButtonElement | null>;
|
|
9
|
+
contentRef: RefObject<Element | Text | null>;
|
|
10
|
+
print: (options?: PrintOptions) => Promise<void>;
|
|
11
|
+
startPrintingTask: () => void;
|
|
12
|
+
finishPrintingTask: () => void;
|
|
13
|
+
}
|
|
14
|
+
/** Printer context. */
|
|
15
|
+
export declare const PrinterContext: import('react').Context<PrinterContextValue | null>;
|
|
16
|
+
/** Hook providing access to the printer context. */
|
|
17
|
+
export declare function usePrinterContext(): PrinterContextValue;
|
|
18
|
+
/**
|
|
19
|
+
* Returns whether printing is currently in progress.
|
|
20
|
+
*
|
|
21
|
+
* **Note**: This hook can be called even when a printer context is **not** in
|
|
22
|
+
* scope, in which case `false` will be returned.
|
|
23
|
+
*/
|
|
24
|
+
export declare function usePrintInProgress(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Hook providing access to the print function. This hook will throw if called
|
|
27
|
+
* outside the printer context.
|
|
28
|
+
*/
|
|
29
|
+
export declare function usePrint(): PrinterContextValue["print"];
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactElement } from 'react';
|
|
2
|
+
/** Properties of the printer trigger. */
|
|
3
|
+
export interface PrinterTriggerProps extends ComponentPropsWithoutRef<"button"> {
|
|
4
|
+
/**
|
|
5
|
+
* By default, the trigger will be hidden while printing, even when inside the
|
|
6
|
+
* print content. Set this to `true` to show it.
|
|
7
|
+
*
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
showWhenPrinting?: boolean;
|
|
11
|
+
children: ReactElement<ComponentPropsWithRef<"button">>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Trigger to print the content of the printer. The provided `children` should
|
|
15
|
+
* be a button.
|
|
16
|
+
*
|
|
17
|
+
* This trigger will **not** show in the print, even when inside the print
|
|
18
|
+
* content, unless `showWhenPrinting` is set to `true`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PrinterTrigger: import('react').ForwardRefExoticComponent<PrinterTriggerProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './Printer.tsx';
|
|
2
|
+
export * from './PrinterContent.tsx';
|
|
3
|
+
export { usePrinting, useStartPrintingTask } from './PrinterContentContext.tsx';
|
|
4
|
+
export { usePrint, usePrintInProgress } from './PrinterContext.ts';
|
|
5
|
+
export * from './PrinterTrigger.tsx';
|
|
6
|
+
export * from './usePrintClassNames.ts';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { AccentColor } from '../../utils/accent.ts';
|
|
3
3
|
import { ControlStatus } from '../../utils/control.ts';
|
|
4
4
|
import { SelectProps } from './Select.tsx';
|
|
@@ -7,7 +7,6 @@ export interface SelectContextValue {
|
|
|
7
7
|
registering?: boolean;
|
|
8
8
|
multiple: boolean;
|
|
9
9
|
value: string | string[];
|
|
10
|
-
setValue: Dispatch<SetStateAction<string | number | readonly string[]>>;
|
|
11
10
|
onOptionSelect: (value: string) => void;
|
|
12
11
|
status?: ControlStatus;
|
|
13
12
|
disabled?: boolean;
|
|
@@ -38,10 +37,9 @@ export declare const SelectContext: import('react').Context<SelectContextValue |
|
|
|
38
37
|
/** Options to pass to the `useCreateSelectContext` hook. */
|
|
39
38
|
export type UseCreateSelectContextOptions = Omit<SelectContextValue, "store">;
|
|
40
39
|
/** Hook which creates the select context. */
|
|
41
|
-
export declare function useCreateSelectContext({ multiple, value,
|
|
40
|
+
export declare function useCreateSelectContext({ multiple, value, onOptionSelect, status, disabled, readOnly, valueTagProps, }: UseCreateSelectContextOptions): {
|
|
42
41
|
multiple: boolean;
|
|
43
42
|
value: string | string[];
|
|
44
|
-
setValue: Dispatch<SetStateAction<string | number | readonly string[]>>;
|
|
45
43
|
onOptionSelect: (value: string) => void;
|
|
46
44
|
status: ControlStatus | undefined;
|
|
47
45
|
disabled: boolean | undefined;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Tabs as TabsPrimitive } from 'radix-ui';
|
|
2
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ComponentPropsWithRef } from 'react';
|
|
3
3
|
/** Properties of the tab content component. */
|
|
4
4
|
export interface TabContentProps extends Omit<ComponentPropsWithoutRef<typeof TabsPrimitive.TabsContent>, "value"> {
|
|
5
5
|
/** Value of the tab that corresponds to this content. */
|
|
6
6
|
value: string | number;
|
|
7
|
+
/**
|
|
8
|
+
* Properties to pass to the tab content label element (shown when printing
|
|
9
|
+
* with `showAllTabsWhilePrinting` set).
|
|
10
|
+
*/
|
|
11
|
+
tabContentLabelProps?: ComponentPropsWithRef<"span">;
|
|
7
12
|
}
|
|
8
13
|
/** Tab content component. */
|
|
9
14
|
export declare const TabContent: import('react').ForwardRefExoticComponent<TabContentProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -14,6 +14,8 @@ export interface TabsProps extends Omit<ComponentPropsWithoutRef<typeof TabsPrim
|
|
|
14
14
|
defaultValue?: string | number;
|
|
15
15
|
/** Value of the active tab. */
|
|
16
16
|
value?: string | number;
|
|
17
|
+
/** Whether the content of all tabs should be shown while printing. */
|
|
18
|
+
showAllTabsWhilePrinting?: boolean;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* The `Tabs` component allows content to be organised in tabs and displayed one
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { ScrollPosition } from '../../utils/useScrollPosition.ts';
|
|
2
3
|
import { TabsVariant } from './Tabs.tsx';
|
|
3
4
|
/** Value of the tabs' context. */
|
|
4
5
|
export interface TabsContextValue {
|
|
5
6
|
variant: TabsVariant;
|
|
7
|
+
showAllTabsWhilePrinting?: boolean;
|
|
6
8
|
store: TabsStore;
|
|
7
9
|
}
|
|
8
10
|
/** State of the tabs. */
|
|
@@ -11,14 +13,21 @@ export interface TabsState {
|
|
|
11
13
|
showScrollButtons?: boolean;
|
|
12
14
|
width: number;
|
|
13
15
|
scrollPosition?: ScrollPosition;
|
|
16
|
+
tabsLabels: Record<string, ReactNode>;
|
|
17
|
+
actions: TabsStateActions;
|
|
18
|
+
}
|
|
19
|
+
interface TabsStateActions {
|
|
20
|
+
registerTabLabel: (value: string, label: ReactNode) => (() => void) | void;
|
|
21
|
+
getTabLabel: (value: string) => ReactNode | undefined;
|
|
14
22
|
}
|
|
15
23
|
/** Tabs' store. */
|
|
16
24
|
export type TabsStore = ReturnType<typeof useCreateTabsContext>["store"];
|
|
17
25
|
/** Tabs' context. */
|
|
18
26
|
export declare const TabsContext: import('react').Context<TabsContextValue | null>;
|
|
19
27
|
/** Hook which creates the tabs' store. */
|
|
20
|
-
export declare function useCreateTabsContext(variant: TabsVariant, defaultValue?: string | number, value?: string | number): {
|
|
28
|
+
export declare function useCreateTabsContext(variant: TabsVariant, defaultValue?: string | number, value?: string | number, showAllTabsWhilePrinting?: boolean): {
|
|
21
29
|
variant: TabsVariant;
|
|
30
|
+
showAllTabsWhilePrinting: boolean | undefined;
|
|
22
31
|
store: Omit<import('zustand').StoreApi<TabsState>, "subscribe"> & {
|
|
23
32
|
subscribe: {
|
|
24
33
|
(listener: (selectedState: TabsState, previousSelectedState: TabsState) => void): () => void;
|
|
@@ -31,3 +40,8 @@ export declare function useCreateTabsContext(variant: TabsVariant, defaultValue?
|
|
|
31
40
|
};
|
|
32
41
|
/** Hooks returning the tabs' context value. */
|
|
33
42
|
export declare function useTabsContext(): TabsContextValue;
|
|
43
|
+
/** Hook which registers a tab label. */
|
|
44
|
+
export declare function useRegisterTabLabel(value: string, label: ReactNode): void;
|
|
45
|
+
/** Hook which returns the label of a tab. */
|
|
46
|
+
export declare function useTabLabel(value: string): ReactNode;
|
|
47
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export * from './components/NumericInput';
|
|
|
44
44
|
export * from './components/Output';
|
|
45
45
|
export * from './components/Popover';
|
|
46
46
|
export * from './components/Portal';
|
|
47
|
+
export * from './components/Printer';
|
|
47
48
|
export * from './components/RadioGroup';
|
|
48
49
|
export * from './components/Select';
|
|
49
50
|
export * from './components/Separator';
|
|
@@ -8,7 +8,7 @@ import { AlertDialogProviderContextValue } from './AlertDialogProviderContext.ts
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
*
|
|
11
|
-
* ```
|
|
11
|
+
* ```tsx
|
|
12
12
|
* const { alert, confirm } = useAlertDialog();
|
|
13
13
|
*
|
|
14
14
|
* async function handleRemoveItemClick(event) {
|
|
@@ -32,7 +32,7 @@ import { AlertDialogProviderContextValue } from './AlertDialogProviderContext.ts
|
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
*
|
|
35
|
-
* ```
|
|
35
|
+
* ```tsx
|
|
36
36
|
* const { prompt } = useAlertDialog();
|
|
37
37
|
*
|
|
38
38
|
* async function handleClick(event) {
|
package/dist/types/utils/cx.d.ts
CHANGED
|
@@ -65,6 +65,12 @@ export interface RegisterKeyboardShortcutOptions {
|
|
|
65
65
|
export declare function registerKeyboardShortcut(keybinds: string | string[], action: KeyboardShortcutAction, { target, eventType, sequenceTimeout, ignore, capture, preventDefault, }?: RegisterKeyboardShortcutOptions): () => void;
|
|
66
66
|
/** Options of the `useKeyboardShortcut` hook. */
|
|
67
67
|
export interface UseKeyboardShortcutOptions extends Omit<RegisterKeyboardShortcutOptions, "target"> {
|
|
68
|
+
/**
|
|
69
|
+
* Whether the shortcut should be enabled.
|
|
70
|
+
*
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
enabled?: boolean;
|
|
68
74
|
/**
|
|
69
75
|
* Target element on which to listen for the keybinds. While set to `null`
|
|
70
76
|
* keybinds will be ignored.
|
|
@@ -102,7 +108,7 @@ export interface UseKeyboardShortcutOptions extends Omit<RegisterKeyboardShortcu
|
|
|
102
108
|
* @see {@link registerKeyboardShortcut} for a non-hook version of this
|
|
103
109
|
* function.
|
|
104
110
|
*/
|
|
105
|
-
export declare function useKeyboardShortcut(keybinds: string | string[] | null | undefined, action: KeyboardShortcutAction, { target, eventType, sequenceTimeout, ignore, capture, preventDefault, }?: UseKeyboardShortcutOptions): void;
|
|
111
|
+
export declare function useKeyboardShortcut(keybinds: string | string[] | null | undefined, action: KeyboardShortcutAction, { enabled, target, eventType, sequenceTimeout, ignore, capture, preventDefault, }?: UseKeyboardShortcutOptions): void;
|
|
106
112
|
/**
|
|
107
113
|
* `ignore` function to use in `registerKeyboardShortcut`/`useKeyboardShortcut`
|
|
108
114
|
* which ignores triggered shortcuts which occur in `<input>`, `<textarea>`, or
|
|
@@ -11,7 +11,7 @@ export interface UseCssVarsResult {
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
*
|
|
14
|
-
* ```
|
|
14
|
+
* ```ts
|
|
15
15
|
* cssVarName("color"); // returns "--[prefix]-color"
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
@@ -22,7 +22,7 @@ export interface UseCssVarsResult {
|
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
*
|
|
25
|
-
* ```
|
|
25
|
+
* ```ts
|
|
26
26
|
* cssVar("color"); // returns "var(--[prefix]-color)"
|
|
27
27
|
* cssVar("size", "10px"); // returns "var(--[prefix]-size, 10px)"
|
|
28
28
|
* ```
|
|
@@ -34,7 +34,7 @@ export interface UseCssVarsResult {
|
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
36
|
*
|
|
37
|
-
* ```
|
|
37
|
+
* ```ts
|
|
38
38
|
* cssVarStyle("color", "red"); // returns {"--[prefix]-color": "red"}
|
|
39
39
|
* cssVarStyle("size", undefined); // returns undefined
|
|
40
40
|
* ```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ostack.tech/ui",
|
|
3
3
|
"description": "ostack/UI component library.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"homepage": "https://ui.ostack.tech/",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Opensoft",
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
"cmdk": "^1.1.1",
|
|
50
50
|
"from-exponential": "^1.1.1",
|
|
51
51
|
"radix-ui": "^1.4.3",
|
|
52
|
-
"react-day-picker": "^9.11.
|
|
52
|
+
"react-day-picker": "^9.11.2",
|
|
53
53
|
"react-error-boundary": "^6.0.0",
|
|
54
54
|
"react-number-format": "^5.4.4",
|
|
55
|
+
"react-to-print": "^3.2.0",
|
|
55
56
|
"tinykeys": "^3.0.0"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
@@ -63,12 +63,11 @@
|
|
|
63
63
|
> #{$tabs-tab-list-root} {
|
|
64
64
|
flex-grow: 1;
|
|
65
65
|
z-index: var(--#{$prefix}z-index-docked);
|
|
66
|
-
margin
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
66
|
+
margin: calc(
|
|
67
|
+
var(--#{$prefix}card-padding-y) * -1 +
|
|
68
|
+
$card-tabs-tab-list-margin-y-offset
|
|
69
|
+
)
|
|
70
|
+
calc(var(--#{$prefix}card-padding-x) * -1);
|
|
72
71
|
padding-left: max(
|
|
73
72
|
var(--#{$prefix}card-padding-x) - var(--#{$prefix}tabs-tab-padding-x),
|
|
74
73
|
var(--#{$prefix}tabs-tab-margin-x, 0)
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
@use "Spinner-variables" as *;
|
|
2
2
|
@use "../../scss/base-variables" as *;
|
|
3
|
+
@use "../../scss/utils/declare-var" as *;
|
|
3
4
|
@use "../../scss/utils/spinner" as *;
|
|
4
5
|
|
|
5
6
|
.#{$prefix}spinner {
|
|
6
7
|
@include spinner;
|
|
7
8
|
|
|
9
|
+
// Accent
|
|
8
10
|
&[data-accent] {
|
|
9
|
-
|
|
11
|
+
@include declare-var(
|
|
12
|
+
--#{$prefix}spinner-track-color,
|
|
13
|
+
$spinner-accent-track-color
|
|
14
|
+
);
|
|
15
|
+
@include declare-var(
|
|
16
|
+
--#{$prefix}spinner-indicator-color,
|
|
17
|
+
$spinner-accent-indicator-color
|
|
18
|
+
);
|
|
10
19
|
}
|
|
11
20
|
|
|
12
21
|
// Sizes
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
width: 100%;
|
|
26
26
|
overflow: auto;
|
|
27
27
|
|
|
28
|
+
@media print {
|
|
29
|
+
overflow: unset;
|
|
30
|
+
min-width: 100%;
|
|
31
|
+
width: min-content;
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
border-radius: var(--#{$prefix}table-border-radius);
|
|
29
35
|
border-width: var(--#{$prefix}table-border-width, 0);
|
|
30
36
|
border-style: solid;
|
|
@@ -201,6 +201,22 @@ $tabs-scroll-button-overflow-indicator-z-index: calc(
|
|
|
201
201
|
var(--#{$prefix}z-index-focused) + 1
|
|
202
202
|
) !default;
|
|
203
203
|
|
|
204
|
+
// Tab content label
|
|
205
|
+
$tabs-tab-content-label-padding-y: calc(
|
|
206
|
+
$tabs-tab-default-padding-y + $tabs-tab-inner-default-padding-y
|
|
207
|
+
) !default;
|
|
208
|
+
$tabs-tab-content-label-padding-x: calc(
|
|
209
|
+
$tabs-tab-default-padding-x + $tabs-tab-inner-default-padding-x
|
|
210
|
+
) !default;
|
|
211
|
+
$tabs-tab-content-label-margin-bottom: spacing(1.5) !default;
|
|
212
|
+
$tabs-tab-content-label-border-bottom: 2px solid var(--#{$prefix}primary-9) !default;
|
|
213
|
+
$tabs-tab-content-label-font-size: var(--#{$prefix}font-size-sm) !default;
|
|
214
|
+
$tabs-tab-content-label-line-height: var(--#{$prefix}font-size-sm) !default;
|
|
215
|
+
$tabs-tab-content-label-font-weight: $font-weight-medium !default;
|
|
216
|
+
|
|
217
|
+
// Tab content
|
|
218
|
+
$tabs-tab-content-gap-y: spacing(2) !default;
|
|
219
|
+
|
|
204
220
|
// Tab content - Focus
|
|
205
221
|
$tabs-tab-content-focus-outline-width: 2px !default;
|
|
206
222
|
$tabs-tab-content-focus-outline-color: var(--#{$prefix}primary-8) !default;
|