@optimum-intelligence/opti-ui 0.7.6 → 0.8.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/CHANGELOG.md +63 -0
- package/README.md +20 -10
- package/dist/components/alert/Alert.d.ts +5 -2
- package/dist/components/alert/Alert.js +67 -65
- package/dist/components/alert/Alert.js.map +1 -1
- package/dist/components/app-shell/AppShell.d.ts +19 -7
- package/dist/components/app-shell/AppShell.js +329 -303
- package/dist/components/app-shell/AppShell.js.map +1 -1
- package/dist/components/calendar/Calendar.js +140 -136
- package/dist/components/calendar/Calendar.js.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +8 -2
- package/dist/components/combobox/Combobox.js +182 -202
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/data-table/DataTable.d.ts +23 -11
- package/dist/components/data-table/DataTable.js +148 -88
- package/dist/components/data-table/DataTable.js.map +1 -1
- package/dist/components/data-table/DataTableContent.js +1 -1
- package/dist/components/data-table/DataTableFilters.d.ts +56 -4
- package/dist/components/data-table/DataTableFilters.js +492 -77
- package/dist/components/data-table/DataTableFilters.js.map +1 -1
- package/dist/components/data-table/types.d.ts +13 -2
- package/dist/components/data-table/useDataTable.d.ts +1 -1
- package/dist/components/data-table/useDataTable.js +251 -229
- package/dist/components/data-table/useDataTable.js.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +5 -0
- package/dist/components/date-picker/DatePicker.js +148 -140
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/date-picker/DateRangePicker.d.ts +2 -0
- package/dist/components/date-picker/DateRangePicker.js +171 -164
- package/dist/components/date-picker/DateRangePicker.js.map +1 -1
- package/dist/components/date-picker/PickerField.d.ts +6 -3
- package/dist/components/date-picker/PickerField.js +166 -159
- package/dist/components/date-picker/PickerField.js.map +1 -1
- package/dist/components/dialog/ConfirmDialog.d.ts +5 -2
- package/dist/components/dialog/ConfirmDialog.js +79 -77
- package/dist/components/dialog/ConfirmDialog.js.map +1 -1
- package/dist/components/dialog/Dialog.d.ts +5 -2
- package/dist/components/dialog/Dialog.js +65 -63
- package/dist/components/dialog/Dialog.js.map +1 -1
- package/dist/components/drawer/Drawer.d.ts +13 -4
- package/dist/components/drawer/Drawer.js +122 -164
- package/dist/components/drawer/Drawer.js.map +1 -1
- package/dist/components/field/Field.d.ts +38 -9
- package/dist/components/field/Field.js +66 -1
- package/dist/components/field/Field.js.map +1 -1
- package/dist/components/file-upload/FileUpload.js +2 -0
- package/dist/components/file-upload/FileUpload.js.map +1 -1
- package/dist/components/input/Input.d.ts +9 -16
- package/dist/components/input/Input.js +124 -206
- package/dist/components/input/Input.js.map +1 -1
- package/dist/components/map/colors.d.ts +2 -2
- package/dist/components/map/colors.js +12 -3
- package/dist/components/map/colors.js.map +1 -1
- package/dist/components/number-field/NumberField.d.ts +12 -3
- package/dist/components/number-field/NumberField.js +109 -130
- package/dist/components/number-field/NumberField.js.map +1 -1
- package/dist/components/pagination/Pagination.js +135 -186
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/search-input/SearchInput.d.ts +5 -2
- package/dist/components/search-input/SearchInput.js +47 -45
- package/dist/components/search-input/SearchInput.js.map +1 -1
- package/dist/components/select/Select.d.ts +13 -3
- package/dist/components/select/Select.js +144 -139
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/spinner/Spinner.d.ts +6 -2
- package/dist/components/spinner/Spinner.js +42 -40
- package/dist/components/spinner/Spinner.js.map +1 -1
- package/dist/components/stepper/Stepper.js +44 -40
- package/dist/components/stepper/Stepper.js.map +1 -1
- package/dist/components/toast/Toast.d.ts +17 -1
- package/dist/components/toast/Toast.js +65 -33
- package/dist/components/toast/Toast.js.map +1 -1
- package/dist/components.json +377 -57
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -3
- package/dist/labels/Labels.d.ts +85 -0
- package/dist/labels/Labels.js +92 -0
- package/dist/labels/Labels.js.map +1 -0
- package/dist/llms-full.txt +224 -37
- package/dist/llms.txt +10 -4
- package/dist/opti-ui.css +210 -18
- package/dist/theme/ThemeProvider.d.ts +8 -4
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/utils/media.d.ts +9 -2
- package/dist/utils/media.js +10 -3
- package/dist/utils/media.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './theme';
|
|
2
2
|
export * from './components/calendar/DateConfig';
|
|
3
|
+
export * from './labels/Labels';
|
|
3
4
|
export * from './components/app-shell/AppShell';
|
|
4
5
|
export * from './components/card/Card';
|
|
5
6
|
export * from './components/stat-card/StatCard';
|
|
@@ -56,3 +57,4 @@ export { cx, withClass } from './utils/cx';
|
|
|
56
57
|
export type { ClassValue } from './utils/cx';
|
|
57
58
|
export { matchesQuery, normalizeText } from './utils/search';
|
|
58
59
|
export { usePortalContainer } from './utils/portal';
|
|
60
|
+
export { useMediaQuery, NARROW_SCREEN, SHELL_COLLAPSED } from './utils/media';
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { cx, withClass } from "./utils/cx.js";
|
|
|
5
5
|
import { ThemeProvider, createTheme, themeToStyle } from "./theme/ThemeProvider.js";
|
|
6
6
|
import { seriesColor } from "./theme/series.js";
|
|
7
7
|
import { DateConfigProvider, useDateConfig } from "./components/calendar/DateConfig.js";
|
|
8
|
+
import { LabelsProvider, useLabels } from "./labels/Labels.js";
|
|
8
9
|
import { ArrowDownIcon, ArrowUpIcon, CalendarIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsUpDownIcon, CircleCheckIcon, CircleIcon, CircleXIcon, ClockIcon, DownloadIcon, ExternalLinkIcon, EyeIcon, EyeOffIcon, FileIcon, FilterIcon, InfoIcon, LayersIcon, MenuIcon, MinusIcon, MoreHorizontalIcon, PencilIcon, PlusIcon, SearchIcon, TrashIcon, TrendingDownIcon, TrendingUpIcon, TriangleAlertIcon, UploadIcon, XIcon } from "./icons/index.js";
|
|
9
10
|
import { AppShell, Grid, Navbar, NavbarBrand, NavbarFooter, NavbarGroup, NavbarHeader, NavbarItem, NavbarSection, NavbarSectionLabel, PageHeader } from "./components/app-shell/AppShell.js";
|
|
10
11
|
import { Card, CardActions, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./components/card/Card.js";
|
|
@@ -20,7 +21,7 @@ import { Button, IconButton } from "./components/button/Button.js";
|
|
|
20
21
|
import { SegmentedControl, Toggle, ToggleGroup } from "./components/toggle/Toggle.js";
|
|
21
22
|
import { ContextMenu, Menu } from "./components/menu/Menu.js";
|
|
22
23
|
import { Toolbar } from "./components/toolbar/Toolbar.js";
|
|
23
|
-
import { Field, Fieldset, Form } from "./components/field/Field.js";
|
|
24
|
+
import { Field, Fieldset, Form, FormField } from "./components/field/Field.js";
|
|
24
25
|
import { Input, PasswordField, PasswordInput, TextField, Textarea, TextareaField } from "./components/input/Input.js";
|
|
25
26
|
import { Select } from "./components/select/Select.js";
|
|
26
27
|
import { Combobox } from "./components/combobox/Combobox.js";
|
|
@@ -30,6 +31,8 @@ import { Slider } from "./components/slider/Slider.js";
|
|
|
30
31
|
import { SearchInput } from "./components/search-input/SearchInput.js";
|
|
31
32
|
import { formatDate } from "./components/calendar/date-utils.js";
|
|
32
33
|
import { Calendar, RangeCalendar } from "./components/calendar/Calendar.js";
|
|
34
|
+
import { NARROW_SCREEN, SHELL_COLLAPSED, useMediaQuery } from "./utils/media.js";
|
|
35
|
+
import { Drawer } from "./components/drawer/Drawer.js";
|
|
33
36
|
import { Popover } from "./components/popover/Popover.js";
|
|
34
37
|
import { DatePicker, DateTimePicker } from "./components/date-picker/DatePicker.js";
|
|
35
38
|
import { DateRangePicker } from "./components/date-picker/DateRangePicker.js";
|
|
@@ -38,7 +41,6 @@ import { Dropzone, FileItem, FileUpload, formatFileSize } from "./components/fil
|
|
|
38
41
|
import { AlertDialog, Dialog } from "./components/dialog/Dialog.js";
|
|
39
42
|
import { Alert } from "./components/alert/Alert.js";
|
|
40
43
|
import { ConfirmDialog } from "./components/dialog/ConfirmDialog.js";
|
|
41
|
-
import { Drawer } from "./components/drawer/Drawer.js";
|
|
42
44
|
import { Tooltip } from "./components/tooltip/Tooltip.js";
|
|
43
45
|
import { PreviewCard } from "./components/preview-card/PreviewCard.js";
|
|
44
46
|
import { ToastProvider, createToastManager, useToast } from "./components/toast/Toast.js";
|
|
@@ -59,4 +61,4 @@ import { EmptyState } from "./components/empty-state/EmptyState.js";
|
|
|
59
61
|
import { useDataTable } from "./components/data-table/useDataTable.js";
|
|
60
62
|
import { DataTable } from "./components/data-table/DataTable.js";
|
|
61
63
|
import { DescriptionItem, DescriptionList } from "./components/description-list/DescriptionList.js";
|
|
62
|
-
export { Accordion, Alert, AlertDialog, AppShell, ArrowDownIcon, ArrowUpIcon, Avatar, AvatarGroup, Badge, Breadcrumb, Breadcrumbs, Button, Calendar, CalendarIcon, Card, CardActions, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckIcon, Checkbox, CheckboxGroup, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsUpDownIcon, CircleCheckIcon, CircleIcon, CircleXIcon, ClockIcon, Collapsible, Combobox, CommandPalette, ConfirmDialog, ContextMenu, DataTable, DateConfigProvider, DatePicker, DateRangePicker, DateTimePicker, DescriptionItem, DescriptionList, Dialog, DownloadIcon, Drawer, Dropzone, EmptyState, ExternalLinkIcon, EyeIcon, EyeOffIcon, Eyebrow, Field, Fieldset, FileIcon, FileItem, FileUpload, FilterIcon, Form, Grid, Heading, IconButton, InfoIcon, Input, LayersIcon, Link, Menu, MenuIcon, Meter, MinusIcon, MoreHorizontalIcon, Navbar, NavbarBrand, NavbarFooter, NavbarGroup, NavbarHeader, NavbarItem, NavbarSection, NavbarSectionLabel, NumberField, PageHeader, Pagination, PasswordField, PasswordInput, PencilIcon, PlusIcon, Popover, PreviewCard, Progress, Radio, RadioGroup, RangeCalendar, ScrollArea, SearchIcon, SearchInput, SegmentedControl, Select, Separator, Skeleton, SkeletonText, Slider, Spinner, Stack, StatCard, Stepper, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, Tag, Text, TextField, Textarea, TextareaField, ThemeProvider, ToastProvider, Toggle, ToggleGroup, Toolbar, Tooltip, TrashIcon, TrendingDownIcon, TrendingUpIcon, TriangleAlertIcon, UploadIcon, XIcon, createTheme, createToastManager, cx, formatDate, formatFileSize, getPageItems, matchesQuery, normalizeText, seriesColor, themeToStyle, useDataTable, useDataTableContext, useDateConfig, usePortalContainer, useToast, withClass };
|
|
64
|
+
export { Accordion, Alert, AlertDialog, AppShell, ArrowDownIcon, ArrowUpIcon, Avatar, AvatarGroup, Badge, Breadcrumb, Breadcrumbs, Button, Calendar, CalendarIcon, Card, CardActions, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CheckIcon, Checkbox, CheckboxGroup, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsUpDownIcon, CircleCheckIcon, CircleIcon, CircleXIcon, ClockIcon, Collapsible, Combobox, CommandPalette, ConfirmDialog, ContextMenu, DataTable, DateConfigProvider, DatePicker, DateRangePicker, DateTimePicker, DescriptionItem, DescriptionList, Dialog, DownloadIcon, Drawer, Dropzone, EmptyState, ExternalLinkIcon, EyeIcon, EyeOffIcon, Eyebrow, Field, Fieldset, FileIcon, FileItem, FileUpload, FilterIcon, Form, FormField, Grid, Heading, IconButton, InfoIcon, Input, LabelsProvider, LayersIcon, Link, Menu, MenuIcon, Meter, MinusIcon, MoreHorizontalIcon, NARROW_SCREEN, Navbar, NavbarBrand, NavbarFooter, NavbarGroup, NavbarHeader, NavbarItem, NavbarSection, NavbarSectionLabel, NumberField, PageHeader, Pagination, PasswordField, PasswordInput, PencilIcon, PlusIcon, Popover, PreviewCard, Progress, Radio, RadioGroup, RangeCalendar, SHELL_COLLAPSED, ScrollArea, SearchIcon, SearchInput, SegmentedControl, Select, Separator, Skeleton, SkeletonText, Slider, Spinner, Stack, StatCard, Stepper, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, Tag, Text, TextField, Textarea, TextareaField, ThemeProvider, ToastProvider, Toggle, ToggleGroup, Toolbar, Tooltip, TrashIcon, TrendingDownIcon, TrendingUpIcon, TriangleAlertIcon, UploadIcon, XIcon, createTheme, createToastManager, cx, formatDate, formatFileSize, getPageItems, matchesQuery, normalizeText, seriesColor, themeToStyle, useDataTable, useDataTableContext, useDateConfig, useLabels, useMediaQuery, usePortalContainer, useToast, withClass };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { CalendarLabels } from '../components/calendar/Calendar';
|
|
3
|
+
import type { DataTableLabels } from '../components/data-table/types';
|
|
4
|
+
import type { DatePickerLabels } from '../components/date-picker/DatePicker';
|
|
5
|
+
import type { DateRangePickerLabels } from '../components/date-picker/DateRangePicker';
|
|
6
|
+
import type { FileUploadLabels } from '../components/file-upload/FileUpload';
|
|
7
|
+
import type { PaginationLabels } from '../components/pagination/Pagination';
|
|
8
|
+
import type { StepperLabels } from '../components/stepper/Stepper';
|
|
9
|
+
/** Every built-in text of the library, for `LabelsProvider`. */
|
|
10
|
+
export interface Labels {
|
|
11
|
+
/** Close buttons of `Dialog`, `Drawer` and toasts. */
|
|
12
|
+
close: string;
|
|
13
|
+
/** Dismiss button of an `Alert`. */
|
|
14
|
+
dismiss: string;
|
|
15
|
+
/** Cancel button of a `ConfirmDialog`. */
|
|
16
|
+
cancel: string;
|
|
17
|
+
/** Accessible name of a `Spinner`. */
|
|
18
|
+
loading: string;
|
|
19
|
+
/** Placeholder of a `Select` with nothing chosen. */
|
|
20
|
+
selectPlaceholder: string;
|
|
21
|
+
/** Clear button of a `SearchInput`. */
|
|
22
|
+
clearSearch: string;
|
|
23
|
+
/** Show/hide button of a `PasswordInput`. */
|
|
24
|
+
showPassword: string;
|
|
25
|
+
/** − button of a `NumberField`. */
|
|
26
|
+
decrease: string;
|
|
27
|
+
/** + button of a `NumberField`. */
|
|
28
|
+
increase: string;
|
|
29
|
+
/** Button that opens a `Combobox` list. */
|
|
30
|
+
openList: string;
|
|
31
|
+
/** Button that clears a `Combobox`. */
|
|
32
|
+
clearSelection: string;
|
|
33
|
+
/** Remove button of a chip in a multiple `Combobox`. */
|
|
34
|
+
removeItem: (label: string) => string;
|
|
35
|
+
/** The `+N` chip of a multiple `Combobox` with `maxChips`. */
|
|
36
|
+
moreSelected: (count: number) => string;
|
|
37
|
+
/** Shown when a `Combobox` filter matches nothing. */
|
|
38
|
+
noResults: string;
|
|
39
|
+
/** Collapse button of the `Navbar`. */
|
|
40
|
+
collapseNavbar: string;
|
|
41
|
+
/** Expand button of a collapsed `Navbar`. */
|
|
42
|
+
expandNavbar: string;
|
|
43
|
+
/** `AppShell` mobile menu button, shown when there is no tab bar. */
|
|
44
|
+
openNavigation: string;
|
|
45
|
+
/** `AppShell` tab that opens the full navigation. */
|
|
46
|
+
more: string;
|
|
47
|
+
/** Accessible name of the `AppShell` mobile tab bar. */
|
|
48
|
+
quickNavigation: string;
|
|
49
|
+
/** Accessible name of the `AppShell` navigation drawer. */
|
|
50
|
+
navigation: string;
|
|
51
|
+
/** Close button of the `AppShell` navigation drawer. */
|
|
52
|
+
closeNavigation: string;
|
|
53
|
+
/** Texts of `Calendar` and `RangeCalendar`. */
|
|
54
|
+
calendar: Partial<CalendarLabels>;
|
|
55
|
+
/** Texts of `DatePicker`. */
|
|
56
|
+
datePicker: Partial<DatePickerLabels>;
|
|
57
|
+
/** Texts of `DateRangePicker`. */
|
|
58
|
+
dateRangePicker: Partial<DateRangePickerLabels>;
|
|
59
|
+
/** Texts of `Pagination`. */
|
|
60
|
+
pagination: Partial<PaginationLabels>;
|
|
61
|
+
/** Texts of `Stepper`. */
|
|
62
|
+
stepper: Partial<StepperLabels>;
|
|
63
|
+
/** Texts of `FileUpload`. */
|
|
64
|
+
fileUpload: Partial<FileUploadLabels>;
|
|
65
|
+
/** Texts of `DataTable`. */
|
|
66
|
+
dataTable: Partial<DataTableLabels>;
|
|
67
|
+
}
|
|
68
|
+
export interface LabelsProviderProps {
|
|
69
|
+
/** Texts to replace. Nested providers override only what they pass; props on a component still win. */
|
|
70
|
+
labels: Partial<Labels>;
|
|
71
|
+
/** The subtree that uses these texts. */
|
|
72
|
+
children?: React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Replaces the library's built-in English texts (button names, placeholders, table and calendar texts) for
|
|
76
|
+
* everything inside it, so an app translates them once instead of per component.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* <LabelsProvider labels={{ close: 'Bezárás', selectPlaceholder: 'Válasszon…', dataTable: { search: 'Keresés…' } }}>
|
|
80
|
+
* <App />
|
|
81
|
+
* </LabelsProvider>
|
|
82
|
+
*/
|
|
83
|
+
export declare function LabelsProvider({ labels, children }: LabelsProviderProps): React.JSX.Element;
|
|
84
|
+
/** The texts from the nearest `LabelsProvider`, with English defaults for the rest. */
|
|
85
|
+
export declare function useLabels(): Labels;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/labels/Labels.tsx
|
|
6
|
+
var defaultLabels = {
|
|
7
|
+
close: "Close",
|
|
8
|
+
dismiss: "Dismiss",
|
|
9
|
+
cancel: "Cancel",
|
|
10
|
+
loading: "Loading",
|
|
11
|
+
selectPlaceholder: "Select…",
|
|
12
|
+
clearSearch: "Clear search",
|
|
13
|
+
showPassword: "Show password",
|
|
14
|
+
decrease: "Decrease",
|
|
15
|
+
increase: "Increase",
|
|
16
|
+
openList: "Open list",
|
|
17
|
+
clearSelection: "Clear selection",
|
|
18
|
+
removeItem: (label) => `Remove ${label}`,
|
|
19
|
+
moreSelected: (count) => `${count} more selected`,
|
|
20
|
+
noResults: "No results found.",
|
|
21
|
+
collapseNavbar: "Collapse",
|
|
22
|
+
expandNavbar: "Expand",
|
|
23
|
+
openNavigation: "Open navigation",
|
|
24
|
+
more: "More",
|
|
25
|
+
quickNavigation: "Quick navigation",
|
|
26
|
+
navigation: "Navigation",
|
|
27
|
+
closeNavigation: "Close navigation",
|
|
28
|
+
calendar: {},
|
|
29
|
+
datePicker: {},
|
|
30
|
+
dateRangePicker: {},
|
|
31
|
+
pagination: {},
|
|
32
|
+
stepper: {},
|
|
33
|
+
fileUpload: {},
|
|
34
|
+
dataTable: {}
|
|
35
|
+
};
|
|
36
|
+
var nested = [
|
|
37
|
+
"calendar",
|
|
38
|
+
"datePicker",
|
|
39
|
+
"dateRangePicker",
|
|
40
|
+
"pagination",
|
|
41
|
+
"stepper",
|
|
42
|
+
"fileUpload",
|
|
43
|
+
"dataTable"
|
|
44
|
+
];
|
|
45
|
+
var LabelsContext = React.createContext(defaultLabels);
|
|
46
|
+
/**
|
|
47
|
+
* Replaces the library's built-in English texts (button names, placeholders, table and calendar texts) for
|
|
48
|
+
* everything inside it, so an app translates them once instead of per component.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* <LabelsProvider labels={{ close: 'Bezárás', selectPlaceholder: 'Válasszon…', dataTable: { search: 'Keresés…' } }}>
|
|
52
|
+
* <App />
|
|
53
|
+
* </LabelsProvider>
|
|
54
|
+
*/
|
|
55
|
+
function LabelsProvider(t0) {
|
|
56
|
+
const $ = c(6);
|
|
57
|
+
const { labels, children } = t0;
|
|
58
|
+
const parent = React.useContext(LabelsContext);
|
|
59
|
+
let value;
|
|
60
|
+
if ($[0] !== labels || $[1] !== parent) {
|
|
61
|
+
value = {
|
|
62
|
+
...parent,
|
|
63
|
+
...labels
|
|
64
|
+
};
|
|
65
|
+
for (const key of nested) value[key] = {
|
|
66
|
+
...parent[key],
|
|
67
|
+
...labels[key]
|
|
68
|
+
};
|
|
69
|
+
$[0] = labels;
|
|
70
|
+
$[1] = parent;
|
|
71
|
+
$[2] = value;
|
|
72
|
+
} else value = $[2];
|
|
73
|
+
let t1;
|
|
74
|
+
if ($[3] !== children || $[4] !== value) {
|
|
75
|
+
t1 = /* @__PURE__ */ jsx(LabelsContext, {
|
|
76
|
+
value,
|
|
77
|
+
children
|
|
78
|
+
});
|
|
79
|
+
$[3] = children;
|
|
80
|
+
$[4] = value;
|
|
81
|
+
$[5] = t1;
|
|
82
|
+
} else t1 = $[5];
|
|
83
|
+
return t1;
|
|
84
|
+
}
|
|
85
|
+
/** The texts from the nearest `LabelsProvider`, with English defaults for the rest. */
|
|
86
|
+
function useLabels() {
|
|
87
|
+
return React.useContext(LabelsContext);
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { LabelsProvider, useLabels };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=Labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Labels.js","names":["React","CalendarLabels","DataTableLabels","DatePickerLabels","DateRangePickerLabels","FileUploadLabels","PaginationLabels","StepperLabels","Labels","close","dismiss","cancel","loading","selectPlaceholder","clearSearch","showPassword","decrease","increase","openList","clearSelection","removeItem","label","moreSelected","count","noResults","collapseNavbar","expandNavbar","openNavigation","more","quickNavigation","navigation","closeNavigation","calendar","Partial","datePicker","dateRangePicker","pagination","stepper","fileUpload","dataTable","defaultLabels","nested","const","LabelsContext","createContext","LabelsProviderProps","labels","children","ReactNode","LabelsProvider","t0","$","_c","parent","useContext","value","key","t1","useLabels","_c"],"sources":["../../src/labels/Labels.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { CalendarLabels } from '../components/calendar/Calendar';\nimport type { DataTableLabels } from '../components/data-table/types';\nimport type { DatePickerLabels } from '../components/date-picker/DatePicker';\nimport type { DateRangePickerLabels } from '../components/date-picker/DateRangePicker';\nimport type { FileUploadLabels } from '../components/file-upload/FileUpload';\nimport type { PaginationLabels } from '../components/pagination/Pagination';\nimport type { StepperLabels } from '../components/stepper/Stepper';\n\n/** Every built-in text of the library, for `LabelsProvider`. */\nexport interface Labels {\n /** Close buttons of `Dialog`, `Drawer` and toasts. */\n close: string;\n /** Dismiss button of an `Alert`. */\n dismiss: string;\n /** Cancel button of a `ConfirmDialog`. */\n cancel: string;\n /** Accessible name of a `Spinner`. */\n loading: string;\n /** Placeholder of a `Select` with nothing chosen. */\n selectPlaceholder: string;\n /** Clear button of a `SearchInput`. */\n clearSearch: string;\n /** Show/hide button of a `PasswordInput`. */\n showPassword: string;\n /** − button of a `NumberField`. */\n decrease: string;\n /** + button of a `NumberField`. */\n increase: string;\n /** Button that opens a `Combobox` list. */\n openList: string;\n /** Button that clears a `Combobox`. */\n clearSelection: string;\n /** Remove button of a chip in a multiple `Combobox`. */\n removeItem: (label: string) => string;\n /** The `+N` chip of a multiple `Combobox` with `maxChips`. */\n moreSelected: (count: number) => string;\n /** Shown when a `Combobox` filter matches nothing. */\n noResults: string;\n /** Collapse button of the `Navbar`. */\n collapseNavbar: string;\n /** Expand button of a collapsed `Navbar`. */\n expandNavbar: string;\n /** `AppShell` mobile menu button, shown when there is no tab bar. */\n openNavigation: string;\n /** `AppShell` tab that opens the full navigation. */\n more: string;\n /** Accessible name of the `AppShell` mobile tab bar. */\n quickNavigation: string;\n /** Accessible name of the `AppShell` navigation drawer. */\n navigation: string;\n /** Close button of the `AppShell` navigation drawer. */\n closeNavigation: string;\n /** Texts of `Calendar` and `RangeCalendar`. */\n calendar: Partial<CalendarLabels>;\n /** Texts of `DatePicker`. */\n datePicker: Partial<DatePickerLabels>;\n /** Texts of `DateRangePicker`. */\n dateRangePicker: Partial<DateRangePickerLabels>;\n /** Texts of `Pagination`. */\n pagination: Partial<PaginationLabels>;\n /** Texts of `Stepper`. */\n stepper: Partial<StepperLabels>;\n /** Texts of `FileUpload`. */\n fileUpload: Partial<FileUploadLabels>;\n /** Texts of `DataTable`. */\n dataTable: Partial<DataTableLabels>;\n}\n\nconst defaultLabels: Labels = {\n close: 'Close',\n dismiss: 'Dismiss',\n cancel: 'Cancel',\n loading: 'Loading',\n selectPlaceholder: 'Select…',\n clearSearch: 'Clear search',\n showPassword: 'Show password',\n decrease: 'Decrease',\n increase: 'Increase',\n openList: 'Open list',\n clearSelection: 'Clear selection',\n removeItem: (label) => `Remove ${label}`,\n moreSelected: (count) => `${count} more selected`,\n noResults: 'No results found.',\n collapseNavbar: 'Collapse',\n expandNavbar: 'Expand',\n openNavigation: 'Open navigation',\n more: 'More',\n quickNavigation: 'Quick navigation',\n navigation: 'Navigation',\n closeNavigation: 'Close navigation',\n calendar: {},\n datePicker: {},\n dateRangePicker: {},\n pagination: {},\n stepper: {},\n fileUpload: {},\n dataTable: {},\n};\n\nconst nested = ['calendar', 'datePicker', 'dateRangePicker', 'pagination', 'stepper', 'fileUpload', 'dataTable'] as const;\n\nconst LabelsContext = React.createContext<Labels>(defaultLabels);\n\nexport interface LabelsProviderProps {\n /** Texts to replace. Nested providers override only what they pass; props on a component still win. */\n labels: Partial<Labels>;\n /** The subtree that uses these texts. */\n children?: React.ReactNode;\n}\n\n/**\n * Replaces the library's built-in English texts (button names, placeholders, table and calendar texts) for\n * everything inside it, so an app translates them once instead of per component.\n *\n * @example\n * <LabelsProvider labels={{ close: 'Bezárás', selectPlaceholder: 'Válasszon…', dataTable: { search: 'Keresés…' } }}>\n * <App />\n * </LabelsProvider>\n */\nexport function LabelsProvider({ labels, children }: LabelsProviderProps) {\n const parent = React.useContext(LabelsContext);\n const value: Labels = { ...parent, ...labels };\n for (const key of nested) value[key] = { ...parent[key], ...labels[key] } as never;\n return <LabelsContext value={value}>{children}</LabelsContext>;\n}\n\n/** The texts from the nearest `LabelsProvider`, with English defaults for the rest. */\nexport function useLabels(): Labels {\n return React.useContext(LabelsContext);\n}\n"],"mappings":";;;;;AAqEA,IAAMwC,gBAAwB;CAC5B/B,OAAO;CACPC,SAAS;CACTC,QAAQ;CACRC,SAAS;CACTC,mBAAmB;CACnBC,aAAa;CACbC,cAAc;CACdC,UAAU;CACVC,UAAU;CACVC,UAAU;CACVC,gBAAgB;CAChBC,aAAaC,UAAU,UAAUA;CACjCC,eAAeC,UAAU,GAAGA,MAAK;CACjCC,WAAW;CACXC,gBAAgB;CAChBC,cAAc;CACdC,gBAAgB;CAChBC,MAAM;CACNC,iBAAiB;CACjBC,YAAY;CACZC,iBAAiB;CACjBC,UAAU,CAAC;CACXE,YAAY,CAAC;CACbC,iBAAiB,CAAC;CAClBC,YAAY,CAAC;CACbC,SAAS,CAAC;CACVC,YAAY,CAAC;CACbC,WAAW,CAAC;AACd;AAEA,IAAME,SAAS;CAAC;CAAY;CAAc;CAAmB;CAAc;CAAW;CAAc;AAAW;AAE/G,IAAME,gBAAgB3C,MAAM4C,cAAsBJ,aAAa;;;;;;;;;;AAkB/D,SAAOS,eAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAwB,MAAA,EAAAN,QAAAC,aAAAG;CAC7B,MAAAG,SAAerD,MAAKsD,WAAYX,aAAa;CAAE,IAAAY;CAAA,IAAAJ,EAAA,OAAAL,UAAAK,EAAA,OAAAE,QAAA;EAC/CE,QAAsB;GAAA,GAAKF;GAAM,GAAKP;EAAO;EAC7C,KAAK,MAAAU,OAAaf,QAAQc,MAAMC,OAAO;GAAA,GAAKH,OAAOG;GAAI,GAAKV,OAAOU;EAAK;EAAWL,EAAA,KAAAL;EAAAK,EAAA,KAAAE;EAAAF,EAAA,KAAAI;CAAA,OAAAA,QAAAJ,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,OAAAJ,YAAAI,EAAA,OAAAI,OAAA;EAC5EE,KAAA,oBAAC,eAAD;GAAsBF;GAAQR;EAAhB,CAAA;EAAyCI,EAAA,KAAAJ;EAAAI,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OAAvDM;AAAuD;;AAIhE,SAAOC,YAAA;CAAA,OACE1D,MAAKsD,WAAYX,aAAa;AAAC"}
|