@olenbetong/appframe-ds 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.
Files changed (112) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +10 -10
  3. package/scripts/copyAssets.mjs +30 -0
  4. package/src/AfLookup/Combobox.tsx +16 -1
  5. package/src/AfLookup/Lookup.tsx +37 -6
  6. package/src/index.ts +3 -0
  7. package/src/layout/AppLayoutDesktop.tsx +3 -0
  8. package/src/layout/AppLayoutMobile.tsx +3 -0
  9. package/src/layout/AppMenu.css +1 -0
  10. package/src/layout/PageContainer.tsx +6 -0
  11. package/src/layout/index.tsx +5 -0
  12. package/src/list/ItemList.css +30 -0
  13. package/src/list/ItemList.tsx +52 -0
  14. package/src/list/ItemListItem.tsx +41 -0
  15. package/src/list/ItemListItemText.tsx +23 -0
  16. package/src/list/index.ts +3 -0
  17. package/src/page/Page.css +45 -0
  18. package/src/page/Page.tsx +70 -0
  19. package/src/page/PageBlock.css +59 -0
  20. package/src/page/PageBlock.tsx +78 -0
  21. package/src/page/PageHeader.css +148 -0
  22. package/src/page/PageHeader.tsx +184 -0
  23. package/src/page/index.ts +3 -0
  24. package/src/paper/Paper.css +35 -0
  25. package/src/paper/Paper.tsx +50 -0
  26. package/src/paper/index.ts +1 -0
  27. package/es/AfLookup/BoundLookup.d.ts +0 -10
  28. package/es/AfLookup/BoundLookup.js +0 -16
  29. package/es/AfLookup/Combobox.css +0 -78
  30. package/es/AfLookup/Combobox.d.ts +0 -31
  31. package/es/AfLookup/Combobox.js +0 -71
  32. package/es/AfLookup/Lookup.css +0 -125
  33. package/es/AfLookup/Lookup.d.ts +0 -35
  34. package/es/AfLookup/Lookup.js +0 -42
  35. package/es/AfLookup/LookupEdit.d.ts +0 -21
  36. package/es/AfLookup/LookupEdit.js +0 -49
  37. package/es/AfLookup/LookupGrid.css +0 -57
  38. package/es/AfLookup/LookupGrid.d.ts +0 -13
  39. package/es/AfLookup/LookupGrid.js +0 -27
  40. package/es/AfLookup/index.d.ts +0 -5
  41. package/es/AfLookup/index.js +0 -5
  42. package/es/binding/BoundCheckbox.d.ts +0 -9
  43. package/es/binding/BoundCheckbox.js +0 -13
  44. package/es/binding/BoundDatePicker.d.ts +0 -7
  45. package/es/binding/BoundDatePicker.js +0 -12
  46. package/es/binding/BoundDateTimePicker.d.ts +0 -7
  47. package/es/binding/BoundDateTimePicker.js +0 -14
  48. package/es/binding/BoundInput.d.ts +0 -6
  49. package/es/binding/BoundInput.js +0 -12
  50. package/es/binding/BoundNumericTextField.d.ts +0 -20
  51. package/es/binding/BoundNumericTextField.js +0 -58
  52. package/es/binding/BoundSelect.d.ts +0 -9
  53. package/es/binding/BoundSelect.js +0 -13
  54. package/es/binding/BoundSwitch.d.ts +0 -9
  55. package/es/binding/BoundSwitch.js +0 -13
  56. package/es/binding/BoundTextField.d.ts +0 -7
  57. package/es/binding/BoundTextField.js +0 -22
  58. package/es/binding/CancelButton.d.ts +0 -3
  59. package/es/binding/CancelButton.js +0 -14
  60. package/es/binding/CancelIconButton.d.ts +0 -2
  61. package/es/binding/CancelIconButton.js +0 -15
  62. package/es/binding/DataEditToolbar.d.ts +0 -13
  63. package/es/binding/DataEditToolbar.js +0 -28
  64. package/es/binding/DataObjectSelect.d.ts +0 -50
  65. package/es/binding/DataObjectSelect.js +0 -26
  66. package/es/binding/DeleteButton.d.ts +0 -8
  67. package/es/binding/DeleteButton.js +0 -14
  68. package/es/binding/DeleteIconButton.d.ts +0 -10
  69. package/es/binding/DeleteIconButton.js +0 -15
  70. package/es/binding/RefreshButton.d.ts +0 -3
  71. package/es/binding/RefreshButton.js +0 -14
  72. package/es/binding/RefreshIconButton.d.ts +0 -2
  73. package/es/binding/RefreshIconButton.js +0 -16
  74. package/es/binding/RefreshRowIconButton.d.ts +0 -7
  75. package/es/binding/RefreshRowIconButton.js +0 -15
  76. package/es/binding/SaveButton.d.ts +0 -3
  77. package/es/binding/SaveButton.js +0 -14
  78. package/es/binding/SaveIconButton.d.ts +0 -2
  79. package/es/binding/SaveIconButton.js +0 -15
  80. package/es/binding/index.d.ts +0 -19
  81. package/es/binding/index.js +0 -19
  82. package/es/index.d.ts +0 -3
  83. package/es/index.js +0 -3
  84. package/es/layout/AppLayoutDesktop.css +0 -65
  85. package/es/layout/AppLayoutDesktop.d.ts +0 -3
  86. package/es/layout/AppLayoutDesktop.js +0 -19
  87. package/es/layout/AppLayoutMobile.css +0 -75
  88. package/es/layout/AppLayoutMobile.d.ts +0 -3
  89. package/es/layout/AppLayoutMobile.js +0 -18
  90. package/es/layout/AppMenu.css +0 -67
  91. package/es/layout/AppMenu.d.ts +0 -8
  92. package/es/layout/AppMenu.js +0 -36
  93. package/es/layout/AppMenuItem.css +0 -97
  94. package/es/layout/AppMenuItem.d.ts +0 -50
  95. package/es/layout/AppMenuItem.js +0 -14
  96. package/es/layout/AppMenuSubheader.css +0 -18
  97. package/es/layout/AppMenuSubheader.d.ts +0 -4
  98. package/es/layout/AppMenuSubheader.js +0 -6
  99. package/es/layout/ErrorBoundary.css +0 -101
  100. package/es/layout/ErrorBoundary.d.ts +0 -30
  101. package/es/layout/ErrorBoundary.js +0 -81
  102. package/es/layout/PageContainer.css +0 -29
  103. package/es/layout/PageContainer.d.ts +0 -7
  104. package/es/layout/PageContainer.js +0 -6
  105. package/es/layout/PartnerToggle.d.ts +0 -5
  106. package/es/layout/PartnerToggle.js +0 -9
  107. package/es/layout/constants.d.ts +0 -2
  108. package/es/layout/constants.js +0 -2
  109. package/es/layout/index.css +0 -65
  110. package/es/layout/index.d.ts +0 -33
  111. package/es/layout/index.js +0 -31
  112. package/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,78 @@
