@eml-payments/ui-kit 0.1.0 → 0.1.1

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 (114) hide show
  1. package/README.md +3 -2
  2. package/dist/components/Button/Button.js +40 -0
  3. package/dist/components/Button/Button.stories.js +59 -0
  4. package/dist/components/Button/Button.types.js +1 -0
  5. package/dist/components/Button/index.js +1 -0
  6. package/dist/components/Checkbox/Checkbox.js +21 -0
  7. package/dist/components/Checkbox/Checkbox.stories.js +45 -0
  8. package/dist/components/Checkbox/Checkbox.types.js +1 -0
  9. package/dist/components/Checkbox/index.js +2 -0
  10. package/dist/components/Divider/Divider.js +8 -0
  11. package/dist/components/Divider/Divider.stories.js +20 -0
  12. package/dist/components/Divider/Divider.types.js +1 -0
  13. package/dist/components/Divider/index.js +1 -0
  14. package/dist/components/Ellipsis/Ellipsis.functions.js +8 -0
  15. package/dist/components/Ellipsis/Ellipsis.js +7 -0
  16. package/dist/components/Ellipsis/Ellipsis.stories.js +27 -0
  17. package/dist/components/Ellipsis/Ellipsis.types.js +1 -0
  18. package/dist/components/Ellipsis/index.js +1 -0
  19. package/dist/components/Input/Input.js +8 -0
  20. package/dist/components/Input/Input.stories.js +45 -0
  21. package/dist/components/Input/Input.types.js +1 -0
  22. package/dist/components/Input/index.js +2 -0
  23. package/dist/components/Label/Label.js +9 -0
  24. package/dist/components/Label/Label.stories.js +17 -0
  25. package/dist/components/Label/Label.types.js +1 -0
  26. package/dist/components/Label/index.js +2 -0
  27. package/dist/components/RadioGroup/RadioGroup.js +14 -0
  28. package/dist/components/RadioGroup/RadioGroup.stories.js +29 -0
  29. package/dist/components/RadioGroup/RadioGroup.types.js +1 -0
  30. package/dist/components/RadioGroup/index.js +2 -0
  31. package/dist/components/Switch/Switch.js +35 -0
  32. package/dist/components/Switch/Switch.stories.js +47 -0
  33. package/dist/components/Switch/Switch.types.js +1 -0
  34. package/dist/components/Switch/index.js +2 -0
  35. package/dist/components/Table/Table.js +120 -0
  36. package/dist/components/Table/Table.stories.js +19 -0
  37. package/dist/components/Table/Table.types.js +1 -0
  38. package/dist/components/Table/index.js +2 -0
  39. package/dist/components/Tooltip/Tooltip.js +10 -0
  40. package/dist/components/Tooltip/Tooltip.stories.js +19 -0
  41. package/dist/components/Tooltip/Tooltip.types.js +1 -0
  42. package/dist/components/Tooltip/index.js +1 -0
  43. package/dist/config/defaultTheme.js +20 -0
  44. package/dist/config/index.js +2 -0
  45. package/dist/config/uikitConfig.js +1 -0
  46. package/dist/context/UIKitContext.js +4 -0
  47. package/dist/context/UIKitProvider.js +32 -0
  48. package/dist/context/useUIKitTheme.js +1 -0
  49. package/dist/hooks/useToggle.js +6 -0
  50. package/dist/index.js +6 -0
  51. package/dist/lib/utils.js +5 -0
  52. package/dist/stories/Header.js +4 -0
  53. package/dist/stories/Header.stories.js +26 -0
  54. package/dist/stories/Page.js +8 -0
  55. package/dist/stories/Page.stories.js +24 -0
  56. package/dist/types/components/Button/Button.d.ts +7 -0
  57. package/dist/types/components/Button/Button.stories.d.ts +16 -0
  58. package/dist/types/components/Button/Button.types.d.ts +8 -0
  59. package/dist/types/components/Button/index.d.ts +1 -0
  60. package/dist/types/components/Checkbox/Checkbox.d.ts +5 -0
  61. package/dist/types/components/Checkbox/Checkbox.stories.d.ts +13 -0
  62. package/dist/types/components/Checkbox/Checkbox.types.d.ts +6 -0
  63. package/dist/types/components/Checkbox/index.d.ts +2 -0
  64. package/dist/types/components/Divider/Divider.d.ts +3 -0
  65. package/dist/types/components/Divider/Divider.stories.d.ts +8 -0
  66. package/dist/types/components/Divider/Divider.types.d.ts +5 -0
  67. package/dist/types/components/Divider/index.d.ts +1 -0
  68. package/dist/types/components/Ellipsis/Ellipsis.d.ts +3 -0
  69. package/dist/types/components/Ellipsis/Ellipsis.functions.d.ts +1 -0
  70. package/dist/types/components/Ellipsis/Ellipsis.stories.d.ts +7 -0
  71. package/dist/types/components/Ellipsis/Ellipsis.types.d.ts +7 -0
  72. package/dist/types/components/Ellipsis/index.d.ts +1 -0
  73. package/dist/types/components/Input/Input.d.ts +3 -0
  74. package/dist/types/components/Input/Input.stories.d.ts +15 -0
  75. package/dist/types/components/Input/Input.types.d.ts +7 -0
  76. package/dist/types/components/Input/index.d.ts +2 -0
  77. package/dist/types/components/Label/Label.d.ts +5 -0
  78. package/dist/types/components/Label/Label.stories.d.ts +7 -0
  79. package/dist/types/components/Label/Label.types.d.ts +3 -0
  80. package/dist/types/components/Label/index.d.ts +2 -0
  81. package/dist/types/components/RadioGroup/RadioGroup.d.ts +5 -0
  82. package/dist/types/components/RadioGroup/RadioGroup.stories.d.ts +9 -0
  83. package/dist/types/components/RadioGroup/RadioGroup.types.d.ts +5 -0
  84. package/dist/types/components/RadioGroup/index.d.ts +2 -0
  85. package/dist/types/components/Switch/Switch.d.ts +5 -0
  86. package/dist/types/components/Switch/Switch.stories.d.ts +12 -0
  87. package/dist/types/components/Switch/Switch.types.d.ts +6 -0
  88. package/dist/types/components/Switch/index.d.ts +2 -0
  89. package/dist/types/components/Table/Table.d.ts +36 -0
  90. package/dist/types/components/Table/Table.stories.d.ts +9 -0
  91. package/dist/types/components/Table/Table.types.d.ts +4 -0
  92. package/dist/types/components/Table/index.d.ts +2 -0
  93. package/dist/types/components/Tooltip/Tooltip.d.ts +7 -0
  94. package/dist/types/components/Tooltip/Tooltip.stories.d.ts +9 -0
  95. package/dist/types/components/Tooltip/Tooltip.types.d.ts +5 -0
  96. package/dist/types/components/Tooltip/index.d.ts +1 -0
  97. package/dist/types/config/defaultTheme.d.ts +2 -0
  98. package/dist/types/config/index.d.ts +2 -0
  99. package/dist/types/config/uikitConfig.d.ts +19 -0
  100. package/dist/types/context/UIKitContext.d.ts +4 -0
  101. package/dist/types/context/UIKitProvider.d.ts +5 -0
  102. package/dist/types/context/useUIKitTheme.d.ts +1 -0
  103. package/dist/types/hooks/useToggle.d.ts +1 -0
  104. package/dist/types/index.d.ts +6 -0
  105. package/dist/types/index.js +1 -0
  106. package/dist/types/lib/utils.d.ts +2 -0
  107. package/dist/types/stories/Header.d.ts +12 -0
  108. package/dist/types/stories/Header.stories.d.ts +18 -0
  109. package/dist/types/stories/Page.d.ts +3 -0
  110. package/dist/types/stories/Page.stories.d.ts +12 -0
  111. package/dist/types/types/index.d.ts +1 -0
  112. package/dist/types/utils/classNames.d.ts +1 -0
  113. package/dist/utils/classNames.js +3 -0
  114. package/package.json +75 -74
