periplo-ui 4.9.2 → 4.10.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/components/Badge/Badge.d.ts +22 -66
- package/dist/components/Badge/Badge.js +15 -88
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts +2 -0
- package/dist/components/Combobox/Combobox.js +2 -1
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Combobox/VirtualizedComboboxList.d.ts +1 -1
- package/dist/components/Combobox/VirtualizedComboboxList.js +7 -6
- package/dist/components/Combobox/VirtualizedComboboxList.js.map +1 -1
- package/dist/components/Combobox/types.d.ts +1 -0
- package/dist/components/DataTable/DataTable.js +31 -23
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/components/DataTableBody.js +2 -2
- package/dist/components/DataTable/components/DataTableBody.js.map +1 -1
- package/dist/components/DataTable/components/DataTableToolbar.js +2 -2
- package/dist/components/DataTable/components/DataTableToolbar.js.map +1 -1
- package/dist/components/Form/Form.d.ts +1 -1
- package/dist/components/NotificationBadge/NotificationBadge.d.ts +84 -0
- package/dist/components/NotificationBadge/NotificationBadge.js +85 -0
- package/dist/components/NotificationBadge/NotificationBadge.js.map +1 -0
- package/dist/components/NotificationBadge/index.d.ts +1 -0
- package/dist/components/NotificationBadge/index.js +2 -0
- package/dist/components/NotificationBadge/index.js.map +1 -0
- package/dist/components/PhoneInput/PhoneInput.d.ts +24 -40
- package/dist/components/PhoneInput/PhoneInput.js +139 -116
- package/dist/components/PhoneInput/PhoneInput.js.map +1 -1
- package/dist/components/PhoneInput/hooks/index.d.ts +1 -0
- package/dist/components/PhoneInput/hooks/index.js +2 -0
- package/dist/components/PhoneInput/hooks/index.js.map +1 -0
- package/dist/components/PhoneInput/hooks/usePhoneField.d.ts +22 -0
- package/dist/components/PhoneInput/hooks/usePhoneField.js +152 -0
- package/dist/components/PhoneInput/hooks/usePhoneField.js.map +1 -0
- package/dist/components/PhoneInput/index.d.ts +2 -1
- package/dist/components/PhoneInput/index.js +1 -1
- package/dist/components/PhoneInput/phone.d.ts +47 -0
- package/dist/components/PhoneInput/phone.js +129 -0
- package/dist/components/PhoneInput/phone.js.map +1 -0
- package/dist/components/PhoneInput/types.d.ts +25 -0
- package/dist/components/PhoneInput/types.js +2 -0
- package/dist/components/PhoneInput/types.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +23 -1
- package/dist/components/RadioGroup/RadioGroup.js +63 -15
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +8 -2
- package/dist/components/Tooltip/Tooltip.js +18 -6
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Typography/Typography.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/useTouchDevice.d.ts +1 -0
- package/dist/lib/useTouchDevice.js +18 -0
- package/dist/lib/useTouchDevice.js.map +1 -0
- package/package.json +6 -1
- package/dist/components/PhoneInput/countries.d.ts +0 -16
- package/dist/components/PhoneInput/countries.js +0 -254
- package/dist/components/PhoneInput/countries.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableBody.js","sources":["../../../../src/components/DataTable/components/DataTableBody.tsx"],"sourcesContent":["import { flexRender, Row, Table } from '@tanstack/react-table'\n\nimport { Skeleton } from '../../Skeleton'\nimport { TableBody, TableCell, TableRow } from '../../Table'\nimport { Typography } from '../../Typography'\nimport { EmptyStateConfig, RowIdentifierFn } from '../types'\n\nimport { DataTableCell } from './DataTableCell'\nimport { ACTIONS_COLUMN_ID, getSkeletonClassName, SELECT_COLUMN_ID } from './dataTableCellStyles'\nimport { DataTableGroupRow } from './DataTableGroupRow'\n\nimport { cn } from '@/lib/utils'\n\ntype GroupRenderConfig<TData> = {\n readonly renderGroupRow?: (row: Row<TData>) => React.ReactNode\n readonly renderGroupSelector?: React.ComponentType<{ row: Row<TData> }>\n readonly isGroupOpen: (groupId: string) => boolean\n readonly toggleGroup: (groupId: string) => void\n readonly getRowId: RowIdentifierFn<TData>\n}\n\ntype DataTableBodyProps<TData> = {\n readonly table: Table<TData>\n readonly isLoading?: boolean\n readonly pageSize: number\n readonly getRowId: RowIdentifierFn<TData>\n readonly rowSelection: Record<string, boolean>\n readonly emptyState: EmptyStateConfig\n readonly group?: GroupRenderConfig<TData>\n}\n\ntype DataTableRowProps<TData> = {\n readonly row: Row<TData>\n readonly isSelected: boolean\n readonly isCollapsible?: boolean\n readonly isOpen?: boolean\n}\n\nfunction DataTableRow<TData>({\n row,\n isSelected,\n isCollapsible = false,\n isOpen = true,\n}: DataTableRowProps<TData>) {\n return (\n <TableRow\n data-selected={isSelected}\n className={cn(isCollapsible && 'transition-colors', isCollapsible && !isOpen && 'border-b-0')}\n >\n {row.getVisibleCells().map((cell) => {\n const content = cell.column.columnDef.cell && flexRender(cell.column.columnDef.cell, cell.getContext())\n\n return (\n <DataTableCell\n key={cell.id}\n columnId={cell.column.id}\n isCollapsible={isCollapsible}\n isOpen={isOpen}\n style={{ width: cell.column.columnDef.size }}\n >\n {content}\n </DataTableCell>\n )\n })}\n </TableRow>\n )\n}\n\nexport function DataTableBody<TData>({\n table,\n isLoading,\n pageSize,\n getRowId,\n rowSelection,\n emptyState,\n group,\n}: DataTableBodyProps<TData>) {\n if (isLoading) {\n return (\n <TableBody>\n {Array.from({ length: pageSize }).map((_unused, index) => (\n <TableRow key={`skeleton-row-${String(index)}`}>\n {table\n .getAllColumns()\n .filter((column) => column.getIsVisible())\n .map((column) => (\n <DataTableCell\n key={`skeleton-cell-${String(index)}-${column.id}`}\n columnId={column.id}\n style={{ width: column.columnDef.size }}\n className={\n column.id !== SELECT_COLUMN_ID && column.id !== ACTIONS_COLUMN_ID ? 'w-full' : undefined\n }\n >\n <Skeleton className={getSkeletonClassName(column.id)} />\n </DataTableCell>\n ))}\n </TableRow>\n ))}\n </TableBody>\n )\n }\n\n const rows = table.getRowModel().rows\n\n if (!rows.length) {\n const visibleColumns = table.getAllColumns().filter((col) => col.getIsVisible())\n\n return (\n <TableBody>\n <TableRow className=\"h-full\">\n <TableCell colSpan={visibleColumns.length} className=\"h-full p-0\">\n <div className=\"
|
|
1
|
+
{"version":3,"file":"DataTableBody.js","sources":["../../../../src/components/DataTable/components/DataTableBody.tsx"],"sourcesContent":["import { flexRender, Row, Table } from '@tanstack/react-table'\n\nimport { Skeleton } from '../../Skeleton'\nimport { TableBody, TableCell, TableRow } from '../../Table'\nimport { Typography } from '../../Typography'\nimport { EmptyStateConfig, RowIdentifierFn } from '../types'\n\nimport { DataTableCell } from './DataTableCell'\nimport { ACTIONS_COLUMN_ID, getSkeletonClassName, SELECT_COLUMN_ID } from './dataTableCellStyles'\nimport { DataTableGroupRow } from './DataTableGroupRow'\n\nimport { cn } from '@/lib/utils'\n\ntype GroupRenderConfig<TData> = {\n readonly renderGroupRow?: (row: Row<TData>) => React.ReactNode\n readonly renderGroupSelector?: React.ComponentType<{ row: Row<TData> }>\n readonly isGroupOpen: (groupId: string) => boolean\n readonly toggleGroup: (groupId: string) => void\n readonly getRowId: RowIdentifierFn<TData>\n}\n\ntype DataTableBodyProps<TData> = {\n readonly table: Table<TData>\n readonly isLoading?: boolean\n readonly pageSize: number\n readonly getRowId: RowIdentifierFn<TData>\n readonly rowSelection: Record<string, boolean>\n readonly emptyState: EmptyStateConfig\n readonly group?: GroupRenderConfig<TData>\n}\n\ntype DataTableRowProps<TData> = {\n readonly row: Row<TData>\n readonly isSelected: boolean\n readonly isCollapsible?: boolean\n readonly isOpen?: boolean\n}\n\nfunction DataTableRow<TData>({\n row,\n isSelected,\n isCollapsible = false,\n isOpen = true,\n}: DataTableRowProps<TData>) {\n return (\n <TableRow\n data-selected={isSelected}\n className={cn(isCollapsible && 'transition-colors', isCollapsible && !isOpen && 'border-b-0')}\n >\n {row.getVisibleCells().map((cell) => {\n const content = cell.column.columnDef.cell && flexRender(cell.column.columnDef.cell, cell.getContext())\n\n return (\n <DataTableCell\n key={cell.id}\n columnId={cell.column.id}\n isCollapsible={isCollapsible}\n isOpen={isOpen}\n style={{ width: cell.column.columnDef.size }}\n >\n {content}\n </DataTableCell>\n )\n })}\n </TableRow>\n )\n}\n\nexport function DataTableBody<TData>({\n table,\n isLoading,\n pageSize,\n getRowId,\n rowSelection,\n emptyState,\n group,\n}: DataTableBodyProps<TData>) {\n if (isLoading) {\n return (\n <TableBody>\n {Array.from({ length: pageSize }).map((_unused, index) => (\n <TableRow key={`skeleton-row-${String(index)}`}>\n {table\n .getAllColumns()\n .filter((column) => column.getIsVisible())\n .map((column) => (\n <DataTableCell\n key={`skeleton-cell-${String(index)}-${column.id}`}\n columnId={column.id}\n style={{ width: column.columnDef.size }}\n className={\n column.id !== SELECT_COLUMN_ID && column.id !== ACTIONS_COLUMN_ID ? 'w-full' : undefined\n }\n >\n <Skeleton className={getSkeletonClassName(column.id)} />\n </DataTableCell>\n ))}\n </TableRow>\n ))}\n </TableBody>\n )\n }\n\n const rows = table.getRowModel().rows\n\n if (!rows.length) {\n const visibleColumns = table.getAllColumns().filter((col) => col.getIsVisible())\n\n return (\n <TableBody>\n <TableRow className=\"h-full\">\n <TableCell colSpan={visibleColumns.length} className=\"h-full p-0\">\n <div className=\"flex h-full w-full flex-col items-center justify-center\">\n {emptyState.imageRoute && (\n <img\n className={cn('mb-6 w-50 md:w-75', emptyState.imageClassName)}\n src={emptyState.imageRoute}\n alt={emptyState.imageAlt ?? 'No data available'}\n />\n )}\n <Typography variant=\"title-md\" weight=\"semibold\" className=\"text-center\">\n {emptyState.title}\n </Typography>\n <Typography variant=\"title-sm\" className=\"text-center opacity-80\">\n {emptyState.description}\n </Typography>\n </div>\n </TableCell>\n </TableRow>\n </TableBody>\n )\n }\n\n const visibleColumnCount = table.getVisibleLeafColumns().length\n\n return (\n <TableBody>\n {rows.map((row) => {\n const rowId = getRowId(row.original)\n\n if (group && row.getCanExpand()) {\n const content = group.renderGroupRow?.(row) ?? `${String(row.getLeafRows().length)} items`\n return (\n <DataTableGroupRow\n key={rowId}\n colSpan={visibleColumnCount}\n selector={group.renderGroupSelector ? <group.renderGroupSelector row={row} /> : undefined}\n content={content}\n isOpen={group.isGroupOpen(rowId)}\n onToggle={() => group.toggleGroup(rowId)}\n />\n )\n }\n\n const isSelected = rowSelection[rowId] ?? false\n const parentRow = group ? row.getParentRow() : undefined\n return (\n <DataTableRow\n key={rowId}\n row={row}\n isSelected={isSelected}\n isCollapsible={!!group}\n isOpen={parentRow ? (group?.isGroupOpen(getRowId(parentRow.original)) ?? true) : true}\n />\n )\n })}\n </TableBody>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;AAsCA,SAAS,YAAA,CAAoB;AAAA,EAC3B,GAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA,GAAgB,KAAA;AAAA,EAChB,MAAA,GAAS;AACX,CAAA,EAA6B;AAC3B,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,eAAA,EAAe,UAAA;AAAA,MACf,WAAW,EAAA,CAAG,aAAA,IAAiB,qBAAqB,aAAA,IAAiB,CAAC,UAAU,YAAY,CAAA;AAAA,MAE3F,QAAA,EAAA,GAAA,CAAI,eAAA,EAAgB,CAAE,GAAA,CAAI,CAAC,IAAA,KAAS;AACnC,QAAA,MAAM,OAAA,GAAU,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAA,IAAQ,UAAA,CAAW,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAA,EAAM,IAAA,CAAK,UAAA,EAAY,CAAA;AAEtG,QAAA,uBACE,GAAA;AAAA,UAAC,aAAA;AAAA,UAAA;AAAA,YAEC,QAAA,EAAU,KAAK,MAAA,CAAO,EAAA;AAAA,YACtB,aAAA;AAAA,YACA,MAAA;AAAA,YACA,OAAO,EAAE,KAAA,EAAO,IAAA,CAAK,MAAA,CAAO,UAAU,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TextColumns } from '@phosphor-icons/react/dist/ssr/TextColumns';
|
|
5
5
|
import { X } from '@phosphor-icons/react/dist/ssr/X';
|
|
6
|
-
import { Badge } from '../../Badge/Badge.js';
|
|
7
6
|
import { Button } from '../../Button/Button.js';
|
|
8
7
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuCheckboxItem, DropdownMenuSeparator } from '../../DropdownMenu/DropdownMenu.js';
|
|
8
|
+
import { NotificationBadge } from '../../NotificationBadge/NotificationBadge.js';
|
|
9
9
|
import { PopoverRoot, PopoverTrigger, PopoverContent } from '../../Popover/Popover.js';
|
|
10
10
|
import { Typography } from '../../Typography/Typography.js';
|
|
11
11
|
import { TooltipProvider, TooltipRoot, TooltipTrigger, TooltipContent } from '../../Tooltip/Tooltip.js';
|
|
@@ -82,7 +82,7 @@ function DataTableToolbar({
|
|
|
82
82
|
showFiltersButton && /* @__PURE__ */ jsxs(PopoverRoot, { children: [
|
|
83
83
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "text", size: "sm", StartIcon: FunnelSimple, className: "relative whitespace-nowrap", children: [
|
|
84
84
|
showBadge && /* @__PURE__ */ jsx(
|
|
85
|
-
|
|
85
|
+
NotificationBadge,
|
|
86
86
|
{
|
|
87
87
|
count: activeFiltersCount,
|
|
88
88
|
color: "primary",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableToolbar.js","sources":["../../../../src/components/DataTable/components/DataTableToolbar.tsx"],"sourcesContent":["import { FunnelSimple } from '@phosphor-icons/react/dist/ssr/FunnelSimple'\nimport { SelectionAll } from '@phosphor-icons/react/dist/ssr/SelectionAll'\nimport { TextColumns } from '@phosphor-icons/react/dist/ssr/TextColumns'\nimport { X } from '@phosphor-icons/react/dist/ssr/X'\nimport { Table } from '@tanstack/react-table'\nimport * as React from 'react'\n\nimport { Badge } from '../../Badge'\nimport { Button } from '../../Button'\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../../DropdownMenu'\nimport { PopoverContent, PopoverRoot, PopoverTrigger } from '../../Popover'\nimport { Typography } from '../../Typography'\n\nimport { ColumnVisibilityConfig } from '@/components/DataTable/types'\nimport { TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger } from '@/components/Tooltip'\nimport { useIsMobile } from '@/lib/useMobile'\nimport { cn } from '@/lib/utils'\n\ntype DataTableToolbarProps<TData> = {\n readonly table: Table<TData>\n readonly columnVisibility?: ColumnVisibilityConfig\n readonly primaryFilters?: React.ReactNode\n readonly secondaryFilters?: React.ReactNode\n readonly activePrimaryFiltersCount?: number\n readonly activeSecondaryFiltersCount?: number\n readonly labels?: {\n filters?: string\n moreFilters?: string\n }\n readonly selection?: {\n isSelectionStarted?: boolean\n onSelectionStart?: () => void\n onSelectionCancel?: () => void\n selectionSummary?: string | null\n isSelectionDisabled?: boolean\n labels?: {\n startSelection?: string\n cancelSelection?: string\n selectionSummary?: string\n selectionDisabledTooltip?: string\n }\n }\n}\n\nconst defaultLabels = {\n filters: 'Filters',\n moreFilters: 'More filters',\n}\n\nconst defaultColumnVisibilityLabels = {\n button: 'Hide columns',\n selectAll: 'Select all',\n}\n\nconst defaultSelectionLabels = {\n startSelection: 'Start selection',\n cancelSelection: 'Cancel selection',\n}\n\nexport function DataTableToolbar<TData>({\n table,\n columnVisibility,\n primaryFilters,\n secondaryFilters,\n activePrimaryFiltersCount = 0,\n activeSecondaryFiltersCount = 0,\n selection,\n labels: labelsProp,\n}: DataTableToolbarProps<TData>) {\n const isMobile = useIsMobile()\n\n const labels = {\n ...defaultLabels,\n ...labelsProp,\n }\n\n const columnVisibilityLabels = {\n ...defaultColumnVisibilityLabels,\n ...columnVisibility?.labels,\n }\n\n const selectionLabels = {\n ...defaultSelectionLabels,\n ...selection?.labels,\n }\n\n const showColumnVisibilityControls = columnVisibility?.showControls ?? true\n\n const hasPrimaryFilters = !!primaryFilters\n const hasSecondaryFilters = !!secondaryFilters\n\n const showFiltersButton = isMobile ? hasPrimaryFilters || hasSecondaryFilters : hasSecondaryFilters\n\n const totalActiveFiltersCount = activePrimaryFiltersCount + activeSecondaryFiltersCount\n const activeFiltersCount = isMobile ? totalActiveFiltersCount : activeSecondaryFiltersCount\n const showBadge = activeFiltersCount > 0\n\n const filtersButtonLabel = !hasPrimaryFilters || isMobile ? labels.filters : labels.moreFilters\n\n if (!showColumnVisibilityControls && !primaryFilters && !secondaryFilters && !selection) {\n return null\n }\n\n return (\n <div className=\"flex shrink-0 flex-col gap-2 p-1\">\n {!isMobile && primaryFilters && <div className=\"flex flex-wrap items-center gap-2\">{primaryFilters}</div>}\n\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n {selection && (\n <div className=\"flex items-center gap-2\">\n {selection.isSelectionStarted ? (\n <>\n <Button variant=\"text\" size=\"sm\" StartIcon={X} onClick={selection.onSelectionCancel}>\n {selectionLabels.cancelSelection}\n </Button>\n {selection.selectionSummary && !isMobile && (\n <Typography variant=\"body-sm\" className=\"text-neutral-600\">\n {selection.selectionSummary}\n </Typography>\n )}\n </>\n ) : (\n <TooltipProvider>\n <TooltipRoot delayDuration={200}>\n <TooltipTrigger asChild>\n <div>\n <Button\n variant=\"text\"\n size=\"sm\"\n StartIcon={SelectionAll}\n onClick={selection.onSelectionStart}\n disabled={selection.isSelectionDisabled}\n >\n {selectionLabels.startSelection}\n </Button>\n </div>\n </TooltipTrigger>\n {selection.labels?.selectionDisabledTooltip && selection.isSelectionDisabled && (\n <TooltipContent>{selection.labels.selectionDisabledTooltip}</TooltipContent>\n )}\n </TooltipRoot>\n </TooltipProvider>\n )}\n </div>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {showFiltersButton && (\n <PopoverRoot>\n <PopoverTrigger asChild>\n <Button variant=\"text\" size=\"sm\" StartIcon={FunnelSimple} className=\"relative whitespace-nowrap\">\n {showBadge && (\n <Badge\n count={activeFiltersCount}\n color=\"primary\"\n ping={false}\n className=\"absolute -top-1 -right-1\"\n />\n )}\n {filtersButtonLabel}\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align=\"center\"\n className={cn('w-fit p-4', isMobile && 'max-h-[80vh] w-[95vw] overflow-y-auto')}\n >\n <div className=\"flex flex-col gap-4\">\n {isMobile && primaryFilters}\n {secondaryFilters}\n </div>\n </PopoverContent>\n </PopoverRoot>\n )}\n {showColumnVisibilityControls && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"text\" size=\"sm\" className={cn('whitespace-nowrap')} StartIcon={TextColumns}>\n {columnVisibilityLabels.button}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuCheckboxItem\n key={'all-columns'}\n className=\"capitalize\"\n checked={table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .every((column) => column.getIsVisible())}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(value) =>\n table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .forEach((column) => column.toggleVisibility(!!value))\n }\n >\n {columnVisibilityLabels.selectAll}\n </DropdownMenuCheckboxItem>\n <DropdownMenuSeparator className=\"bg-neutral-100\" />\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(value) => column.toggleVisibility(!!value)}\n >\n {column.columnDef.header?.toString()}\n </DropdownMenuCheckboxItem>\n )\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkDA,MAAM,aAAA,GAAgB;AAAA,EACpB,OAAA,EAAS,SAAA;AAAA,EACT,WAAA,EAAa;AACf,CAAA;AAEA,MAAM,6BAAA,GAAgC;AAAA,EACpC,MAAA,EAAQ,cAAA;AAAA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AA,EAAY,CAAA,CACtC,GAAA,CAAI,CAAC,MAAA,KAAW;AACf,cAAA,uBACE,GAAA;AAAA,gBAAC,wBAAA;AAAA,gBAAA;AAAA,kBAEC,SAAA,EAAU,YAAA;AAAA,kBACV,OAAA,EAAS,OAAO,YAAA,EAAa;AAAA,kBAC7B,QAAA,EAAU,CAAC,KAAA,KAAU,KAAA,CAAM,cAAA,EAAe;AAAA,kBAC1C,iBAAiB,CAAC,KAAA,KAAU,OAAO,gBAAA,CAAiB,CAAC,CAAC,KAAK,CAAA;AAAA,kBAE1D,QAAA,EAAA,MAAA,CAAO,SAAA,CAAU,MAAA,EAAQ,QAAA;AAAS,iBAAA;AAAA,gBAN9B,MAAA,CAAO;AAAA,eAOd;AAAA,YAEJ,CAAC;AAAA,WAAA,EACL;AAAA,SAAA,EACF;AAAA,OAAA,EAEJ;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"DataTableToolbar.js","sources":["../../../../src/components/DataTable/components/DataTableToolbar.tsx"],"sourcesContent":["import { FunnelSimple } from '@phosphor-icons/react/dist/ssr/FunnelSimple'\nimport { SelectionAll } from '@phosphor-icons/react/dist/ssr/SelectionAll'\nimport { TextColumns } from '@phosphor-icons/react/dist/ssr/TextColumns'\nimport { X } from '@phosphor-icons/react/dist/ssr/X'\nimport { Table } from '@tanstack/react-table'\nimport * as React from 'react'\n\nimport { Button } from '../../Button'\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '../../DropdownMenu'\nimport { NotificationBadge } from '../../NotificationBadge'\nimport { PopoverContent, PopoverRoot, PopoverTrigger } from '../../Popover'\nimport { Typography } from '../../Typography'\n\nimport { ColumnVisibilityConfig } from '@/components/DataTable/types'\nimport { TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger } from '@/components/Tooltip'\nimport { useIsMobile } from '@/lib/useMobile'\nimport { cn } from '@/lib/utils'\n\ntype DataTableToolbarProps<TData> = {\n readonly table: Table<TData>\n readonly columnVisibility?: ColumnVisibilityConfig\n readonly primaryFilters?: React.ReactNode\n readonly secondaryFilters?: React.ReactNode\n readonly activePrimaryFiltersCount?: number\n readonly activeSecondaryFiltersCount?: number\n readonly labels?: {\n filters?: string\n moreFilters?: string\n }\n readonly selection?: {\n isSelectionStarted?: boolean\n onSelectionStart?: () => void\n onSelectionCancel?: () => void\n selectionSummary?: string | null\n isSelectionDisabled?: boolean\n labels?: {\n startSelection?: string\n cancelSelection?: string\n selectionSummary?: string\n selectionDisabledTooltip?: string\n }\n }\n}\n\nconst defaultLabels = {\n filters: 'Filters',\n moreFilters: 'More filters',\n}\n\nconst defaultColumnVisibilityLabels = {\n button: 'Hide columns',\n selectAll: 'Select all',\n}\n\nconst defaultSelectionLabels = {\n startSelection: 'Start selection',\n cancelSelection: 'Cancel selection',\n}\n\nexport function DataTableToolbar<TData>({\n table,\n columnVisibility,\n primaryFilters,\n secondaryFilters,\n activePrimaryFiltersCount = 0,\n activeSecondaryFiltersCount = 0,\n selection,\n labels: labelsProp,\n}: DataTableToolbarProps<TData>) {\n const isMobile = useIsMobile()\n\n const labels = {\n ...defaultLabels,\n ...labelsProp,\n }\n\n const columnVisibilityLabels = {\n ...defaultColumnVisibilityLabels,\n ...columnVisibility?.labels,\n }\n\n const selectionLabels = {\n ...defaultSelectionLabels,\n ...selection?.labels,\n }\n\n const showColumnVisibilityControls = columnVisibility?.showControls ?? true\n\n const hasPrimaryFilters = !!primaryFilters\n const hasSecondaryFilters = !!secondaryFilters\n\n const showFiltersButton = isMobile ? hasPrimaryFilters || hasSecondaryFilters : hasSecondaryFilters\n\n const totalActiveFiltersCount = activePrimaryFiltersCount + activeSecondaryFiltersCount\n const activeFiltersCount = isMobile ? totalActiveFiltersCount : activeSecondaryFiltersCount\n const showBadge = activeFiltersCount > 0\n\n const filtersButtonLabel = !hasPrimaryFilters || isMobile ? labels.filters : labels.moreFilters\n\n if (!showColumnVisibilityControls && !primaryFilters && !secondaryFilters && !selection) {\n return null\n }\n\n return (\n <div className=\"flex shrink-0 flex-col gap-2 p-1\">\n {!isMobile && primaryFilters && <div className=\"flex flex-wrap items-center gap-2\">{primaryFilters}</div>}\n\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n {selection && (\n <div className=\"flex items-center gap-2\">\n {selection.isSelectionStarted ? (\n <>\n <Button variant=\"text\" size=\"sm\" StartIcon={X} onClick={selection.onSelectionCancel}>\n {selectionLabels.cancelSelection}\n </Button>\n {selection.selectionSummary && !isMobile && (\n <Typography variant=\"body-sm\" className=\"text-neutral-600\">\n {selection.selectionSummary}\n </Typography>\n )}\n </>\n ) : (\n <TooltipProvider>\n <TooltipRoot delayDuration={200}>\n <TooltipTrigger asChild>\n <div>\n <Button\n variant=\"text\"\n size=\"sm\"\n StartIcon={SelectionAll}\n onClick={selection.onSelectionStart}\n disabled={selection.isSelectionDisabled}\n >\n {selectionLabels.startSelection}\n </Button>\n </div>\n </TooltipTrigger>\n {selection.labels?.selectionDisabledTooltip && selection.isSelectionDisabled && (\n <TooltipContent>{selection.labels.selectionDisabledTooltip}</TooltipContent>\n )}\n </TooltipRoot>\n </TooltipProvider>\n )}\n </div>\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {showFiltersButton && (\n <PopoverRoot>\n <PopoverTrigger asChild>\n <Button variant=\"text\" size=\"sm\" StartIcon={FunnelSimple} className=\"relative whitespace-nowrap\">\n {showBadge && (\n <NotificationBadge\n count={activeFiltersCount}\n color=\"primary\"\n ping={false}\n className=\"absolute -top-1 -right-1\"\n />\n )}\n {filtersButtonLabel}\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align=\"center\"\n className={cn('w-fit p-4', isMobile && 'max-h-[80vh] w-[95vw] overflow-y-auto')}\n >\n <div className=\"flex flex-col gap-4\">\n {isMobile && primaryFilters}\n {secondaryFilters}\n </div>\n </PopoverContent>\n </PopoverRoot>\n )}\n {showColumnVisibilityControls && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"text\" size=\"sm\" className={cn('whitespace-nowrap')} StartIcon={TextColumns}>\n {columnVisibilityLabels.button}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuCheckboxItem\n key={'all-columns'}\n className=\"capitalize\"\n checked={table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .every((column) => column.getIsVisible())}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(value) =>\n table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .forEach((column) => column.toggleVisibility(!!value))\n }\n >\n {columnVisibilityLabels.selectAll}\n </DropdownMenuCheckboxItem>\n <DropdownMenuSeparator className=\"bg-neutral-100\" />\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(value) => column.toggleVisibility(!!value)}\n >\n {column.columnDef.header?.toString()}\n </DropdownMenuCheckboxItem>\n )\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkDA,MAAM,aAAA,GAAgB;AAAA,EACpB,OAAA,EAAS,SAAA;AAAA,EACT,WAAA,EAAa;AACf,CAAA;AAEA,MAAM,6BAAA,GAAgC;AAAA,EACpC,MAAA,EAAQ,cAAA;AAAA,EACR,SAAA,EAAW;AACb,CAAA;AAEA,MAAM,sBAAA,GAAyB;AAAA,EAC7B,cAAA,EAAgB,iBAAA;AAAA,EAChB,eAAA,EAAiB;AACnB,CAAA;AAEO,SAAS,gBAAA,CAAwB;AAAA,EACtC,KAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,gBAAA;AAAA,EACA,yBAAA,GAA4B,CAAA;AAAA,EAC5B,2BAAA,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AAC,KAAA,KAAU,OAAO,gBAAA,CAAiB,CAAC,CAAC,KAAK,CAAA;AAAA,kBAE1D,QAAA,EAAA,MAAA,CAAO,SAAA,CAAU,MAAA,EAAQ,QAAA;AAAS,iBAAA;AAAA,gBAN9B,MAAA,CAAO;AAAA,eAOd;AAAA,YAEJ,CAAC;AAAA,WAAA,EACL;AAAA,SAAA,EACF;AAAA,OAAA,EAEJ;AAAA,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -25,7 +25,7 @@ declare const FormMessage: React.ForwardRefExoticComponent<{
|
|
|
25
25
|
asChild?: boolean;
|
|
26
26
|
} & React.BaseHTMLAttributes<HTMLParagraphElement> & import('class-variance-authority').VariantProps<(props?: ({
|
|
27
27
|
variant?: "display-lg" | "display-md" | "display-sm" | "headline-lg" | "headline-md" | "headline-sm" | "title-lg" | "title-md" | "title-sm" | "label-lg" | "label-md" | "label-sm" | "body-lg" | "body-md" | "body-sm" | null | undefined;
|
|
28
|
-
weight?: "bold" | "
|
|
28
|
+
weight?: "bold" | "medium" | "regular" | "semibold" | null | undefined;
|
|
29
29
|
family?: "onest" | null | undefined;
|
|
30
30
|
color?: "primary" | "accent" | "success" | "warning" | "error" | "neutral" | "inverse" | "secondary" | null | undefined;
|
|
31
31
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string> & React.RefAttributes<HTMLParagraphElement>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare const notificationBadgeVariants: (props?: ({
|
|
3
|
+
color?: "primary" | "accent" | "success" | "warning" | "error" | "neutral" | null | undefined;
|
|
4
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
5
|
+
position?: "top-right" | "top-left" | "bottom-right" | "bottom-left" | null | undefined;
|
|
6
|
+
numeric?: boolean | null | undefined;
|
|
7
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
8
|
+
export type NotificationBadgeProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Controls the visibility of the pulsing animation effect
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
ping?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The color variant of the badge
|
|
16
|
+
* @default 'accent'
|
|
17
|
+
*/
|
|
18
|
+
color?: 'neutral' | 'accent' | 'primary' | 'success' | 'warning' | 'error';
|
|
19
|
+
/**
|
|
20
|
+
* The size of the badge
|
|
21
|
+
* @default 'md'
|
|
22
|
+
*/
|
|
23
|
+
size?: 'sm' | 'md' | 'lg';
|
|
24
|
+
/**
|
|
25
|
+
* The position of the badge relative to its container
|
|
26
|
+
* @default 'top-right'
|
|
27
|
+
*/
|
|
28
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
29
|
+
/**
|
|
30
|
+
* The number to display in the badge
|
|
31
|
+
*/
|
|
32
|
+
count?: number;
|
|
33
|
+
} & React.HTMLAttributes<HTMLElement>;
|
|
34
|
+
/**
|
|
35
|
+
* A dot or counter positioned absolutely over an icon or avatar, used to
|
|
36
|
+
* show a notification, status, or draw attention to an element.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* // Simple notification badge
|
|
41
|
+
* <div className="relative">
|
|
42
|
+
* <Bell className="h-6 w-6" />
|
|
43
|
+
* <NotificationBadge color="error" />
|
|
44
|
+
* </div>
|
|
45
|
+
*
|
|
46
|
+
* // Custom size and position
|
|
47
|
+
* <div className="relative">
|
|
48
|
+
* <Avatar />
|
|
49
|
+
* <NotificationBadge
|
|
50
|
+
* color="success"
|
|
51
|
+
* size="sm"
|
|
52
|
+
* position="bottom-right"
|
|
53
|
+
* ping={false}
|
|
54
|
+
* />
|
|
55
|
+
* </div>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare const NotificationBadge: React.ForwardRefExoticComponent<{
|
|
59
|
+
/**
|
|
60
|
+
* Controls the visibility of the pulsing animation effect
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
ping?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The color variant of the badge
|
|
66
|
+
* @default 'accent'
|
|
67
|
+
*/
|
|
68
|
+
color?: "neutral" | "accent" | "primary" | "success" | "warning" | "error";
|
|
69
|
+
/**
|
|
70
|
+
* The size of the badge
|
|
71
|
+
* @default 'md'
|
|
72
|
+
*/
|
|
73
|
+
size?: "sm" | "md" | "lg";
|
|
74
|
+
/**
|
|
75
|
+
* The position of the badge relative to its container
|
|
76
|
+
* @default 'top-right'
|
|
77
|
+
*/
|
|
78
|
+
position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
79
|
+
/**
|
|
80
|
+
* The number to display in the badge
|
|
81
|
+
*/
|
|
82
|
+
count?: number;
|
|
83
|
+
} & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLSpanElement>>;
|
|
84
|
+
export { NotificationBadge, notificationBadgeVariants };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../lib/utils.js';
|
|
5
|
+
|
|
6
|
+
const notificationBadgeVariants = cva("rounded-full", {
|
|
7
|
+
variants: {
|
|
8
|
+
color: {
|
|
9
|
+
neutral: "bg-neutral text-neutral-foreground",
|
|
10
|
+
accent: "bg-accent text-accent-foreground",
|
|
11
|
+
primary: "bg-primary text-primary-foreground",
|
|
12
|
+
success: "bg-success text-success-foreground ",
|
|
13
|
+
warning: "bg-warning text-warning-foreground",
|
|
14
|
+
error: "bg-error text-error-foreground"
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
sm: "h-2 w-2",
|
|
18
|
+
md: "h-3 w-3",
|
|
19
|
+
lg: "h-4 w-4"
|
|
20
|
+
},
|
|
21
|
+
position: {
|
|
22
|
+
"top-right": "right-0 top-0",
|
|
23
|
+
"top-left": "left-0 top-0",
|
|
24
|
+
"bottom-right": "right-0 bottom-0",
|
|
25
|
+
"bottom-left": "left-0 bottom-0"
|
|
26
|
+
},
|
|
27
|
+
numeric: {
|
|
28
|
+
true: "min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-medium",
|
|
29
|
+
false: ""
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
color: "primary",
|
|
34
|
+
size: "md",
|
|
35
|
+
position: "top-right",
|
|
36
|
+
numeric: false
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const NotificationBadge = React.forwardRef(
|
|
40
|
+
({ className, color = "accent", size = "md", position = "top-right", ping = true, count, ...props }, ref) => {
|
|
41
|
+
const sizeClasses = {
|
|
42
|
+
sm: "h-2 w-2",
|
|
43
|
+
md: "h-3 w-3",
|
|
44
|
+
lg: "h-4 w-4"
|
|
45
|
+
}[size || "md"];
|
|
46
|
+
return /* @__PURE__ */ jsxs(
|
|
47
|
+
"span",
|
|
48
|
+
{
|
|
49
|
+
className: cn(
|
|
50
|
+
"absolute flex",
|
|
51
|
+
notificationBadgeVariants({ color, position, numeric: !!count }),
|
|
52
|
+
!count && sizeClasses,
|
|
53
|
+
className
|
|
54
|
+
),
|
|
55
|
+
ref,
|
|
56
|
+
...props,
|
|
57
|
+
children: [
|
|
58
|
+
ping && /* @__PURE__ */ jsx(
|
|
59
|
+
"span",
|
|
60
|
+
{
|
|
61
|
+
className: cn(
|
|
62
|
+
notificationBadgeVariants({ color }),
|
|
63
|
+
"absolute inline-flex h-full w-full animate-ping opacity-75"
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
"span",
|
|
69
|
+
{
|
|
70
|
+
className: cn(
|
|
71
|
+
notificationBadgeVariants({ color }),
|
|
72
|
+
"relative inline-flex h-full w-full items-center justify-center"
|
|
73
|
+
),
|
|
74
|
+
children: count
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
NotificationBadge.displayName = "NotificationBadge";
|
|
83
|
+
|
|
84
|
+
export { NotificationBadge, notificationBadgeVariants };
|
|
85
|
+
//# sourceMappingURL=NotificationBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationBadge.js","sources":["../../../src/components/NotificationBadge/NotificationBadge.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { cn } from '../../lib/utils'\n\nconst notificationBadgeVariants = cva('rounded-full', {\n variants: {\n color: {\n neutral: 'bg-neutral text-neutral-foreground',\n accent: 'bg-accent text-accent-foreground',\n primary: 'bg-primary text-primary-foreground',\n success: 'bg-success text-success-foreground ',\n warning: 'bg-warning text-warning-foreground',\n error: 'bg-error text-error-foreground',\n },\n size: {\n sm: 'h-2 w-2',\n md: 'h-3 w-3',\n lg: 'h-4 w-4',\n },\n position: {\n 'top-right': 'right-0 top-0',\n 'top-left': 'left-0 top-0',\n 'bottom-right': 'right-0 bottom-0',\n 'bottom-left': 'left-0 bottom-0',\n },\n numeric: {\n true: 'min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-medium',\n false: '',\n },\n },\n defaultVariants: {\n color: 'primary',\n size: 'md',\n position: 'top-right',\n numeric: false,\n },\n})\n\nexport type NotificationBadgeProps = {\n /**\n * Controls the visibility of the pulsing animation effect\n * @default true\n */\n ping?: boolean\n\n /**\n * The color variant of the badge\n * @default 'accent'\n */\n color?: 'neutral' | 'accent' | 'primary' | 'success' | 'warning' | 'error'\n\n /**\n * The size of the badge\n * @default 'md'\n */\n size?: 'sm' | 'md' | 'lg'\n\n /**\n * The position of the badge relative to its container\n * @default 'top-right'\n */\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n\n /**\n * The number to display in the badge\n */\n count?: number\n} & React.HTMLAttributes<HTMLElement>\n\n/**\n * A dot or counter positioned absolutely over an icon or avatar, used to\n * show a notification, status, or draw attention to an element.\n *\n * @example\n * ```tsx\n * // Simple notification badge\n * <div className=\"relative\">\n * <Bell className=\"h-6 w-6\" />\n * <NotificationBadge color=\"error\" />\n * </div>\n *\n * // Custom size and position\n * <div className=\"relative\">\n * <Avatar />\n * <NotificationBadge\n * color=\"success\"\n * size=\"sm\"\n * position=\"bottom-right\"\n * ping={false}\n * />\n * </div>\n * ```\n */\nconst NotificationBadge = React.forwardRef<HTMLSpanElement, NotificationBadgeProps>(\n ({ className, color = 'accent', size = 'md', position = 'top-right', ping = true, count, ...props }, ref) => {\n const sizeClasses = {\n sm: 'h-2 w-2',\n md: 'h-3 w-3',\n lg: 'h-4 w-4',\n }[size || 'md']\n\n return (\n <span\n className={cn(\n 'absolute flex',\n notificationBadgeVariants({ color, position, numeric: !!count }),\n !count && sizeClasses,\n className,\n )}\n ref={ref}\n {...props}\n >\n {ping && (\n <span\n className={cn(\n notificationBadgeVariants({ color }),\n 'absolute inline-flex h-full w-full animate-ping opacity-75',\n )}\n />\n )}\n <span\n className={cn(\n notificationBadgeVariants({ color }),\n 'relative inline-flex h-full w-full items-center justify-center',\n )}\n >\n {count}\n </span>\n </span>\n )\n },\n)\n\nNotificationBadge.displayName = 'NotificationBadge'\n\nexport { NotificationBadge, notificationBadgeVariants }\n"],"names":[],"mappings":";;;;;AAKA,MAAM,yBAAA,GAA4B,IAAI,cAAA,EAAgB;AAAA,EACpD,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA,MACL,OAAA,EAAS,oCAAA;AAAA,MACT,MAAA,EAAQ,kCAAA;AAAA,MACR,OAAA,EAAS,oCAAA;AAAA,MACT,OAAA,EAAS,sCAAA;AAAA,MACT,OAAA,EAAS,oCAAA;AAAA,MACT,KAAA,EAAO;AAAA,KACT;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,EAAA,EAAI,SAAA;AAAA,MACJ,EAAA,EAAI,SA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AA;AAAA,gBACnC;AAAA;AACF;AAAA,WACF;AAAA,0BAEF,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAW,EAAA;AAAA,gBACT,yBAAA,CAA0B,EAAE,KAAA,EAAO,CAAA;AAAA,gBACnC;AAAA,eACF;AAAA,cAEC,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AAEA,iBAAA,CAAkB,WAAA,GAAc,mBAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NotificationBadge';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,58 +1,42 @@
|
|
|
1
|
-
import { PhoneCountry } from './
|
|
1
|
+
import { PhoneCountry, PhoneInputCountryAccessors, PhoneValue } from './types';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
export type PhoneInputCountryAccessors<T> = {
|
|
4
|
-
/** Returns the unique key used to identify a country in the selector. */
|
|
5
|
-
getCountryValue: (country: T) => string;
|
|
6
|
-
/** Returns the E.164 dial code, including the leading "+", e.g. "+34". */
|
|
7
|
-
getCountryDialCode: (country: T) => string;
|
|
8
|
-
/** Returns the flag emoji (or any other leading glyph) for a country. */
|
|
9
|
-
getCountryFlag: (country: T) => string;
|
|
10
|
-
/** Returns the display name used for search and the option list. */
|
|
11
|
-
getCountryName: (country: T) => string;
|
|
12
|
-
};
|
|
13
|
-
/** Props unrelated to the country shape, shared by both usage modes. */
|
|
14
3
|
type PhoneInputBaseProps = {
|
|
15
|
-
/**
|
|
4
|
+
/** Lands on the number input, so `<label htmlFor>` targets it. */
|
|
16
5
|
id?: string;
|
|
17
|
-
/** Name applied to the number input. */
|
|
18
6
|
name?: string;
|
|
19
|
-
/** Classes for the outer wrapper. */
|
|
20
7
|
className?: string;
|
|
21
|
-
/** Classes for the country selector trigger button. */
|
|
22
|
-
prefixClassName?: string;
|
|
23
|
-
/** Classes for the number `<input>` element. */
|
|
24
|
-
numberClassName?: string;
|
|
25
8
|
disabled?: boolean;
|
|
26
|
-
error?: boolean
|
|
27
|
-
|
|
9
|
+
error?: boolean;
|
|
10
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
11
|
+
/** Controlled when set, otherwise seeded by `defaultCountry`. */
|
|
28
12
|
country?: string;
|
|
29
|
-
/**
|
|
13
|
+
/** National digits, no country code or separators. */
|
|
30
14
|
number?: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
/**
|
|
15
|
+
onChange?: (value: PhoneValue) => void;
|
|
16
|
+
/** ISO code, used when `country` is uncontrolled. */
|
|
17
|
+
defaultCountry?: string;
|
|
18
|
+
/** ISO codes pinned above the list, in order. */
|
|
19
|
+
priorityCountries?: Array<string>;
|
|
20
|
+
numberInputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'id' | 'name' | 'disabled' | 'value' | 'onChange' | 'onKeyDown' | 'className'>;
|
|
21
|
+
/** Defaults to the country's example number. */
|
|
35
22
|
placeholder?: string;
|
|
36
|
-
/** Accessible label for the country selector trigger (announced by screen readers; not visible). */
|
|
37
23
|
countryAriaLabel?: string;
|
|
38
|
-
/** Placeholder for the country search field. */
|
|
39
24
|
searchPlaceholder?: string;
|
|
40
|
-
/** Message shown when no country matches the search. */
|
|
41
25
|
emptyMessage?: string;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
26
|
+
'aria-describedby'?: string;
|
|
27
|
+
'aria-invalid'?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type ResolvedPhoneInputProps<T extends object> = PhoneInputBaseProps & Partial<PhoneInputCountryAccessors<T>> & {
|
|
30
|
+
/** Defaults to the generated list. */
|
|
31
|
+
countries?: Array<T>;
|
|
32
|
+
/** Names the generated list. Ignored when `countries` is passed. */
|
|
33
|
+
locale?: string;
|
|
34
|
+
onChange?: (value: PhoneValue<T>) => void;
|
|
49
35
|
};
|
|
50
|
-
|
|
36
|
+
export type PhoneInputDefaultProps = ResolvedPhoneInputProps<PhoneCountry>;
|
|
51
37
|
export type PhoneInputCustomProps<T extends object> = PhoneInputBaseProps & PhoneInputCountryAccessors<T> & {
|
|
52
|
-
/** Backend-driven / custom country list. */
|
|
53
38
|
countries: Array<T>;
|
|
54
|
-
|
|
55
|
-
onCountryChange?: (country: T) => void;
|
|
39
|
+
onChange?: (value: PhoneValue<T>) => void;
|
|
56
40
|
};
|
|
57
41
|
export type PhoneInputProps<T extends object = PhoneCountry> = PhoneInputDefaultProps | PhoneInputCustomProps<T>;
|
|
58
42
|
export declare function PhoneInput(props: PhoneInputDefaultProps): React.ReactElement;
|