1
+ import "./PageBlock.css";
2
+
3
+ import clsx from "clsx";
4
+ import type React from "react";
5
+
6
+ export const pageBlockWidths = ["text", "md", "lg", "xl", "2xl"] as const;
7
+
8
+ export type PageBlockWidth = (typeof pageBlockWidths)[number];
9
+
10
+ export type PageBlockProps = React.HTMLAttributes<HTMLElement> & {
11
+ /**
12
+ * Overrides the rendered element (e.g. `"main"`, `"header"`, `"footer"`)
13
+ * @default "div"
14
+ */
15
+ as?: React.ElementType;
16
+ children?: React.ReactNode;
17
+ /**
18
+ * Fills the remaining space of the parent `Page`. Combine with
19
+ * `overflow="auto"` inside `<Page layout="app">` to make the block the
20
+ * scroll container.
21
+ * @default false
22
+ */
23
+ grow?: boolean;
24
+ /**
25
+ * Adds a standardised responsive inline padding
26
+ * @default false
27
+ */
28
+ gutters?: boolean;
29
+ /**
30
+ * Overflow behaviour of the block. Only relevant inside
31
+ * `<Page layout="app">`, where scrolling is delegated down the tree.
32
+ */
33
+ overflow?: "auto" | "hidden";
34
+ /**
35
+ * Predefined max-width. Content is horizontally centered.
36
+ *
37
+ * - `text`: 36rem (576px) — recommended line-length for running text
38
+ * - `md`: 48rem (768px)
39
+ * - `lg`: 64rem (1024px)
40
+ * - `xl`: 80rem (1280px)
41
+ * - `2xl`: 90rem (1440px)
42
+ *
43
+ * @default max-width: 100%
44
+ */
45
+ width?: PageBlockWidth;
46
+ };
47
+
48
+ /**
49
+ * Layout block for defining max-width, gutters and horizontal centering.
50
+ * Replaces the deprecated `PageContainer` (`maxWidth` mapping: `xs`/`sm` →
51
+ * `text`, `md` → `md`, `lg` → `lg`, `xl` → `xl`, `false` → no `width`).
52
+ */
53
+ export function PageBlock({
54
+ as: Component = "div",
55
+ children,
56
+ className,
57
+ grow,
58
+ gutters,
59
+ overflow,
60
+ width,
61
+ ...props
62
+ }: PageBlockProps) {
63
+ return (
64
+ <Component
65
+ className={clsx(
66
+ "ObPageBlock-root",
67
+ width && `ObPageBlock-${width}`,
68
+ gutters && "ObPageBlock-gutters",
69
+ grow && "ObPageBlock-grow",
70
+ overflow && `ObPageBlock-overflow${overflow === "auto" ? "Auto" : "Hidden"}`,
71
+ className,
72
+ )}
73
+ {...props}
74
+ >
75
+ {children}
76
+ </Component>
77
+ );
78
+ }
@@ -0,0 +1,148 @@
1
+ .ObPageHeader-root {
2
+ flex: 0 0 auto;
3
+ }
4
+
5
+ /* --- appbar variant --- */
6
+
7
+ .ObPageHeader-appbar {
8
+ background-color: var(--ds-color-brand-base-default, #0062ba);
9
+ color: var(--ds-color-brand-base-contrast-default, #fff);
10
+ }
11
+
12
+ .ObPageHeader-appbar .ObPageHeader-bar {
13
+ display: flex;
14
+ align-items: center;
15
+ gap: 0.5rem;
16
+ min-height: var(--ob-page-appbar-height, 3.5rem);
17
+ padding-inline: 0.5rem 1rem;
18
+ }
19
+
20
+ .ObPageHeader-title {
21
+ flex: 1 1 auto;
22
+ margin: 0;
23
+ font-size: var(--ds-font-size-lg, 1.25rem);
24
+ font-weight: 500;
25
+ overflow: hidden;
26
+ text-overflow: ellipsis;
27
+ white-space: nowrap;
28
+ }
29
+
30
+ .ObPageHeader-actions {
31
+ display: flex;
32
+ align-items: center;
33
+ gap: 0.5rem;
34
+ margin-left: auto;
35
+ }
36
+
37
+ .ObPageHeader-title + .ObPageHeader-actions {
38
+ margin-left: 0;
39
+ }
40
+
41
+ .ObPageHeader-toggle {
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ background: transparent;
46
+ border: none;
47
+ color: inherit;
48
+ cursor: pointer;
49
+ border-radius: 50%;
50
+ height: 2.75rem;
51
+ width: 2.75rem;
52
+ font-size: 1.5rem;
53
+ flex-shrink: 0;
54
+ }
55
+
56
+ .ObPageHeader-toggle:hover {
57
+ background-color: rgb(255 255 255 / 0.12);
58
+ }
59
+
60
+ /* --- plain variant --- */
61
+
62
+ .ObPageHeader-plainInner {
63
+ display: flex;
64
+ align-items: center;
65
+ gap: 0.5rem;
66
+ }
67
+
68
+ .ObPageHeader-plainTitle {
69
+ margin: 0;
70
+ font-size: var(--ds-font-size-xl, 1.5rem);
71
+ font-weight: 500;
72
+ }
73
+
74
+ /*
75
+ * Reserved slot for the app-launcher and user profile menu in the future
76
+ * sidebar-free site layout. Hidden under the current sidebar layout; the
77
+ * activation mechanism is decided together with the new website template.
78
+ */
79
+ .ObPageHeader-end {
80
+ display: none;
81
+ }
82
+
83
+ /* --- drawer --- */
84
+
85
+ @media screen {
86
+ .ObPageHeader-drawer {
87
+ position: fixed;
88
+ top: 0;
89
+ left: 0;
90
+ bottom: 0;
91
+ width: var(--ob-page-drawer-width, 20rem);
92
+ max-width: 90%;
93
+ box-sizing: border-box;
94
+ background-color: var(--ds-color-neutral-background-default, #fff);
95
+ color: var(--ds-color-neutral-text-default, #1e2b3c);
96
+ transform: translateX(-100%);
97
+ transition: transform 225ms cubic-bezier(0, 0, 0.2, 1);
98
+ overflow: hidden;
99
+ display: flex;
100
+ flex-direction: column;
101
+ }
102
+
103
+ .ObPageHeader-drawer > .MenuItems-root {
104
+ flex: 1 1 auto;
105
+ min-height: 0;
106
+ }
107
+
108
+ .ObPageHeader-drawer.ObPageHeader-drawerOpen {
109
+ transform: translateX(0);
110
+ }
111
+
112
+ .ObPageHeader-drawerDocked {
113
+ border-right: 1px solid var(--ds-color-neutral-border-subtle, #dfdfdf);
114
+ z-index: 1100;
115
+ }
116
+
117
+ .ObPageHeader-drawerOverlayMode {
118
+ z-index: 1200;
119
+ box-shadow:
120
+ rgb(0 0 0 / 20%) 0px 8px 10px -5px,
121
+ rgb(0 0 0 / 14%) 0px 16px 24px 2px,
122
+ rgb(0 0 0 / 12%) 0px 6px 30px 5px;
123
+ }
124
+
125
+ .ObPageHeader-drawerOverlay {
126
+ position: fixed;
127
+ inset: 0;
128
+ background-color: rgb(0 0 0 / 50%);
129
+ z-index: 1199;
130
+ opacity: 0;
131
+ pointer-events: none;
132
+ transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1);
133
+ }
134
+
135
+ .ObPageHeader-drawerOverlay.ObPageHeader-drawerOpen {
136
+ opacity: 1;
137
+ pointer-events: auto;
138
+ }
139
+ }
140
+
141
+ @media print {
142
+ .ObPageHeader-appbar .ObPageHeader-bar,
143
+ .ObPageHeader-drawer,
144
+ .ObPageHeader-drawerOverlay,
145
+ .ObPageHeader-toggle {
146
+ display: none !important;
147
+ }
148
+ }
@@ -0,0 +1,184 @@
1
+ import "./PageHeader.css";
2
+
3
+ import { getLocalizedString } from "@olenbetong/appframe-core";
4
+
5
+ import clsx from "clsx";
6
+ import type React from "react";
7
+ import { useEffect, useRef, useState } from "react";
8
+ import { useLocation } from "react-router";
9
+
10
+ import { AppMenu, type AppMenuProps } from "../layout/AppMenu.js";
11
+ import { PageBlock, type PageBlockWidth } from "./PageBlock.js";
12
+
13
+ export type PageHeaderVariant = "appbar" | "plain";
14
+
15
+ export type PageHeaderProps = Omit<React.HTMLAttributes<HTMLElement>, "title"> & {
16
+ /**
17
+ * Actions displayed at the end of the header (buttons, search, etc.)
18
+ */
19
+ actions?: React.ReactNode;
20
+ /**
21
+ * Props passed to the `AppMenu` wrapping the `menu` content
22
+ */
23
+ AppMenuProps?: AppMenuProps;
24
+ children?: React.ReactNode;
25
+ /**
26
+ * App menu (navigation) content. When provided, the `appbar` variant
27
+ * renders a menu toggle button and a drawer hosting the menu — docked on
28
+ * desktop (≥1200px), overlay on smaller screens.
29
+ */
30
+ menu?: React.ReactNode;
31
+ /**
32
+ * Application title
33
+ */
34
+ title?: React.ReactNode;
35
+ /**
36
+ * Adds a standardised responsive inline padding to the header content.
37
+ * See `Page.Block`.
38
+ * @default false
39
+ */
40
+ gutters?: boolean;
41
+ /**
42
+ * Constrains and centers the header content to a predefined max-width,
43
+ * so it can align with a `Page.Block` of the same width. See `Page.Block`.
44
+ */
45
+ width?: PageBlockWidth;
46
+ /**
47
+ * - `"appbar"` (default): a top app bar with menu toggle, title and
48
+ * actions. For apps that have an app menu.
49
+ * - `"plain"`: no app bar chrome — for simple apps without an app menu
50
+ * (e.g. report-issue). Renders the title as a regular heading block.
51
+ *
52
+ * Both variants reserve an end-slot (`.ObPageHeader-end`) that will host
53
+ * the app-launcher and user profile menu in the future sidebar-free site
54
+ * layout. It is hidden under the current sidebar layout.
55
+ * @default "appbar"
56
+ */
57
+ variant?: PageHeaderVariant;
58
+ };
59
+
60
+ function useIsMobile() {
61
+ let [isMobile, setIsMobile] = useState(() => {
62
+ if (typeof window === "undefined") return false;
63
+ return window.matchMedia("(max-width: 1199px)").matches;
64
+ });
65
+
66
+ useEffect(() => {
67
+ let mq = window.matchMedia("(max-width: 1199px)");
68
+ let handler = (e: MediaQueryListEvent) => setIsMobile(e.matches);
69
+ mq.addEventListener("change", handler);
70
+ return () => mq.removeEventListener("change", handler);
71
+ }, []);
72
+
73
+ return isMobile;
74
+ }
75
+
76
+ type PageHeaderDrawerProps = {
77
+ AppMenuProps?: AppMenuProps;
78
+ menu: React.ReactNode;
79
+ onClose: () => void;
80
+ isMobile: boolean;
81
+ open: boolean;
82
+ };
83
+
84
+ function PageHeaderDrawer({ AppMenuProps, menu, onClose, isMobile, open }: PageHeaderDrawerProps) {
85
+ let location = useLocation();
86
+ let prevLocation = useRef(location);
87
+
88
+ useEffect(() => {
89
+ if (location !== prevLocation.current) {
90
+ prevLocation.current = location;
91
+ if (isMobile) onClose();
92
+ }
93
+ }, [location, isMobile, onClose]);
94
+
95
+ return (
96
+ <>
97
+ {isMobile && (
98
+ <div
99
+ className={clsx("ObPageHeader-drawerOverlay", open && "ObPageHeader-drawerOpen")}
100
+ onClick={onClose}
101
+ aria-hidden="true"
102
+ />
103
+ )}
104
+ <div
105
+ className={clsx(
106
+ "ObPageHeader-drawer",
107
+ "AppMenu-drawer",
108
+ isMobile ? "ObPageHeader-drawerOverlayMode" : "ObPageHeader-drawerDocked",
109
+ open && "ObPageHeader-drawerOpen",
110
+ )}
111
+ >
112
+ <AppMenu {...AppMenuProps}>{menu}</AppMenu>
113
+ </div>
114
+ </>
115
+ );
116
+ }
117
+
118
+ /**
119
+ * Page header for use inside `Page`. See the `variant` prop for the two
120
+ * supported header styles.
121
+ */
122
+ export function PageHeader({
123
+ actions,
124
+ AppMenuProps,
125
+ children,
126
+ className,
127
+ gutters,
128
+ menu,
129
+ title,
130
+ variant = "appbar",
131
+ width,
132
+ ...props
133
+ }: PageHeaderProps) {
134
+ let isMobile = useIsMobile();
135
+ let [desktopOpen, setDesktopOpen] = useState(true);
136
+ let [mobileOpen, setMobileOpen] = useState(false);
137
+
138
+ let open = isMobile ? mobileOpen : desktopOpen;
139
+ let toggle = () => (isMobile ? setMobileOpen((o) => !o) : setDesktopOpen((o) => !o));
140
+
141
+ if (variant === "plain") {
142
+ return (
143
+ <header className={clsx("ObPageHeader-root", "ObPageHeader-plain", className)} {...props}>
144
+ <PageBlock className="ObPageHeader-plainInner" width={width} gutters={gutters}>
145
+ {title && <h1 className="ObPageHeader-plainTitle">{title}</h1>}
146
+ {actions && <div className="ObPageHeader-actions">{actions}</div>}
147
+ {children}
148
+ <div className="ObPageHeader-end" />
149
+ </PageBlock>
150
+ </header>
151
+ );
152
+ }
153
+
154
+ return (
155
+ <header className={clsx("ObPageHeader-root", "ObPageHeader-appbar", className)} {...props}>
156
+ <PageBlock className="ObPageHeader-bar" width={width} gutters={gutters}>
157
+ {menu && (
158
+ <button
159
+ type="button"
160
+ className="ObPageHeader-toggle"
161
+ onClick={toggle}
162
+ aria-label={getLocalizedString("Toggle menu")}
163
+ aria-expanded={open}
164
+ >
165
+
166
+ </button>
167
+ )}
168
+ {title && <h1 className="ObPageHeader-title">{title}</h1>}
169
+ {actions && <div className="ObPageHeader-actions">{actions}</div>}
170
+ <div className="ObPageHeader-end" />
171
+ </PageBlock>
172
+ {children}
173
+ {menu && (
174
+ <PageHeaderDrawer
175
+ AppMenuProps={AppMenuProps}
176
+ menu={menu}
177
+ onClose={() => setMobileOpen(false)}
178
+ isMobile={isMobile}
179
+ open={open}
180
+ />
181
+ )}
182
+ </header>
183
+ );
184
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Page.js";
2
+ export * from "./PageBlock.js";
3
+ export * from "./PageHeader.js";
@@ -0,0 +1,35 @@
1
+ .ObPaper-root {
2
+ background-color: var(--ds-color-neutral-surface-default, #fff);
3
+ color: var(--ds-color-neutral-text-default, #1e2b3c);
4
+ border-radius: var(--ds-border-radius-md, 0.375rem);
5
+ }
6
+
7
+ .ObPaper-shadow-xs {
8
+ box-shadow: var(--ds-shadow-xs);
9
+ }
10
+
11
+ .ObPaper-shadow-sm {
12
+ box-shadow: var(--ds-shadow-sm);
13
+ }
14
+
15
+ .ObPaper-shadow-md {
16
+ box-shadow: var(--ds-shadow-md);
17
+ }
18
+
19
+ .ObPaper-shadow-lg {
20
+ box-shadow: var(--ds-shadow-lg);
21
+ }
22
+
23
+ .ObPaper-shadow-xl {
24
+ box-shadow: var(--ds-shadow-xl);
25
+ }
26
+
27
+ .ObPaper-border {
28
+ border: var(--ds-border-width-default, 1px) solid var(--ds-color-neutral-border-subtle, #dfdfdf);
29
+ }
30
+
31
+ @media print {
32
+ .ObPaper-root {
33
+ box-shadow: none;
34
+ }
35
+ }
@@ -0,0 +1,50 @@
1
+ import "./Paper.css";
2
+
3
+ import clsx from "clsx";
4
+ import type React from "react";
5
+
6
+ export const paperShadows = ["none", "xs", "sm", "md", "lg", "xl"] as const;
7
+
8
+ export type PaperShadow = (typeof paperShadows)[number];
9
+
10
+ export type PaperProps = React.HTMLAttributes<HTMLElement> & {
11
+ /**
12
+ * Overrides the rendered element (e.g. `"section"`, `"ul"`)
13
+ * @default "div"
14
+ */
15
+ as?: React.ElementType;
16
+ /**
17
+ * Adds a subtle border. Combine with `shadow="none"` for an outlined
18
+ * variant (MUI `variant="outlined"` equivalent).
19
+ * @default false
20
+ */
21
+ border?: boolean;
22
+ children?: React.ReactNode;
23
+ /**
24
+ * Elevation shadow, using the designsystemet `--ds-shadow-*` tokens.
25
+ * @default "sm"
26
+ */
27
+ shadow?: PaperShadow;
28
+ };
29
+
30
+ /**
31
+ * Surface component equivalent to MUI `Paper`: a neutral surface with
32
+ * rounded corners and an elevation shadow. Use it instead of hand-rolled
33
+ * `background` + `box-shadow` CSS so surfaces stay consistent with the
34
+ * designsystemet tokens (and adapt to dark mode).
35
+ */
36
+ export function Paper({ as: Component = "div", border, children, className, shadow = "sm", ...props }: PaperProps) {
37
+ return (
38
+ <Component
39
+ className={clsx(
40
+ "ObPaper-root",
41
+ shadow !== "none" && `ObPaper-shadow-${shadow}`,
42
+ border && "ObPaper-border",
43
+ className,
44
+ )}
45
+ {...props}
46
+ >
47
+ {children}
48
+ </Component>
49
+ );
50
+ }
@@ -0,0 +1 @@
1
+ export * from "./Paper.js";
@@ -1,10 +0,0 @@
1
- import type { CurrentRow, DataObject } from "@olenbetong/appframe-data";
2
- import { type DistributiveOmit } from "@olenbetong/appframe-react";
3
- import { type AfLookupProps } from "./Lookup.js";
4
- export type BoundLookupProps<TBoundData extends Record<string, unknown>, TLookupData extends Record<string, unknown>> = DistributiveOmit<AfLookupProps<TLookupData>, "onChange"> & {
5
- dataObject: DataObject<TLookupData>;
6
- displayField?: keyof TBoundData;
7
- getChanges: (selectedItem: TLookupData | null) => Partial<TBoundData>;
8
- getDisplayValue?: (currentRow: CurrentRow<TBoundData>) => string;
9
- };
10
- export declare function BoundLookup<TBoundData extends Record<string, unknown>, TLookupData extends Record<string, unknown> = any>({ dataObject, displayField, getChanges, getDisplayValue, ...props }: BoundLookupProps<TBoundData, TLookupData>): import("react").JSX.Element;
@@ -1,16 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useCurrentRow, useDataObject } from "@olenbetong/appframe-react";
3
- import { AfLookup } from "./Lookup.js";
4
- export function BoundLookup({ dataObject, displayField, getChanges, getDisplayValue, ...props }) {
5
- let boundDataObject = useDataObject();
6
- let row = useCurrentRow(boundDataObject);
7
- function handleChange(item) {
8
- let changes = getChanges(item);
9
- for (let key in changes) {
10
- let newValue = changes[key];
11
- boundDataObject.currentRow(key, newValue);
12
- }
13
- }
14
- let displayValue = getDisplayValue ? getDisplayValue(row) : displayField ? String(row[displayField] ?? "") : "";
15
- return _jsx(AfLookup, { dataObject: dataObject, value: displayValue, onChange: handleChange, ...props });
16
- }
@@ -1,78 +0,0 @@
1
- .ObCombobox-root {
2
- height: 100%;
3
- display: grid;
4
- grid-template-rows: min-content auto 1fr;
5
- gap: 0.5rem;
6
-
7
- overscroll-behavior: contain;
8
- }
9
-
10
- .ObCombobox-actions {
11
- display: flex;
12
- justify-content: space-between;
13
- }
14
-
15
- .ObCombobox-listWrap {
16
- overflow: hidden;
17
- min-height: 0;
18
- border: 1px solid rgb(0 0 0 / 0.12);
19
- border-radius: 0.25rem;
20
- background-color: white;
21
- }
22
-
23
- .ObCombobox-list {
24
- border: 1px solid rgb(0 0 0 / 0.06);
25
- height: 100%;
26
- overflow-y: hidden;
27
- overscroll-behavior: contain;
28
- list-style: none;
29
- margin: 0;
30
- padding: 0;
31
- }
32
-
33
- .ObCombobox-input {
34
- background-color: white;
35
- }
36
-
37
- .ObCombobox-listItem {
38
- --active-color: oklch(from var(--brand-secondary, #999) l c h / 50%);
39
- cursor: pointer;
40
-
41
- &.active {
42
- background-color: var(--active-color);
43
- }
44
-
45
- &:hover {
46
- background-color: rgb(0 0 0 / 0.06);
47
- }
48
-
49
- &.active:hover {
50
- background-color: oklch(from var(--active-color) calc(l + 0.1) calc(c - 0.04) h);
51
- }
52
- }
53
-
54
- .ObCombobox-progress {
55
- position: relative;
56
- height: 4px;
57
- overflow: hidden;
58
- background-color: rgb(0 0 0 / 0.08);
59
- }
60
-
61
- .ObCombobox-progress-bar {
62
- position: absolute;
63
- top: 0;
64
- left: -100%;
65
- height: 100%;
66
- width: 50%;
67
- background-color: var(--ds-color-accent-base-default, #0062ba);
68
- animation: ObCombobox-progress-anim 1.5s ease-in-out infinite;
69
- }
70
-
71
- @keyframes ObCombobox-progress-anim {
72
- 0% {
73
- left: -100%;
74
- }
75
- 100% {
76
- left: 200%;
77
- }
78
- }
@@ -1,31 +0,0 @@
1
- import "./Combobox.css";
2
- import type { DataObject } from "@olenbetong/appframe-data";
3
- import { type LookupColumn } from "@olenbetong/appframe-react";
4
- export interface ComboboxBaseProps<T extends Record<string, unknown>> {
5
- nullable?: boolean;
6
- dataObject: DataObject<T>;
7
- uniqueIdField?: string;
8
- isItemSelected?: (item: T) => boolean;
9
- onChange?: (item: T | null) => void;
10
- value?: T;
11
- onClose?: () => void;
12
- }
13
- export interface ComboboxListProps<T extends Record<string, unknown>> extends ComboboxBaseProps<T> {
14
- /**
15
- * Renders the popup content as a list (default).
16
- */
17
- variant?: "list";
18
- renderItem: (props: React.ComponentPropsWithRef<"li"> & {
19
- item: T;
20
- }) => React.ReactNode;
21
- }
22
- export interface ComboboxGridProps<T extends Record<string, unknown>> extends ComboboxBaseProps<T> {
23
- /**
24
- * Renders the popup content as a grid with a header row and one column per
25
- * entry in `columns`.
26
- */
27
- variant: "grid";
28
- columns: LookupColumn<T>[];
29
- }
30
- export type ComboboxProps<T extends Record<string, unknown>> = ComboboxListProps<T> | ComboboxGridProps<T>;
31
- export declare function Combobox<T extends Record<string, unknown>>(props: ComboboxProps<T>): import("react").JSX.Element;