@@ -0,0 +1,120 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { flexRender, getCoreRowModel, getPaginationRowModel, useReactTable, } from '@tanstack/react-table';
3
+ import { useEffect, useMemo, useState } from 'react';
4
+ import { Button } from '../Button';
5
+ export function Table({ data, search, columns, selected, pageSize, rowIdKey, setSearch, pageIndex, pageCount, rowActions, setSelected, onSortChange, tableActions, onPageChange, onPageSizeChange, sortableFields = [], }) {
6
+ const [inputValue, setInputValue] = useState(search !== null && search !== void 0 ? search : '');
7
+ useEffect(() => {
8
+ if (setSearch) {
9
+ setSearch(inputValue);
10
+ if (onPageChange) {
11
+ onPageChange(0);
12
+ }
13
+ }
14
+ }, [inputValue, setSearch, onPageChange]);
15
+ const [sortingField, setSortingField] = useState(undefined);
16
+ const [sortingDirection, setSortingDirection] = useState(undefined);
17
+ function handleSortClick(key) {
18
+ if (!key || !sortableFields.includes(key)) {
19
+ return;
20
+ }
21
+ let nextDir;
22
+ if (sortingField !== key) {
23
+ nextDir = 'asc';
24
+ }
25
+ else if (sortingDirection === 'asc') {
26
+ nextDir = 'desc';
27
+ }
28
+ else if (sortingDirection === 'desc') {
29
+ nextDir = undefined;
30
+ }
31
+ else {
32
+ nextDir = 'asc';
33
+ }
34
+ setSortingField(nextDir ? key : undefined);
35
+ setSortingDirection(nextDir);
36
+ onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(nextDir ? key : undefined, nextDir);
37
+ }
38
+ const isSelectionEnabled = selected !== undefined && setSelected !== undefined;
39
+ const isPaginationEnabled = pageIndex !== undefined &&
40
+ pageSize !== undefined &&
41
+ pageCount !== undefined &&
42
+ onPageChange !== undefined &&
43
+ onPageSizeChange !== undefined;
44
+ function getAccessorKey(col) {
45
+ return 'accessorKey' in col && typeof col.accessorKey === 'string' ? col.accessorKey : undefined;
46
+ }
47
+ const internalColumns = useMemo(() => {
48
+ const result = [];
49
+ if (isSelectionEnabled) {
50
+ result.unshift({
51
+ id: '__select__',
52
+ accessorFn: (row) => row,
53
+ enableSorting: false,
54
+ header: ({ table }) => {
55
+ return (_jsx("input", { type: "checkbox", checked: table.getIsAllPageRowsSelected(), onChange: table.getToggleAllRowsSelectedHandler() }));
56
+ },
57
+ cell: ({ row }) => {
58
+ return (_jsx("input", { type: "checkbox", checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler() }));
59
+ },
60
+ });
61
+ }
62
+ for (const col of columns) {
63
+ const key = getAccessorKey(col);
64
+ result.push({
65
+ ...col,
66
+ enableSorting: key ? sortableFields.includes(key) : false,
67
+ });
68
+ }
69
+ if (rowActions) {
70
+ result.push({
71
+ id: '__actions__',
72
+ accessorFn: (row) => row,
73
+ enableSorting: false,
74
+ header: 'Actions',
75
+ cell: (info) => (_jsx("div", { className: "flex gap-2", children: rowActions.map((action) => (_jsx(Button, { title: action.title, "aria-label": action.title, className: action.className, onClick: () => action.fn(info.row.original), children: action.icon }, action.title))) })),
76
+ });
77
+ }
78
+ return result;
79
+ }, [columns, sortableFields, rowActions, isSelectionEnabled]);
80
+ const table = useReactTable({
81
+ data,
82
+ manualSorting: true,
83
+ columns: internalColumns,
84
+ getCoreRowModel: getCoreRowModel(),
85
+ manualPagination: isPaginationEnabled,
86
+ enableRowSelection: isSelectionEnabled,
87
+ ...(rowIdKey && {
88
+ getRowId: (row) => String(row[rowIdKey]),
89
+ }),
90
+ ...(isPaginationEnabled && { getPaginationRowModel: getPaginationRowModel() }),
91
+ state: {
92
+ ...(isSelectionEnabled && { rowSelection: selected }),
93
+ ...(isPaginationEnabled && { pagination: { pageIndex, pageSize } }),
94
+ },
95
+ ...(isSelectionEnabled && { onRowSelectionChange: setSelected }),
96
+ ...(isPaginationEnabled && {
97
+ onPaginationChange: (updater) => {
98
+ const next = typeof updater === 'function' ? updater({ pageIndex, pageSize }) : updater;
99
+ onPageChange(next.pageIndex);
100
+ onPageSizeChange(next.pageSize);
101
+ },
102
+ }),
103
+ });
104
+ let sortIcon;
105
+ if (sortingDirection === 'asc') {
106
+ sortIcon = ' 🔼';
107
+ }
108
+ else if (sortingDirection === 'desc') {
109
+ sortIcon = ' 🔽';
110
+ }
111
+ else {
112
+ sortIcon = null;
113
+ }
114
+ return (_jsxs("div", { children: [_jsxs("div", { className: "flex justify-between", children: [setSearch && (_jsx("div", { className: "mb-4", children: _jsx("input", { type: "text", value: inputValue, placeholder: "Search\u2026", className: "border px-3 py-2 w-full max-w-sm", onChange: (e) => setInputValue(e.target.value) }) })), tableActions && (_jsx("div", { className: "mb-2 flex gap-2", children: tableActions.map((action) => (_jsxs(Button, { onClick: action.fn, title: action.title, "aria-label": action.title, className: action.className, children: [action.icon, action.title] }, action.title))) }))] }), _jsxs("table", { className: "table-auto w-full border border-gray-300 border-collapse", children: [_jsx("thead", { children: table.getHeaderGroups().map((headerGroup) => (_jsx("tr", { className: "bg-gray-100", children: headerGroup.headers.map((header) => {
115
+ const key = getAccessorKey(header.column.columnDef);
116
+ return (_jsx("th", { className: "border border-gray-300 px-4 py-2 text-left", children: header.isPlaceholder ? null : (_jsxs("div", { className: header.column.getCanSort()
117
+ ? 'cursor-pointer select-none'
118
+ : undefined, onClick: () => handleSortClick(key), children: [flexRender(header.column.columnDef.header, header.getContext()), sortingField === key && sortIcon] })) }, header.id));
119
+ }) }, headerGroup.id))) }), _jsx("tbody", { children: table.getRowModel().rows.length ? (table.getRowModel().rows.map((row) => (_jsx("tr", { className: row.getIsSelected() ? 'bg-blue-100' : undefined, children: row.getVisibleCells().map((cell) => (_jsx("td", { className: "border border-gray-300 px-4 py-2", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id)))) : (_jsx("tr", { children: _jsx("td", { colSpan: internalColumns.length, children: _jsx("div", { className: "p-4 text-center", children: _jsx("h2", { children: "\u041D\u044F\u043C\u0430 \u043D\u0430\u043B\u0438\u0447\u043D\u0438 \u0434\u0430\u043D\u043D\u0438" }) }) }) })) })] }), isPaginationEnabled && (_jsxs("div", { className: "mt-4 flex items-center gap-2", children: [_jsx("button", { onClick: () => onPageChange(pageIndex - 1), disabled: pageIndex === 0, className: "px-3 py-1 bg-gray-200 rounded disabled:opacity-50", children: "Previous" }), _jsx("button", { onClick: () => onPageChange(pageIndex + 1), disabled: pageIndex + 1 >= pageCount, className: "px-3 py-1 bg-gray-200 rounded disabled:opacity-50", children: "Next" }), _jsxs("span", { className: "ml-2", children: ["Page ", pageIndex + 1, " of ", pageCount] }), _jsx("select", { value: pageSize, onChange: (e) => onPageSizeChange(Number(e.target.value)), className: "ml-4 border border-gray-300 px-2 py-1", children: [10, 20, 30, 50].map((size) => (_jsxs("option", { value: size, children: ["Show ", size] }, size))) })] }))] }));
120
+ }
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Table } from './Table';
3
+ const data = [
4
+ { name: 'Alice', email: 'alice@email.com', role: 'Admin' },
5
+ { name: 'Bob', email: 'bob@email.com', role: 'User' },
6
+ { name: 'Charlie', email: 'charlie@email.com', role: 'User' },
7
+ ];
8
+ const columns = [
9
+ { header: 'Name', accessorKey: 'name' },
10
+ { header: 'Email', accessorKey: 'email' },
11
+ { header: 'Role', accessorKey: 'role' },
12
+ ];
13
+ export default {
14
+ title: 'UIKit/Table',
15
+ component: Table,
16
+ };
17
+ export const Basic = {
18
+ render: () => _jsx(Table, { data: data, columns: columns }),
19
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './Table';
2
+ export * from './Table.types';
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
4
+ import { cn } from '../../lib/utils';
5
+ const TooltipProvider = TooltipPrimitive.Provider;
6
+ const Tooltip = TooltipPrimitive.Root;
7
+ const TooltipTrigger = TooltipPrimitive.Trigger;
8
+ const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn('z-50 overflow-hidden rounded-md bg-[var(--uikit-info)] px-3 py-1.5 text-xs text-[var(--uikit-text-primary)] font-[var(--uikit-font-family)] break-words max-w-xs sm:max-w-sm md:max-w-md', className), ...props }) })));
9
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
10
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from './Tooltip';
3
+ import { Button } from '../Button';
4
+ export const TooltipStoryWrapper = ({ content, children, ...props }) => (_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: children }), _jsx(TooltipContent, { ...props, children: content })] }) }));
5
+ const meta = {
6
+ title: 'UIKit/Tooltip',
7
+ component: TooltipContent,
8
+ tags: ['autodocs'],
9
+ };
10
+ export default meta;
11
+ export const Default = {
12
+ render: () => (_jsx(TooltipStoryWrapper, { content: "Simple tooltip", children: _jsx(Button, { children: "Hover me" }) })),
13
+ };
14
+ export const LongTextResponsive = {
15
+ render: () => (_jsx(TooltipProvider, { children: _jsxs(Tooltip, { delayDuration: 100, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { variant: "outlined", children: "Hover me" }) }), _jsx(TooltipContent, { side: "top", className: "max-w-xs sm:max-w-sm md:max-w-md break-words", children: "This tooltip contains a longer message that wraps gracefully across multiple lines. On smaller screens, it narrows and stacks vertically so it's easier to read\u2014especially useful for accessibility, mobile devices, or multi-language support." })] }) })),
16
+ };
17
+ export const OnDifferentSides = {
18
+ render: () => (_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx(TooltipStoryWrapper, { content: "Top tooltip", side: "top", children: _jsx(Button, { children: "Top" }) }), _jsx(TooltipStoryWrapper, { content: "Bottom tooltip", side: "bottom", children: _jsx(Button, { children: "Bottom" }) }), _jsx(TooltipStoryWrapper, { content: "Left tooltip", side: "left", children: _jsx(Button, { children: "Left" }) }), _jsx(TooltipStoryWrapper, { content: "Right tooltip", side: "right", children: _jsx(Button, { children: "Right" }) })] })),
19
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
@@ -0,0 +1,20 @@
1
+ export const defaultTheme = {
2
+ colors: {
3
+ // Base tokens
4
+ primary: '#0A5FFF',
5
+ secondary: '#F3F5FB',
6
+ accent: '#E3ECFF',
7
+ // Semantic intent
8
+ success: '#16c784',
9
+ warning: '#f4b740',
10
+ error: '#d7263d',
11
+ info: '#FEF9BF',
12
+ // Layout
13
+ background: '#ffffff',
14
+ foreground: '#1a2236',
15
+ // Text
16
+ textPrimary: '#27272A',
17
+ },
18
+ radius: '8px',
19
+ fontFamily: 'Inter, system-ui, sans-serif',
20
+ };
@@ -0,0 +1,2 @@
1
+ export * from './defaultTheme';
2
+ export * from './uikitConfig';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { defaultTheme } from '../config/defaultTheme';
3
+ export const UIKitContext = React.createContext(defaultTheme);
4
+ export const useUIKitTheme = () => React.useContext(UIKitContext);
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useMemo } from 'react';
3
+ import { defaultTheme } from '../config/defaultTheme';
4
+ import { UIKitContext } from './UIKitContext';
5
+ const mergeTheme = (user) => {
6
+ return {
7
+ ...defaultTheme,
8
+ ...user,
9
+ colors: { ...defaultTheme.colors, ...((user === null || user === void 0 ? void 0 : user.colors) || {}) },
10
+ };
11
+ };
12
+ function applyThemeToRoot(theme) {
13
+ if (typeof window === 'undefined')
14
+ return;
15
+ const root = document.documentElement;
16
+ const { colors = {}, radius, fontFamily } = theme;
17
+ Object.entries(colors).forEach(([key, value]) => {
18
+ if (value)
19
+ root.style.setProperty(`--uikit-${key}`, value);
20
+ });
21
+ if (radius)
22
+ root.style.setProperty('--uikit-radius', radius);
23
+ if (fontFamily)
24
+ root.style.setProperty('--uikit-font-family', fontFamily);
25
+ }
26
+ export const UIKitProvider = ({ config, children }) => {
27
+ const mergedTheme = useMemo(() => mergeTheme(config), [config]);
28
+ React.useEffect(() => {
29
+ applyThemeToRoot(mergedTheme);
30
+ }, [mergedTheme]);
31
+ return _jsx(UIKitContext.Provider, { value: mergedTheme, children: children });
32
+ };
@@ -0,0 +1 @@
1
+ export { useUIKitTheme } from './UIKitContext';
@@ -0,0 +1,6 @@
1
+ import { useState, useCallback } from 'react';
2
+ export function useToggle(initial = false) {
3
+ const [on, setOn] = useState(initial);
4
+ const toggle = useCallback(() => setOn((v) => !v), []);
5
+ return [on, toggle];
6
+ }
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { UIKitProvider } from './context/UIKitProvider';
2
+ export { useUIKitTheme } from './context/useUIKitTheme';
3
+ export * from './components/Button';
4
+ export * from './components/Input';
5
+ export * from './components/Table';
6
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import './header.css';
3
+ import { Button } from '../components/Button';
4
+ export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (_jsx("header", { children: _jsxs("div", { className: "storybook-header", children: [_jsxs("div", { children: [_jsx("svg", { width: "32", height: "32", viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: _jsxs("g", { fill: "none", fillRule: "evenodd", children: [_jsx("path", { d: "M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z", fill: "#FFF" }), _jsx("path", { d: "M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z", fill: "#555AB9" }), _jsx("path", { d: "M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z", fill: "#91BAF8" })] }) }), _jsx("h1", { children: "Acme" })] }), _jsx("div", { children: user ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "welcome", children: ["Welcome, ", _jsx("b", { children: user.name }), "!"] }), _jsx(Button, { size: "sm", onClick: onLogout, children: "Log out" })] })) : (_jsxs(_Fragment, { children: [_jsx(Button, { size: "sm", onClick: onLogin, children: "Log in" }), _jsx(Button, { variant: "primary", size: "sm", onClick: onCreateAccount, children: "Sign up" })] })) })] }) }));
@@ -0,0 +1,26 @@
1
+ import { fn } from 'storybook/test';
2
+ import { Header } from './Header';
3
+ const meta = {
4
+ title: 'Example/Header',
5
+ component: Header,
6
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
7
+ tags: ['autodocs'],
8
+ parameters: {
9
+ // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
10
+ layout: 'fullscreen',
11
+ },
12
+ args: {
13
+ onLogin: fn(),
14
+ onLogout: fn(),
15
+ onCreateAccount: fn(),
16
+ },
17
+ };
18
+ export default meta;
19
+ export const LoggedIn = {
20
+ args: {
21
+ user: {
22
+ name: 'Jane Doe',
23
+ },
24
+ },
25
+ };
26
+ export const LoggedOut = {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Header } from './Header';
4
+ import './page.css';
5
+ export const Page = () => {
6
+ const [user, setUser] = React.useState();
7
+ return (_jsxs("article", { children: [_jsx(Header, { user: user, onLogin: () => setUser({ name: 'Jane Doe' }), onLogout: () => setUser(undefined), onCreateAccount: () => setUser({ name: 'Jane Doe' }) }), _jsxs("section", { className: "storybook-page", children: [_jsx("h2", { children: "Pages in Storybook" }), _jsxs("p", { children: ["We recommend building UIs with a", ' ', _jsx("a", { href: "https://componentdriven.org", target: "_blank", rel: "noopener noreferrer", children: _jsx("strong", { children: "component-driven" }) }), ' ', "process starting with atomic components and ending with pages."] }), _jsx("p", { children: "Render pages with mock data. This makes it easy to build and review page states without needing to navigate to them in your app. Here are some handy patterns for managing page data in Storybook:" }), _jsxs("ul", { children: [_jsx("li", { children: "Use a higher-level connected component. Storybook helps you compose such data from the \"args\" of child component stories" }), _jsx("li", { children: "Assemble data in the page component from your services. You can mock these services out using Storybook." })] }), _jsxs("p", { children: ["Get a guided tutorial on component-driven development at", ' ', _jsx("a", { href: "https://storybook.js.org/tutorials/", target: "_blank", rel: "noopener noreferrer", children: "Storybook tutorials" }), ". Read more in the", ' ', _jsx("a", { href: "https://storybook.js.org/docs", target: "_blank", rel: "noopener noreferrer", children: "docs" }), "."] }), _jsxs("div", { className: "tip-wrapper", children: [_jsx("span", { className: "tip", children: "Tip" }), " Adjust the width of the canvas with the", ' ', _jsx("svg", { width: "10", height: "10", viewBox: "0 0 12 12", xmlns: "http://www.w3.org/2000/svg", children: _jsx("g", { fill: "none", fillRule: "evenodd", children: _jsx("path", { d: "M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z", id: "a", fill: "#999" }) }) }), "Viewports addon in the toolbar"] })] })] }));
8
+ };
@@ -0,0 +1,24 @@
1
+ import { expect, userEvent, within } from 'storybook/test';
2
+ import { Page } from './Page';
3
+ const meta = {
4
+ title: 'Example/Page',
5
+ component: Page,
6
+ parameters: {
7
+ // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
8
+ layout: 'fullscreen',
9
+ },
10
+ };
11
+ export default meta;
12
+ export const LoggedOut = {};
13
+ // More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing
14
+ export const LoggedIn = {
15
+ play: async ({ canvasElement }) => {
16
+ const canvas = within(canvasElement);
17
+ const loginButton = canvas.getByRole('button', { name: /Log in/i });
18
+ await expect(loginButton).toBeInTheDocument();
19
+ await userEvent.click(loginButton);
20
+ await expect(loginButton).not.toBeInTheDocument();
21
+ const logoutButton = canvas.getByRole('button', { name: /Log out/i });
22
+ await expect(logoutButton).toBeInTheDocument();
23
+ },
24
+ };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { ButtonProps } from './Button.types';
3
+ export declare const buttonVariants: (props?: ({
4
+ variant?: "primary" | "secondary" | "outlined" | "ghost" | "destructive" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
+ export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,16 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Button } from './Button';
3
+ declare const meta: Meta<typeof Button>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Button>;
6
+ export declare const Primary: Story;
7
+ export declare const Secondary: Story;
8
+ export declare const Outlined: Story;
9
+ export declare const Ghost: Story;
10
+ export declare const Destructive: Story;
11
+ export declare const Loading: Story;
12
+ export declare const WithLoadingText: Story;
13
+ export declare const WithIconLeft: Story;
14
+ export declare const WithIconRight: Story;
15
+ export declare const DisabledVariants: Story;
16
+ export declare const AllSizes: Story;
@@ -0,0 +1,8 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import { buttonVariants } from './Button';
3
+ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
4
+ children: React.ReactNode;
5
+ asChild?: boolean;
6
+ loading?: boolean;
7
+ loadingText?: string;
8
+ }
@@ -0,0 +1 @@
1
+ export * from './Button';
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
3
+ import { CheckboxProps } from './Checkbox.types';
4
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & CheckboxProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
5
+ export { Checkbox };
@@ -0,0 +1,13 @@
1
+ import type { CheckboxProps } from './Checkbox.types';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ declare const meta: Meta<CheckboxProps>;
4
+ export default meta;
5
+ type Story = StoryObj<CheckboxProps>;
6
+ export declare const Default: Story;
7
+ export declare const Checked: Story;
8
+ export declare const Disabled: Story;
9
+ export declare const DisabledChecked: Story;
10
+ export declare const ControlledCheckbox: Story;
11
+ export declare const WithLabel: Story;
12
+ export declare const WithLabelPosition: Story;
13
+ export declare const ControlledAndLabel: Story;
@@ -0,0 +1,6 @@
1
+ import { ComponentProps } from 'react';
2
+ import { Checkbox as ShadCBCheckbox } from '@radix-ui/react-checkbox';
3
+ export interface CheckboxProps extends ComponentProps<typeof ShadCBCheckbox> {
4
+ label?: string;
5
+ labelPosition?: 'left' | 'right' | 'top' | 'bottom';
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Checkbox';
2
+ export * from './Checkbox.types';
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { DividerProps } from './Divider.types';
3
+ export declare const Divider: React.FC<DividerProps>;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Divider } from './Divider';
3
+ declare const meta: Meta<typeof Divider>;
4
+ export default meta;
5
+ export declare const Horizontal: StoryObj<typeof Divider>;
6
+ export declare const HorizontalCustomColor: StoryObj<typeof Divider>;
7
+ export declare const Vertical: StoryObj<typeof Divider>;
8
+ export declare const VerticalTall: StoryObj<typeof Divider>;
@@ -0,0 +1,5 @@
1
+ export type Orientation = 'horizontal' | 'vertical';
2
+ export interface DividerProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ orientation?: Orientation;
4
+ color?: string;
5
+ }
@@ -0,0 +1 @@
1
+ export * from './Divider';
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { EllipsisTextProps } from './Ellipsis.types';
3
+ export declare const EllipsisText: React.FC<EllipsisTextProps>;
@@ -0,0 +1 @@
1
+ export declare function middleEllipsis(text: string, maxLength: number): string;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { EllipsisText } from './Ellipsis';
3
+ declare const meta: Meta<typeof EllipsisText>;
4
+ export default meta;
5
+ export declare const EndEllipsis: StoryObj<typeof EllipsisText>;
6
+ export declare const MiddleEllipsis: StoryObj<typeof EllipsisText>;
7
+ export declare const NoEllipsisNeeded: StoryObj<typeof EllipsisText>;
@@ -0,0 +1,7 @@
1
+ export type EllipsisMode = 'end' | 'middle';
2
+ export interface EllipsisTextProps extends React.HTMLAttributes<HTMLSpanElement> {
3
+ text: string;
4
+ maxLength?: number;
5
+ mode?: EllipsisMode;
6
+ width?: string;
7
+ }
@@ -0,0 +1 @@
1
+ export * from './Ellipsis';
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { InputProps } from './Input.types';
3
+ export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,15 @@
1
+ import type { InputProps } from './Input.types';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ declare const meta: Meta<InputProps>;
4
+ export default meta;
5
+ type Story = StoryObj<InputProps>;
6
+ export declare const Text: Story;
7
+ export declare const Number: Story;
8
+ export declare const WithValue: Story;
9
+ export declare const WithLabel: Story;
10
+ export declare const PasswordInput: Story;
11
+ export declare const WithHelperText: Story;
12
+ export declare const Disabled: Story;
13
+ export declare const DisabledWithValue: Story;
14
+ export declare const WithError: Story;
15
+ export declare const withIcon: Story;
@@ -0,0 +1,7 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
3
+ label?: string;
4
+ error?: string;
5
+ helperText?: string;
6
+ icon?: React.ReactNode;
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Input';
2
+ export * from './Input.types';
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import * as LabelPrimitive from '@radix-ui/react-label';
3
+ import { type VariantProps } from 'class-variance-authority';
4
+ declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string> & React.RefAttributes<HTMLLabelElement>>;
5
+ export { Label };
@@ -0,0 +1,7 @@
1
+ import type { LabelProps } from './Label.types';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ declare const meta: Meta<LabelProps>;
4
+ export default meta;
5
+ type Story = StoryObj<LabelProps>;
6
+ export declare const Default: Story;
7
+ export declare const WithCustomStyle: Story;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Label';
2
+ export * from './Label.types';
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
3
+ declare const RadioGroup: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
5
+ export { RadioGroup, RadioGroupItem };
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import type { RadioGroupProps } from './RadioGroup.types';
3
+ declare const meta: Meta<RadioGroupProps>;
4
+ export default meta;
5
+ type Story = StoryObj<RadioGroupProps>;
6
+ export declare const Default: Story;
7
+ export declare const Horizontal: Story;
8
+ export declare const Disabled: Story;
9
+ export declare const Size: Story;
@@ -0,0 +1,5 @@
1
+ import { ComponentProps } from 'react';
2
+ import { RadioGroup as ShadCNRadioGroup } from '@radix-ui/react-radio-group';
3
+ export interface RadioGroupProps extends ComponentProps<typeof ShadCNRadioGroup> {
4
+ size?: 'sm' | 'md' | 'lg';
5
+ }
@@ -0,0 +1,2 @@
1
+ export * from './RadioGroup';
2
+ export * from './RadioGroup.types';
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import * as SwitchPrimitives from '@radix-ui/react-switch';
3
+ import { SwitchProps } from './Switch.types';
4
+ declare const Switch: React.ForwardRefExoticComponent<Omit<Omit<SwitchPrimitives.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> & SwitchProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
5
+ export { Switch };
@@ -0,0 +1,12 @@
1
+ import type { SwitchProps } from './Switch.types';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ declare const meta: Meta<SwitchProps>;
4
+ export default meta;
5
+ type Story = StoryObj<SwitchProps>;
6
+ export declare const Default: Story;
7
+ export declare const Checked: Story;
8
+ export declare const Disabled: Story;
9
+ export declare const ControlledSwitch: Story;
10
+ export declare const WithLabel: Story;
11
+ export declare const WithLabelPosition: Story;
12
+ export declare const ControlledAndLabel: Story;
@@ -0,0 +1,6 @@
1
+ import { ComponentProps } from 'react';
2
+ import { Switch as ShadCNSwitch } from '@radix-ui/react-switch';
3
+ export interface SwitchProps extends ComponentProps<typeof ShadCNSwitch> {
4
+ label?: string;
5
+ labelPosition?: 'left' | 'right' | 'top' | 'bottom';
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Switch';
2
+ export * from './Switch.types';