@knkcs/anker 1.10.0 → 1.10.2
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/atoms/index.d.ts +2 -0
- package/dist/atoms/index.js +2 -2
- package/dist/{chunk-ELQTHWXC.js → chunk-ETY43HAI.js} +10 -6
- package/dist/chunk-ETY43HAI.js.map +1 -0
- package/dist/components/index.d.ts +53 -1
- package/dist/components/index.js +77 -6
- package/dist/components/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ELQTHWXC.js.map +0 -1
package/dist/atoms/index.d.ts
CHANGED
|
@@ -556,6 +556,8 @@ interface StatusBadgeProps {
|
|
|
556
556
|
label: string;
|
|
557
557
|
/** The background color for the badge (hex format, e.g. "#ff0000") */
|
|
558
558
|
color: string;
|
|
559
|
+
/** Optional icon rendered inline before the label inside the badge. */
|
|
560
|
+
icon?: React__default.ReactNode;
|
|
559
561
|
}
|
|
560
562
|
declare const StatusBadge: React__default.FC<StatusBadgeProps>;
|
|
561
563
|
|
package/dist/atoms/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Prose } from '../chunk-VOGT33LU.js';
|
|
2
|
-
import { formatRelativeToCurrentWeekDateTime, formatRelativeDateTime } from '../chunk-
|
|
3
|
-
export { StatusBadge, formatRelativeDateTime, formatRelativeToCurrentWeekDateTime } from '../chunk-
|
|
2
|
+
import { formatRelativeToCurrentWeekDateTime, formatRelativeDateTime } from '../chunk-ETY43HAI.js';
|
|
3
|
+
export { StatusBadge, formatRelativeDateTime, formatRelativeToCurrentWeekDateTime } from '../chunk-ETY43HAI.js';
|
|
4
4
|
import { Tooltip, Avatar, Table, MenuRoot, MenuTrigger, MenuContent, MenuItem, Badge } from '../chunk-2ZWZ2WAS.js';
|
|
5
5
|
export { SearchInput } from '../chunk-E7KRPPCQ.js';
|
|
6
6
|
import { Textarea } from '../chunk-NFZMG6ZL.js';
|
|
@@ -5,7 +5,7 @@ import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
|
5
5
|
import utcPlugin from 'dayjs/plugin/utc.js';
|
|
6
6
|
import { readableColor } from 'color2k';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { jsxs } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
10
|
dayjs.extend(utcPlugin);
|
|
11
11
|
dayjs.extend(relativeTime);
|
|
@@ -23,7 +23,7 @@ function formatRelativeToCurrentWeekDateTime(date, baseDate = /* @__PURE__ */ ne
|
|
|
23
23
|
return formatRelativeDateTime(date, baseDate);
|
|
24
24
|
}
|
|
25
25
|
var StatusBadge = (props) => {
|
|
26
|
-
const { label, color } = props;
|
|
26
|
+
const { label, color, icon } = props;
|
|
27
27
|
const textColor = useMemo(() => {
|
|
28
28
|
try {
|
|
29
29
|
return readableColor(color);
|
|
@@ -31,7 +31,7 @@ var StatusBadge = (props) => {
|
|
|
31
31
|
return "black";
|
|
32
32
|
}
|
|
33
33
|
}, [color]);
|
|
34
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ jsxs(
|
|
35
35
|
Badge,
|
|
36
36
|
{
|
|
37
37
|
bg: color,
|
|
@@ -39,12 +39,16 @@ var StatusBadge = (props) => {
|
|
|
39
39
|
rounded: "base",
|
|
40
40
|
px: 2,
|
|
41
41
|
marginInlineStart: 1,
|
|
42
|
-
|
|
42
|
+
gap: 1,
|
|
43
|
+
children: [
|
|
44
|
+
icon,
|
|
45
|
+
label
|
|
46
|
+
]
|
|
43
47
|
}
|
|
44
48
|
);
|
|
45
49
|
};
|
|
46
50
|
StatusBadge.displayName = "StatusBadge";
|
|
47
51
|
|
|
48
52
|
export { StatusBadge, formatRelativeDateTime, formatRelativeToCurrentWeekDateTime };
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-ETY43HAI.js.map
|
|
54
|
+
//# sourceMappingURL=chunk-ETY43HAI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/atoms/datetime/utils/relative-date-time-utils.ts","../src/atoms/status-badge/status-badge.tsx"],"names":[],"mappings":";;;;;;;;;AAKA,KAAA,CAAM,OAAO,SAAS,CAAA;AACtB,KAAA,CAAM,OAAO,YAAY,CAAA;AACzB,KAAA,CAAM,OAAO,cAAc,CAAA;AAmBpB,SAAS,sBAAA,CACf,IAAA,EACA,QAAA,mBAAqB,IAAI,MAAK,EAC7B;AACD,EAAA,OAAO,KAAA,CAAM,IAAI,CAAA,CAAE,IAAA,CAAK,QAAQ,CAAA;AACjC;AAmBO,SAAS,mCAAA,CACf,IAAA,EACA,QAAA,mBAAqB,IAAI,MAAK,EAC7B;AACD,EAAA,MAAM,UAAU,KAAA,CAAM,IAAI,CAAA,CAAE,MAAA,CAAO,UAAU,KAAK,CAAA;AAElD,EAAA,IAAI,CAAC,OAAA,EAAS;AAGb,IAAA,OAAO,KAAA,CAAM,IAAI,CAAA,CAAE,QAAA,CAAS,QAAA,EAAU;AAAA,MACrC,QAAA,EAAU;AAAA,KACV,CAAA;AAAA,EACF;AAGA,EAAA,OAAO,sBAAA,CAAuB,MAAM,QAAQ,CAAA;AAC7C;ACpDO,IAAM,WAAA,GAA0C,CAAC,KAAA,KAAU;AACjE,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAO,IAAA,EAAK,GAAI,KAAA;AAE/B,EAAA,MAAM,SAAA,GAAY,QAAQ,MAAM;AAC/B,IAAA,IAAI;AACH,MAAA,OAAO,cAAc,KAAK,CAAA;AAAA,IAC3B,CAAA,CAAA,MAAQ;AACP,MAAA,OAAO,OAAA;AAAA,IACR;AAAA,EACD,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAA,uBACC,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACA,EAAA,EAAI,KAAA;AAAA,MACJ,KAAA,EAAO,SAAA;AAAA,MACP,OAAA,EAAQ,MAAA;AAAA,MACR,EAAA,EAAI,CAAA;AAAA,MACJ,iBAAA,EAAmB,CAAA;AAAA,MACnB,GAAA,EAAK,CAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,QAAA,IAAA;AAAA,QACA;AAAA;AAAA;AAAA,GACF;AAEF;AAEA,WAAA,CAAY,WAAA,GAAc,aAAA","file":"chunk-ETY43HAI.js","sourcesContent":["import dayjs from \"dayjs\";\nimport calendarPlugin from \"dayjs/plugin/calendar.js\";\nimport relativeTime from \"dayjs/plugin/relativeTime.js\";\nimport utcPlugin from \"dayjs/plugin/utc.js\";\n\ndayjs.extend(utcPlugin);\ndayjs.extend(relativeTime);\ndayjs.extend(calendarPlugin);\n\nimport type { DateType } from \"../types\";\n\n/**\n * A function that will return a string with how far a given date is in the past or future,\n * using a baseDate as reference. If the baseDate is not passed, the function will use today as reference.\n *\n * @param date - the date to be formatted\n * @param baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeDateTime('2021-08-17T15:45:00') // returns \"a day ago\"\n *\n * @example\n * formatRelativeDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"in a day\"\n */\nexport function formatRelativeDateTime(\n\tdate: DateType,\n\tbaseDate: DateType = new Date(),\n) {\n\treturn dayjs(date).from(baseDate);\n}\n\n/**\n * A function that formats a date relative to Today or to the `baseDate` if passed.\n * If the date is not today, it will return a string with \"Yesterday ...\", \"Tomorrow ...\", etc\n * If the date is not in the current week, it return a string with \"DD MMM YYYY\" format\n * If the date is today, it will return a string with \"... ago\" or \"in ...\"\n *\n * @param date - the date to be formatted\n * @param baseDate - the date that should be used as a reference (default is \"today\")\n * @returns a relative date\n *\n * @example\n * // Considering today as 18.08.2021\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00') // returns \"Yesterday at 3:45 PM\"\n *\n * @example\n * formatRelativeToCurrentWeekDateTime('2021-08-17T15:45:00', '2021-08-16') // returns \"Tomorrow at 3:45 PM\"\n */\nexport function formatRelativeToCurrentWeekDateTime(\n\tdate: DateType,\n\tbaseDate: DateType = new Date(),\n) {\n\tconst isToday = dayjs(date).isSame(baseDate, \"day\");\n\n\tif (!isToday) {\n\t\t// if the date is not today, we display it with \"Yesterday\", \"Tomorrow\", etc.\n\t\t// and if the date is not in the current week then it will display \"17 Aug 2021\"\n\t\treturn dayjs(date).calendar(baseDate, {\n\t\t\tsameElse: \"DD MMM YYYY\",\n\t\t});\n\t}\n\n\t// returns \"... ago\"\n\treturn formatRelativeDateTime(date, baseDate);\n}\n","import { readableColor } from \"color2k\";\nimport type React from \"react\";\nimport { useMemo } from \"react\";\nimport { Badge } from \"../../primitives/badge\";\n\nexport interface StatusBadgeProps {\n\t/** The display label for the badge */\n\tlabel: string;\n\t/** The background color for the badge (hex format, e.g. \"#ff0000\") */\n\tcolor: string;\n\t/** Optional icon rendered inline before the label inside the badge. */\n\ticon?: React.ReactNode;\n}\n\nexport const StatusBadge: React.FC<StatusBadgeProps> = (props) => {\n\tconst { label, color, icon } = props;\n\n\tconst textColor = useMemo(() => {\n\t\ttry {\n\t\t\treturn readableColor(color);\n\t\t} catch {\n\t\t\treturn \"black\";\n\t\t}\n\t}, [color]);\n\n\treturn (\n\t\t<Badge\n\t\t\tbg={color}\n\t\t\tcolor={textColor}\n\t\t\trounded=\"base\"\n\t\t\tpx={2}\n\t\t\tmarginInlineStart={1}\n\t\t\tgap={1}\n\t\t>\n\t\t\t{icon}\n\t\t\t{label}\n\t\t</Badge>\n\t);\n};\n\nStatusBadge.displayName = \"StatusBadge\";\n"]}
|
|
@@ -241,6 +241,37 @@ interface DateCellProps {
|
|
|
241
241
|
}
|
|
242
242
|
declare const DateCell: React__default.FC<DateCellProps>;
|
|
243
243
|
|
|
244
|
+
interface DeviceCellProps {
|
|
245
|
+
/** Raw User-Agent string. Null/empty renders the empty cell value. */
|
|
246
|
+
userAgent: string | null | undefined;
|
|
247
|
+
/** Optional badge displayed to the right of the primary line (e.g. "Current"). */
|
|
248
|
+
badge?: {
|
|
249
|
+
label: string;
|
|
250
|
+
colorPalette?: string;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
declare const DeviceCell: React__default.FC<DeviceCellProps>;
|
|
254
|
+
|
|
255
|
+
interface IdentityCellProps {
|
|
256
|
+
/** Primary display name. Null/undefined renders the empty cell value. */
|
|
257
|
+
name: string | null | undefined;
|
|
258
|
+
/** Optional secondary line below the name (e.g., email, ID). */
|
|
259
|
+
subText?: React__default.ReactNode;
|
|
260
|
+
/** Avatar image source URL. */
|
|
261
|
+
avatarSrc?: string;
|
|
262
|
+
/** Initials shown as the avatar fallback. Auto-derived from `name` when omitted. */
|
|
263
|
+
avatarFallback?: string;
|
|
264
|
+
/** Avatar size; defaults to "sm" to match table density. */
|
|
265
|
+
size?: "sm" | "md";
|
|
266
|
+
/**
|
|
267
|
+
* Optional Chakra `colorPalette` forwarded to the underlying `Avatar`
|
|
268
|
+
* primitive (e.g. `"primary"`, `"secondary"`). Tints the fallback circle
|
|
269
|
+
* with the chosen palette. Omit for the default neutral-gray look.
|
|
270
|
+
*/
|
|
271
|
+
colorPalette?: string;
|
|
272
|
+
}
|
|
273
|
+
declare const IdentityCell: React__default.FC<IdentityCellProps>;
|
|
274
|
+
|
|
244
275
|
interface LinkCellProps {
|
|
245
276
|
/** Route path for navigation. Renders em-dash when null/undefined. */
|
|
246
277
|
to: string | null | undefined;
|
|
@@ -303,6 +334,11 @@ interface StatusBadgeCellProps {
|
|
|
303
334
|
* don't fit on the badge label.
|
|
304
335
|
*/
|
|
305
336
|
tooltip?: React__default.ReactNode;
|
|
337
|
+
/**
|
|
338
|
+
* Optional icon rendered inline before the label inside the badge (e.g.
|
|
339
|
+
* a `lucide-react` glyph). A small gap separates it from the label.
|
|
340
|
+
*/
|
|
341
|
+
icon?: React__default.ReactNode;
|
|
306
342
|
}
|
|
307
343
|
declare const StatusBadgeCell: React__default.FC<StatusBadgeCellProps>;
|
|
308
344
|
|
|
@@ -334,6 +370,22 @@ interface UrlCellProps {
|
|
|
334
370
|
}
|
|
335
371
|
declare const UrlCell: React__default.FC<UrlCellProps>;
|
|
336
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Parse a User-Agent string into a coarse browser + OS label.
|
|
375
|
+
*
|
|
376
|
+
* Used by `DeviceCell` to render "Chrome on macOS" style labels in
|
|
377
|
+
* sessions / device lists. The matchers are intentionally simple —
|
|
378
|
+
* they cover the common power-user browsers (Chrome, Safari, Firefox,
|
|
379
|
+
* Edge, Opera) on the common platforms (macOS, Windows, iOS, Android,
|
|
380
|
+
* Linux). Unknown browsers return `"Unknown"`; unknown OSes return `""`.
|
|
381
|
+
*/
|
|
382
|
+
declare function parseUserAgent(ua: string | undefined | null): {
|
|
383
|
+
browser: string;
|
|
384
|
+
os: string;
|
|
385
|
+
};
|
|
386
|
+
/** Format a parsed UA into the "Chrome on macOS" style label. */
|
|
387
|
+
declare function formatUserAgent(ua: string | undefined | null): string;
|
|
388
|
+
|
|
337
389
|
interface DataTableProps<T extends Record<string, unknown>> {
|
|
338
390
|
/** Column definitions for TanStack Table */
|
|
339
391
|
columns: ColumnDef<T, unknown>[];
|
|
@@ -908,4 +960,4 @@ interface WidgetProps {
|
|
|
908
960
|
}
|
|
909
961
|
declare const Widget: React__default.FC<WidgetProps>;
|
|
910
962
|
|
|
911
|
-
export { ActionCell, type ActionCellAction, type ActionCellProps, BooleanCell, type BooleanCellProps, BulkActionBar, type BulkActionBarProps, type BulkActionProps, type BulkPopoverActionProps, Card, CardList, CardListData, type CardListDataProps, CardListItem, type CardListItemProps, type CardListMenuItem, type CardListProps, type CardProps, ChipPicker, type ChipPickerProps, CodeCell, type CodeCellProps, ColorSwatchCell, type ColorSwatchCellProps, ContextRail, type ContextRailHeaderProps, type ContextRailProps, type ContextRailSectionProps, CountCell, type CountCellProps, DataTable, type DataTableProps, DateCell, type DateCellProps, type DrawerProps, DrawerRoot, FactBox, type FactBoxAction, type FactBoxProps, InlineCreatableList, type InlineCreatableListProps, LabeledSwitch, type LabeledSwitchProps, LinkCell, type LinkCellProps, MenuCell, type MenuCellAction, type MenuCellProps, Modal, type ModalProps, NumberCell, type NumberCellProps, Pagination, type PaginationProps, SelectableCard, type SelectableCardBodyProps, type SelectableCardFooterProps, type SelectableCardProps, type SelectableCardThumbnailProps, Sidebar, type SidebarItemProps, type SidebarLogoProps, type SidebarSectionProps$1 as SidebarNavSectionProps, type SidebarProps, SidebarSection, type SidebarSectionProps, type SidebarUserMenuItemProps, type SidebarUserMenuProps, SlugCell, type SlugCellProps, StatusBadgeCell, type StatusBadgeCellProps, Stepper, StepperCompleted, StepperContainer, StepperContent, type StepperContentProps, StepperIcon, type StepperIconProps, type StepperProps, StepperProvider, StepperSeparator, type StepperSeparatorProps, StepperStep, type StepperStepProps, StepperStepTitle, StepperSteps, type StepperStepsProps, SwitchCell, type SwitchCellProps, CardList as Table, CardListData as TableData, type CardListDataProps as TableDataProps, CardListItem as TableItem, type CardListItemProps as TableItemProps, type CardListMenuItem as TableMenuItem, type CardListProps as TableProps, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, type TimelineItemProps, TimelineRoot, type TimelineRootProps, TimelineSeparator, TimelineTitle, Toolbar, type ToolbarFilterChipProps, type ToolbarSearchProps, TreeViewBranch, TreeViewBranchContent, TreeViewBranchControl, TreeViewBranchIndicator, type TreeViewBranchProps, TreeViewBranchText, TreeViewBranchTrigger, TreeViewItem, TreeViewItemIndicator, type TreeViewItemProps, TreeViewItemText, TreeViewLabel, TreeViewNode, TreeViewRoot, type TreeViewRootProps, TreeViewTree, TruncatedTextCell, type TruncatedTextCellProps, UploadDropZone, type UploadDropZoneProps, UrlCell, type UrlCellProps, type UseStepProps, type UseStepperProps, type UseStepperReturn, Widget, type WidgetProps, emptyCellValue, pluralize, truncateText, useSidebarContext, useStep, useStepper, useStepperContext, useStepperNextButton, useStepperPrevButton };
|
|
963
|
+
export { ActionCell, type ActionCellAction, type ActionCellProps, BooleanCell, type BooleanCellProps, BulkActionBar, type BulkActionBarProps, type BulkActionProps, type BulkPopoverActionProps, Card, CardList, CardListData, type CardListDataProps, CardListItem, type CardListItemProps, type CardListMenuItem, type CardListProps, type CardProps, ChipPicker, type ChipPickerProps, CodeCell, type CodeCellProps, ColorSwatchCell, type ColorSwatchCellProps, ContextRail, type ContextRailHeaderProps, type ContextRailProps, type ContextRailSectionProps, CountCell, type CountCellProps, DataTable, type DataTableProps, DateCell, type DateCellProps, DeviceCell, type DeviceCellProps, type DrawerProps, DrawerRoot, FactBox, type FactBoxAction, type FactBoxProps, IdentityCell, type IdentityCellProps, InlineCreatableList, type InlineCreatableListProps, LabeledSwitch, type LabeledSwitchProps, LinkCell, type LinkCellProps, MenuCell, type MenuCellAction, type MenuCellProps, Modal, type ModalProps, NumberCell, type NumberCellProps, Pagination, type PaginationProps, SelectableCard, type SelectableCardBodyProps, type SelectableCardFooterProps, type SelectableCardProps, type SelectableCardThumbnailProps, Sidebar, type SidebarItemProps, type SidebarLogoProps, type SidebarSectionProps$1 as SidebarNavSectionProps, type SidebarProps, SidebarSection, type SidebarSectionProps, type SidebarUserMenuItemProps, type SidebarUserMenuProps, SlugCell, type SlugCellProps, StatusBadgeCell, type StatusBadgeCellProps, Stepper, StepperCompleted, StepperContainer, StepperContent, type StepperContentProps, StepperIcon, type StepperIconProps, type StepperProps, StepperProvider, StepperSeparator, type StepperSeparatorProps, StepperStep, type StepperStepProps, StepperStepTitle, StepperSteps, type StepperStepsProps, SwitchCell, type SwitchCellProps, CardList as Table, CardListData as TableData, type CardListDataProps as TableDataProps, CardListItem as TableItem, type CardListItemProps as TableItemProps, type CardListMenuItem as TableMenuItem, type CardListProps as TableProps, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, type TimelineItemProps, TimelineRoot, type TimelineRootProps, TimelineSeparator, TimelineTitle, Toolbar, type ToolbarFilterChipProps, type ToolbarSearchProps, TreeViewBranch, TreeViewBranchContent, TreeViewBranchControl, TreeViewBranchIndicator, type TreeViewBranchProps, TreeViewBranchText, TreeViewBranchTrigger, TreeViewItem, TreeViewItemIndicator, type TreeViewItemProps, TreeViewItemText, TreeViewLabel, TreeViewNode, TreeViewRoot, type TreeViewRootProps, TreeViewTree, TruncatedTextCell, type TruncatedTextCellProps, UploadDropZone, type UploadDropZoneProps, UrlCell, type UrlCellProps, type UseStepProps, type UseStepperProps, type UseStepperReturn, Widget, type WidgetProps, emptyCellValue, formatUserAgent, parseUserAgent, pluralize, truncateText, useSidebarContext, useStep, useStepper, useStepperContext, useStepperNextButton, useStepperPrevButton };
|
package/dist/components/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Collapsible, Skeleton, Separator, Checkbox as Checkbox$1 } from '../chunk-TXGJ7BNX.js';
|
|
2
|
-
import { formatRelativeDateTime, StatusBadge } from '../chunk-
|
|
3
|
-
import { MenuItem, MenuRoot, MenuTrigger, MenuContent, Tooltip, Table } from '../chunk-2ZWZ2WAS.js';
|
|
2
|
+
import { formatRelativeDateTime, StatusBadge } from '../chunk-ETY43HAI.js';
|
|
3
|
+
import { MenuItem, MenuRoot, MenuTrigger, MenuContent, Tooltip, Badge, Avatar, Table } from '../chunk-2ZWZ2WAS.js';
|
|
4
4
|
import { Popover, PopoverTrigger, PopoverContent, PopoverBody, Switch } from '../chunk-WQIEF5N3.js';
|
|
5
5
|
import { text_input_default } from '../chunk-OU6H3KU4.js';
|
|
6
6
|
import { Button, IconButton } from '../chunk-JS7ZEZV3.js';
|
|
7
7
|
export { AuthCard, PageHeader } from '../chunk-D5ICTOCW.js';
|
|
8
|
-
import { Box, Flex, Heading, Text, HStack, Grid, GridItem, Code,
|
|
8
|
+
import { Box, Flex, Heading, Text, HStack, Grid, GridItem, Code, VStack, Link, Spacer, Stack } from '../chunk-G4QMIXLC.js';
|
|
9
9
|
import { PanelRightOpen, PanelRightClose, ChevronRight, Search, PanelLeftOpen, PanelLeftClose, X, Ellipsis, Plus, ChevronLeft, ArrowUp, ArrowDown, ArrowUpDown, ChevronDown, Check, Upload } from 'lucide-react';
|
|
10
10
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
import { createContext as createContext$1, Timeline, TreeView, Card as Card$1, Menu, Portal, Checkbox, Drawer, ButtonGroup, Dialog, useSlotRecipe, chakra } from '@chakra-ui/react';
|
|
@@ -699,6 +699,76 @@ var DateCell = ({
|
|
|
699
699
|
return /* @__PURE__ */ jsx("span", { children: formatted });
|
|
700
700
|
};
|
|
701
701
|
DateCell.displayName = "DateCell";
|
|
702
|
+
|
|
703
|
+
// src/components/data-table/cells/user-agent.ts
|
|
704
|
+
function parseUserAgent(ua) {
|
|
705
|
+
if (!ua) return { browser: "Unknown", os: "" };
|
|
706
|
+
let browser = "Unknown";
|
|
707
|
+
if (/Edg\//.test(ua)) browser = "Edge";
|
|
708
|
+
else if (/Firefox\//.test(ua)) browser = "Firefox";
|
|
709
|
+
else if (/OPR\/|Opera/.test(ua)) browser = "Opera";
|
|
710
|
+
else if (/Chrome\//.test(ua)) browser = "Chrome";
|
|
711
|
+
else if (/Safari\//.test(ua)) browser = "Safari";
|
|
712
|
+
let os = "";
|
|
713
|
+
if (/Windows NT/.test(ua)) os = "Windows";
|
|
714
|
+
else if (/iPhone|iPad/.test(ua)) os = "iOS";
|
|
715
|
+
else if (/Mac OS X|Macintosh/.test(ua)) os = "macOS";
|
|
716
|
+
else if (/Android/.test(ua)) os = "Android";
|
|
717
|
+
else if (/Linux/.test(ua)) os = "Linux";
|
|
718
|
+
return { browser, os };
|
|
719
|
+
}
|
|
720
|
+
function formatUserAgent(ua) {
|
|
721
|
+
const { browser, os } = parseUserAgent(ua);
|
|
722
|
+
return os ? `${browser} on ${os}` : browser;
|
|
723
|
+
}
|
|
724
|
+
var DeviceCell = ({ userAgent, badge }) => {
|
|
725
|
+
if (userAgent == null || userAgent === "") {
|
|
726
|
+
return /* @__PURE__ */ jsx("span", { children: emptyCellValue });
|
|
727
|
+
}
|
|
728
|
+
const label = formatUserAgent(userAgent);
|
|
729
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: userAgent, showArrow: true, children: /* @__PURE__ */ jsxs(VStack, { align: "start", gap: 0, children: [
|
|
730
|
+
/* @__PURE__ */ jsxs(HStack, { gap: 2, align: "center", children: [
|
|
731
|
+
/* @__PURE__ */ jsx(Text, { fontSize: "sm", fontWeight: "medium", lineClamp: 1, children: label }),
|
|
732
|
+
badge && /* @__PURE__ */ jsx(Badge, { colorPalette: badge.colorPalette, size: "xs", children: badge.label })
|
|
733
|
+
] }),
|
|
734
|
+
/* @__PURE__ */ jsx(Text, { fontSize: "xs", color: "fg.muted", lineClamp: 1, children: userAgent })
|
|
735
|
+
] }) });
|
|
736
|
+
};
|
|
737
|
+
DeviceCell.displayName = "DeviceCell";
|
|
738
|
+
function deriveInitials(name) {
|
|
739
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
740
|
+
if (parts.length === 0) return "";
|
|
741
|
+
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
742
|
+
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
743
|
+
}
|
|
744
|
+
var IdentityCell = ({
|
|
745
|
+
name,
|
|
746
|
+
subText,
|
|
747
|
+
avatarSrc,
|
|
748
|
+
avatarFallback,
|
|
749
|
+
size = "sm",
|
|
750
|
+
colorPalette
|
|
751
|
+
}) => {
|
|
752
|
+
if (name == null) return /* @__PURE__ */ jsx("span", { children: emptyCellValue });
|
|
753
|
+
const initials = avatarFallback ?? deriveInitials(name);
|
|
754
|
+
return /* @__PURE__ */ jsxs(HStack, { gap: 2, align: "center", children: [
|
|
755
|
+
/* @__PURE__ */ jsx(
|
|
756
|
+
Avatar,
|
|
757
|
+
{
|
|
758
|
+
size,
|
|
759
|
+
name,
|
|
760
|
+
src: avatarSrc,
|
|
761
|
+
fallback: initials,
|
|
762
|
+
colorPalette
|
|
763
|
+
}
|
|
764
|
+
),
|
|
765
|
+
/* @__PURE__ */ jsxs(VStack, { align: "start", gap: 0, children: [
|
|
766
|
+
/* @__PURE__ */ jsx(Text, { fontSize: "sm", fontWeight: "semibold", lineClamp: 1, children: name }),
|
|
767
|
+
subText != null && /* @__PURE__ */ jsx(Text, { fontSize: "xs", color: "fg.muted", lineClamp: 1, children: subText })
|
|
768
|
+
] })
|
|
769
|
+
] });
|
|
770
|
+
};
|
|
771
|
+
IdentityCell.displayName = "IdentityCell";
|
|
702
772
|
var LinkCell = ({ to, label }) => {
|
|
703
773
|
if (to == null) return /* @__PURE__ */ jsx("span", { children: emptyCellValue });
|
|
704
774
|
return /* @__PURE__ */ jsx(Link, { color: "accent", asChild: true, children: /* @__PURE__ */ jsx(
|
|
@@ -792,11 +862,12 @@ var StatusBadgeCell = ({
|
|
|
792
862
|
fallbackColor = "gray",
|
|
793
863
|
detail,
|
|
794
864
|
detailColor = "fg.error",
|
|
795
|
-
tooltip
|
|
865
|
+
tooltip,
|
|
866
|
+
icon
|
|
796
867
|
}) => {
|
|
797
868
|
if (value == null) return /* @__PURE__ */ jsx("span", { children: emptyCellValue });
|
|
798
869
|
const color = colorMap?.[value] ?? fallbackColor;
|
|
799
|
-
let badge = /* @__PURE__ */ jsx(StatusBadge, { label: value, color });
|
|
870
|
+
let badge = /* @__PURE__ */ jsx(StatusBadge, { label: value, color, icon });
|
|
800
871
|
if (tooltip != null) {
|
|
801
872
|
badge = /* @__PURE__ */ jsx(Tooltip, { content: tooltip, showArrow: true, children: /* @__PURE__ */ jsx("span", { children: badge }) });
|
|
802
873
|
}
|
|
@@ -2576,6 +2647,6 @@ var Widget = ({
|
|
|
2576
2647
|
};
|
|
2577
2648
|
Widget.displayName = "Widget";
|
|
2578
2649
|
|
|
2579
|
-
export { ActionCell, BooleanCell, BulkActionBar, Card, CardList, CardListData, CardListItem, ChipPicker, CodeCell, ColorSwatchCell, ContextRail, CountCell, DataTable, DateCell, DrawerRoot, FactBox, InlineCreatableList, LabeledSwitch, LinkCell, MenuCell, Modal, NumberCell, Pagination, SelectableCard, Sidebar, SidebarSection2 as SidebarSection, SlugCell, StatusBadgeCell, Stepper, StepperCompleted, StepperContainer, StepperContent, StepperIcon, StepperProvider, StepperSeparator, StepperStep, StepperStepTitle, StepperSteps, SwitchCell, CardList as Table, CardListData as TableData, CardListItem as TableItem, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineRoot, TimelineSeparator, TimelineTitle, Toolbar, TreeViewBranch, TreeViewBranchContent, TreeViewBranchControl, TreeViewBranchIndicator, TreeViewBranchText, TreeViewBranchTrigger, TreeViewItem, TreeViewItemIndicator, TreeViewItemText, TreeViewLabel, TreeViewNode, TreeViewRoot, TreeViewTree, TruncatedTextCell, UploadDropZone, UrlCell, Widget, emptyCellValue, pluralize, truncateText, useSidebarContext, useStep, useStepper, useStepperContext, useStepperNextButton, useStepperPrevButton };
|
|
2650
|
+
export { ActionCell, BooleanCell, BulkActionBar, Card, CardList, CardListData, CardListItem, ChipPicker, CodeCell, ColorSwatchCell, ContextRail, CountCell, DataTable, DateCell, DeviceCell, DrawerRoot, FactBox, IdentityCell, InlineCreatableList, LabeledSwitch, LinkCell, MenuCell, Modal, NumberCell, Pagination, SelectableCard, Sidebar, SidebarSection2 as SidebarSection, SlugCell, StatusBadgeCell, Stepper, StepperCompleted, StepperContainer, StepperContent, StepperIcon, StepperProvider, StepperSeparator, StepperStep, StepperStepTitle, StepperSteps, SwitchCell, CardList as Table, CardListData as TableData, CardListItem as TableItem, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineRoot, TimelineSeparator, TimelineTitle, Toolbar, TreeViewBranch, TreeViewBranchContent, TreeViewBranchControl, TreeViewBranchIndicator, TreeViewBranchText, TreeViewBranchTrigger, TreeViewItem, TreeViewItemIndicator, TreeViewItemText, TreeViewLabel, TreeViewNode, TreeViewRoot, TreeViewTree, TruncatedTextCell, UploadDropZone, UrlCell, Widget, emptyCellValue, formatUserAgent, parseUserAgent, pluralize, truncateText, useSidebarContext, useStep, useStepper, useStepperContext, useStepperNextButton, useStepperPrevButton };
|
|
2580
2651
|
//# sourceMappingURL=index.js.map
|
|
2581
2652
|
//# sourceMappingURL=index.js.map
|