@jcsoftdev/ui 0.7.0 → 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 +51 -0
- package/README.md +9 -0
- package/dist/atoms/elapsed-time/elapsed-time.d.ts +29 -0
- package/dist/atoms/elapsed-time/elapsed-time.js +65 -0
- package/dist/atoms/elapsed-time/index.d.ts +2 -0
- package/dist/atoms/elapsed-time/index.js +9 -0
- package/dist/atoms/elapsed-time/model.d.ts +17 -0
- package/dist/atoms/elapsed-time/model.js +37 -0
- package/dist/atoms/elapsed-time/ticker.d.ts +5 -0
- package/dist/atoms/elapsed-time/ticker.js +37 -0
- package/dist/atoms/index.d.ts +2 -0
- package/dist/atoms/index.js +2 -0
- package/dist/atoms/table-glyph/index.d.ts +2 -0
- package/dist/atoms/table-glyph/index.js +14 -0
- package/dist/atoms/table-glyph/layout.d.ts +38 -0
- package/dist/atoms/table-glyph/layout.js +152 -0
- package/dist/atoms/table-glyph/table-glyph.d.ts +32 -0
- package/dist/atoms/table-glyph/table-glyph.js +131 -0
- package/dist/containers/floor-plan/edit-model.d.ts +33 -0
- package/dist/containers/floor-plan/edit-model.js +82 -0
- package/dist/containers/floor-plan/floor-plan.d.ts +83 -0
- package/dist/containers/floor-plan/floor-plan.js +278 -0
- package/dist/containers/floor-plan/index.d.ts +3 -0
- package/dist/containers/floor-plan/index.js +21 -0
- package/dist/containers/floor-plan/model.d.ts +36 -0
- package/dist/containers/floor-plan/model.js +52 -0
- package/dist/containers/floor-plan/use-floor-plan-edit.d.ts +26 -0
- package/dist/containers/floor-plan/use-floor-plan-edit.js +97 -0
- package/dist/containers/index.d.ts +1 -0
- package/dist/containers/index.js +1 -0
- package/dist/i18n/strings.d.ts +48 -0
- package/dist/i18n/strings.js +24 -0
- package/dist/shell/bottom-nav/bottom-nav.d.ts +5 -1
- package/dist/shell/bottom-nav/bottom-nav.js +52 -9
- package/package.json +2 -2
- package/src/atoms/elapsed-time/elapsed-time.tsx +101 -0
- package/src/atoms/elapsed-time/index.ts +6 -0
- package/src/atoms/elapsed-time/model.ts +54 -0
- package/src/atoms/elapsed-time/ticker.ts +39 -0
- package/src/atoms/index.ts +2 -0
- package/src/atoms/table-glyph/index.ts +14 -0
- package/src/atoms/table-glyph/layout.ts +187 -0
- package/src/atoms/table-glyph/table-glyph.tsx +161 -0
- package/src/containers/floor-plan/edit-model.ts +115 -0
- package/src/containers/floor-plan/floor-plan.tsx +393 -0
- package/src/containers/floor-plan/index.ts +20 -0
- package/src/containers/floor-plan/model.ts +81 -0
- package/src/containers/floor-plan/use-floor-plan-edit.ts +135 -0
- package/src/containers/index.ts +1 -0
- package/src/i18n/strings.ts +48 -0
- package/src/shell/bottom-nav/bottom-nav.tsx +78 -8
package/src/i18n/strings.ts
CHANGED
|
@@ -20,6 +20,30 @@ export interface UiStrings {
|
|
|
20
20
|
copy: string;
|
|
21
21
|
copied: string;
|
|
22
22
|
more: string;
|
|
23
|
+
/** Accessible total on the bottom bar "More" button; `{count}` is replaced. */
|
|
24
|
+
morePending: string;
|
|
25
|
+
/** Accessible text of an `ElapsedTime` at exactly one minute; `{count}` is replaced. */
|
|
26
|
+
elapsedMinutesOne: string;
|
|
27
|
+
/** Accessible text of an `ElapsedTime`; `{count}` is replaced. */
|
|
28
|
+
elapsedMinutes: string;
|
|
29
|
+
/** Visible text of an `ElapsedTime` with `format="minutes"`; `{count}` is replaced. */
|
|
30
|
+
minutesShort: string;
|
|
31
|
+
/** Accessible text of a countdown `ElapsedTime`; `{time}` is the remaining time. */
|
|
32
|
+
countdownLeft: string;
|
|
33
|
+
/** Accessible text of a countdown `ElapsedTime` past its target; `{time}` is the overrun. */
|
|
34
|
+
countdownOver: string;
|
|
35
|
+
/** Seat count of a floor plan table; `{count}` is replaced. */
|
|
36
|
+
seats: string;
|
|
37
|
+
/** Seat count of a one-seat floor plan table; `{count}` is replaced. */
|
|
38
|
+
seatsOne: string;
|
|
39
|
+
/** Screen-reader state of a floor plan item ringed as late. */
|
|
40
|
+
late: string;
|
|
41
|
+
/** Default accessible name of a `FloorPlan`. */
|
|
42
|
+
floorPlan: string;
|
|
43
|
+
/** Accessible name of the rotate button of an editable `FloorPlan` item. */
|
|
44
|
+
rotate: string;
|
|
45
|
+
/** Keyboard help of an editable `FloorPlan`. */
|
|
46
|
+
floorPlanEditHint: string;
|
|
23
47
|
remove: string;
|
|
24
48
|
noResults: string;
|
|
25
49
|
clear: string;
|
|
@@ -159,6 +183,18 @@ export const uiStrings = {
|
|
|
159
183
|
copy: "Copy",
|
|
160
184
|
copied: "Copied",
|
|
161
185
|
more: "More",
|
|
186
|
+
morePending: "{count} pending",
|
|
187
|
+
elapsedMinutesOne: "{count} minute",
|
|
188
|
+
elapsedMinutes: "{count} minutes",
|
|
189
|
+
minutesShort: "{count} min",
|
|
190
|
+
countdownLeft: "{time} left",
|
|
191
|
+
countdownOver: "{time} over",
|
|
192
|
+
seats: "{count} seats",
|
|
193
|
+
seatsOne: "{count} seat",
|
|
194
|
+
late: "Late",
|
|
195
|
+
floorPlan: "Floor plan",
|
|
196
|
+
rotate: "Rotate 90°",
|
|
197
|
+
floorPlanEditHint: "Alt with arrows moves, Alt and Shift with arrows resizes, R rotates.",
|
|
162
198
|
remove: "Remove",
|
|
163
199
|
noResults: "No results",
|
|
164
200
|
clear: "Clear",
|
|
@@ -248,6 +284,18 @@ export const uiStrings = {
|
|
|
248
284
|
copy: "Copiar",
|
|
249
285
|
copied: "Copiado",
|
|
250
286
|
more: "Más",
|
|
287
|
+
morePending: "{count} pendientes",
|
|
288
|
+
elapsedMinutesOne: "{count} minuto",
|
|
289
|
+
elapsedMinutes: "{count} minutos",
|
|
290
|
+
minutesShort: "{count} min",
|
|
291
|
+
countdownLeft: "faltan {time}",
|
|
292
|
+
countdownOver: "{time} de retraso",
|
|
293
|
+
seats: "{count} asientos",
|
|
294
|
+
seatsOne: "{count} asiento",
|
|
295
|
+
late: "Con retraso",
|
|
296
|
+
floorPlan: "Plano de sala",
|
|
297
|
+
rotate: "Girar 90°",
|
|
298
|
+
floorPlanEditHint: "Alt con flechas mueve, Alt y Mayús con flechas cambia el tamaño, R gira.",
|
|
251
299
|
remove: "Quitar",
|
|
252
300
|
noResults: "Sin resultados",
|
|
253
301
|
clear: "Limpiar",
|
|
@@ -36,6 +36,10 @@ export interface BottomNavProps {
|
|
|
36
36
|
maxSlots?: number;
|
|
37
37
|
/** Text of the "More" button and the drawer title. Defaults to the localized "More". */
|
|
38
38
|
moreLabel?: string;
|
|
39
|
+
/** Accessible text of the total on "More"; defaults to the localized "{count} pending". */
|
|
40
|
+
moreBadgeLabel?: (count: number) => string;
|
|
41
|
+
/** `count` (default) shows numeric badges as a count chip on the phone bar; `dot` keeps the small dot. */
|
|
42
|
+
badgeStyle?: "count" | "dot";
|
|
39
43
|
/** Pinned at the bottom of the "More" drawer, e.g. the account or a sign-out button. */
|
|
40
44
|
moreFooter?: ReactNode;
|
|
41
45
|
/** Link renderer; defaults to a plain anchor. */
|
|
@@ -45,6 +49,45 @@ export interface BottomNavProps {
|
|
|
45
49
|
classNames?: ClassNames<BottomNavPart>;
|
|
46
50
|
}
|
|
47
51
|
|
|
52
|
+
const BADGE_CAP = 99;
|
|
53
|
+
|
|
54
|
+
function numericBadge(badge: ReactNode): number | undefined {
|
|
55
|
+
if (typeof badge === "number") return Number.isFinite(badge) ? badge : undefined;
|
|
56
|
+
if (typeof badge === "string" && /^\s*\d+\s*$/.test(badge)) return Number(badge);
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function formatCount(count: number): string {
|
|
61
|
+
return count > BADGE_CAP ? `${BADGE_CAP}+` : String(count);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const dotClasses = "absolute -top-0.5 -right-1 size-2 rounded-pill";
|
|
65
|
+
|
|
66
|
+
const chipClasses =
|
|
67
|
+
"absolute -top-1.5 -right-2.5 inline-flex h-4 min-w-4 items-center justify-center rounded-pill px-1 font-bold text-count text-surface leading-none";
|
|
68
|
+
|
|
69
|
+
function BadgeMark({
|
|
70
|
+
count,
|
|
71
|
+
danger,
|
|
72
|
+
asDot,
|
|
73
|
+
className,
|
|
74
|
+
}: {
|
|
75
|
+
count: number | undefined;
|
|
76
|
+
danger: boolean;
|
|
77
|
+
asDot: boolean;
|
|
78
|
+
className?: string;
|
|
79
|
+
}) {
|
|
80
|
+
const tone = danger ? "bg-danger" : "bg-warning";
|
|
81
|
+
if (count === undefined || asDot) {
|
|
82
|
+
return <span aria-hidden="true" className={cn(dotClasses, tone, className)} />;
|
|
83
|
+
}
|
|
84
|
+
return (
|
|
85
|
+
<span aria-hidden="true" className={cn(chipClasses, tone, className)}>
|
|
86
|
+
{formatCount(count)}
|
|
87
|
+
</span>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
48
91
|
const defaultRenderLink: BottomNavRenderLink = ({ children, ...props }) => (
|
|
49
92
|
<a {...props}>{children}</a>
|
|
50
93
|
);
|
|
@@ -63,6 +106,8 @@ export function BottomNav({
|
|
|
63
106
|
ariaLabel,
|
|
64
107
|
maxSlots = BOTTOM_NAV_MAX_SLOTS,
|
|
65
108
|
moreLabel,
|
|
109
|
+
moreBadgeLabel,
|
|
110
|
+
badgeStyle = "count",
|
|
66
111
|
moreFooter,
|
|
67
112
|
renderLink = defaultRenderLink,
|
|
68
113
|
className,
|
|
@@ -73,6 +118,20 @@ export function BottomNav({
|
|
|
73
118
|
const { visible, overflow } = splitBottomNavItems(items, maxSlots);
|
|
74
119
|
const more = moreLabel ?? strings.more;
|
|
75
120
|
const moreActive = overflow.some((item) => item.active);
|
|
121
|
+
const badged = overflow.filter((item) => item.badge !== undefined);
|
|
122
|
+
const overflowCounts = badged.map((item) => numericBadge(item.badge));
|
|
123
|
+
const overflowTotal = overflowCounts.reduce<number | undefined>(
|
|
124
|
+
(sum, count) => (count === undefined ? sum : (sum ?? 0) + count),
|
|
125
|
+
undefined,
|
|
126
|
+
);
|
|
127
|
+
const overflowDanger = badged.some((item) => item.badgeTone === "danger");
|
|
128
|
+
const overflowBadgeText =
|
|
129
|
+
overflowTotal === undefined
|
|
130
|
+
? undefined
|
|
131
|
+
: (
|
|
132
|
+
moreBadgeLabel ??
|
|
133
|
+
((count: number) => strings.morePending.replace("{count}", String(count)))
|
|
134
|
+
)(overflowTotal);
|
|
76
135
|
|
|
77
136
|
return (
|
|
78
137
|
<>
|
|
@@ -102,13 +161,11 @@ export function BottomNav({
|
|
|
102
161
|
{item.icon}
|
|
103
162
|
{item.badge !== undefined ? (
|
|
104
163
|
<>
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
classNames?.badge,
|
|
111
|
-
)}
|
|
164
|
+
<BadgeMark
|
|
165
|
+
count={numericBadge(item.badge)}
|
|
166
|
+
danger={item.badgeTone === "danger"}
|
|
167
|
+
asDot={badgeStyle === "dot"}
|
|
168
|
+
className={classNames?.badge}
|
|
112
169
|
/>
|
|
113
170
|
<span className="sr-only">{item.badgeLabel ?? item.badge}</span>
|
|
114
171
|
</>
|
|
@@ -130,8 +187,21 @@ export function BottomNav({
|
|
|
130
187
|
onClick={() => setMoreOpen(true)}
|
|
131
188
|
className={cn(slotClasses, classNames?.moreButton)}
|
|
132
189
|
>
|
|
133
|
-
<
|
|
190
|
+
<span className="relative">
|
|
191
|
+
<Menu aria-hidden="true" />
|
|
192
|
+
{badged.length > 0 ? (
|
|
193
|
+
<BadgeMark
|
|
194
|
+
count={overflowTotal}
|
|
195
|
+
danger={overflowDanger}
|
|
196
|
+
asDot={badgeStyle === "dot"}
|
|
197
|
+
className={classNames?.badge}
|
|
198
|
+
/>
|
|
199
|
+
) : null}
|
|
200
|
+
</span>
|
|
134
201
|
<span>{more}</span>
|
|
202
|
+
{badged.length > 0 && overflowBadgeText ? (
|
|
203
|
+
<span className="sr-only">{overflowBadgeText}</span>
|
|
204
|
+
) : null}
|
|
135
205
|
</button>
|
|
136
206
|
</li>
|
|
137
207
|
) : null}
|