@pk-design/react-tailwind 1.4.0 → 1.4.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/react-tailwind.cjs.js +35 -29
- package/dist/react-tailwind.cjs.js.map +1 -1
- package/dist/react-tailwind.es.js +35 -29
- package/dist/react-tailwind.es.js.map +1 -1
- package/dist/types/components/Alert/Alert.d.ts +1 -1
- package/dist/types/components/Alert/Alert.types.d.ts +10 -4
- package/dist/types/components/Badge/Badge.types.d.ts +13 -3
- package/dist/types/components/Banner/Banner.types.d.ts +17 -3
- package/dist/types/components/Table/Table.types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { twMerge } from 'tailwind-merge';
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import React__default, { forwardRef, useMemo, useId, useRef, useState, useEffect, Fragment as Fragment$1, useCallback, useImperativeHandle, createContext, useContext } from 'react';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
import { Dialog, DialogBackdrop, DialogPanel, DialogTitle, Menu, MenuButton, MenuItems, MenuItem, RadioGroup as RadioGroup$1, Radio as Radio$1, Combobox, ComboboxInput, ComboboxButton, ComboboxOptions, ComboboxOption, TabGroup, TabList, Tab, TabPanels, TabPanel, Transition } from '@headlessui/react';
|
|
6
6
|
import { FixedSizeList } from 'react-window';
|
|
7
7
|
|
|
@@ -131,7 +131,7 @@ const TextContent = forwardRef((props, ref) => {
|
|
|
131
131
|
return React__default.createElement('span', {
|
|
132
132
|
...rest,
|
|
133
133
|
ref,
|
|
134
|
-
className: buildClassName(xsmall && 'text-xs/5', small && 'text-sm/6', strong && 'font-semibold', muted && 'text-gray-500', error && 'text-red-500 dark:text-red-
|
|
134
|
+
className: buildClassName('text-gray-900 dark:text-gray-100', xsmall && 'text-xs/5', small && 'text-sm/6', strong && 'font-semibold', muted && 'text-gray-500 dark:text-gray-400', error && 'text-red-500 dark:text-red-400', className),
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
TextContent.displayName = 'TextContent';
|
|
@@ -215,17 +215,18 @@ const AlertTypeIconMap = {
|
|
|
215
215
|
warning: SvgCircleAlert,
|
|
216
216
|
info: SvgInfo,
|
|
217
217
|
};
|
|
218
|
-
const TypeClassMap = {
|
|
218
|
+
const TypeClassMap$1 = {
|
|
219
219
|
success: 'bg-[var(--ui-success-light)] ring-[var(--ui-success-ring-subtle)] text-[var(--ui-success-text)]',
|
|
220
|
-
danger: 'bg-[var(--ui-danger-light)]
|
|
220
|
+
danger: 'bg-[var(--ui-danger-light)] ring-[var(--ui-danger-ring-subtle)] text-[var(--ui-danger-text)]',
|
|
221
221
|
warning: 'bg-[var(--ui-warning-light)] ring-[var(--ui-warning-ring-subtle)] text-[var(--ui-warning-text)]',
|
|
222
|
-
info: 'bg-[var(--ui-info-light)]
|
|
223
|
-
};
|
|
224
|
-
const Alert = (props) => {
|
|
225
|
-
const { type = 'info', className = '', message, children, removable = false, onRemove = () => { }, ...restProps } = props;
|
|
226
|
-
const Icon = AlertTypeIconMap[type] || SvgInfo;
|
|
227
|
-
return (jsxs("div", { className: buildClassName(className, 'flex items-center justify-between rounded-md p-3 text-sm ring-1 ring-inset gap-2', TypeClassMap[type]), ...restProps, children: [jsxs("span", { className: "inline-flex items-center gap-2", children: [jsx(Icon, { className: "size-5", "data-testid": `alert-${type}-icon` }), jsx("span", { className: "pr-2 inline-flex items-center", children: message || children })] }), removable && (jsx(Button, { iconOnly: true, "aria-label": "Dismiss alert", size: "xs", variant: "plain", theme: "secondary", className: "hover:bg-black/5 text-gray-600 dark:hover:bg-black/5 dark:text-gray-600", onClick: () => onRemove(), "data-testid": "alert-remove-btn", children: jsx(SvgX, { className: "size-4.5", "data-testid": "alert-remove-icon" }) }))] }));
|
|
222
|
+
info: 'bg-[var(--ui-info-light)] ring-[var(--ui-info-ring-subtle)] text-[var(--ui-info-text)]',
|
|
228
223
|
};
|
|
224
|
+
const Alert = forwardRef((props, ref) => {
|
|
225
|
+
const { type = 'info', className, message, children, removable = false, onRemove, icon, title, ...restProps } = props;
|
|
226
|
+
const DefaultIcon = AlertTypeIconMap[type] || SvgInfo;
|
|
227
|
+
const iconNode = icon !== undefined ? (icon) : (jsx(DefaultIcon, { className: "size-5 shrink-0", "data-testid": `alert-${type}-icon` }));
|
|
228
|
+
return (jsxs("div", { ref: ref, className: buildClassName('flex items-center justify-between rounded-md p-3 text-sm ring-1 ring-inset gap-2', TypeClassMap$1[type], className), ...restProps, children: [jsxs("span", { className: "inline-flex items-start gap-2 min-w-0", children: [iconNode && jsx("span", { className: "shrink-0 inline-flex mt-0.5", children: iconNode }), jsxs("span", { className: "inline-flex flex-col gap-0.5 min-w-0", children: [title && jsx("span", { className: "font-semibold", children: title }), jsx("span", { className: "inline-flex items-center", children: message !== null && message !== void 0 ? message : children })] })] }), removable && (jsx(Button, { iconOnly: true, "aria-label": "Dismiss alert", size: "xs", variant: "plain", theme: "secondary", className: "hover:bg-black/10 dark:hover:bg-white/10 shrink-0", onClick: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(), "data-testid": "alert-remove-btn", children: jsx(SvgX, { className: "size-4.5", "data-testid": "alert-remove-icon" }) }))] }));
|
|
229
|
+
});
|
|
229
230
|
Alert.displayName = 'Alert';
|
|
230
231
|
|
|
231
232
|
const ThemeClassMap = {
|
|
@@ -235,14 +236,18 @@ const ThemeClassMap = {
|
|
|
235
236
|
info: 'bg-[var(--ui-info-light)] text-[var(--ui-info-text)] ring-[var(--ui-info-ring-subtle)]',
|
|
236
237
|
secondary: 'bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-200 ring-[var(--ui-secondary-ring-subtle)]',
|
|
237
238
|
};
|
|
239
|
+
const SIZE_CLASS = {
|
|
240
|
+
sm: 'text-xs py-0.5 px-2',
|
|
241
|
+
md: 'text-xs py-1 px-3',
|
|
242
|
+
};
|
|
238
243
|
const Badge = forwardRef((props, ref) => {
|
|
239
|
-
const { theme = 'info', className
|
|
240
|
-
return (jsxs(TextContent, { ref: ref, className: buildClassName(
|
|
244
|
+
const { theme = 'info', className, children, removable = false, rounded = false, onRemove, size = 'md', icon, ...restProps } = props;
|
|
245
|
+
return (jsxs(TextContent, { ref: ref, className: buildClassName('inline-flex items-center gap-1 font-medium ring-1 ring-inset', SIZE_CLASS[size], ThemeClassMap[theme], rounded ? 'rounded-full' : 'rounded-md', icon ? 'pl-2' : '', removable ? 'pr-1' : '', className), "data-testid": `badge-${theme}`, ...restProps, children: [icon && jsx("span", { className: "shrink-0 inline-flex", children: icon }), children, removable && (jsx(SvgX, { className: "size-4 shrink-0 hover:bg-black/10 dark:hover:bg-white/10 rounded-sm cursor-pointer", role: "button", tabIndex: 0, "aria-label": "Remove", onClick: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(), onKeyDown: (e) => {
|
|
241
246
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
242
247
|
e.preventDefault();
|
|
243
|
-
onRemove();
|
|
248
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove();
|
|
244
249
|
}
|
|
245
|
-
} }))
|
|
250
|
+
} }))] }));
|
|
246
251
|
});
|
|
247
252
|
Badge.displayName = 'Badge';
|
|
248
253
|
|
|
@@ -289,13 +294,11 @@ var SvgCircleCheck = function SvgCircleCheck(props) {
|
|
|
289
294
|
};
|
|
290
295
|
|
|
291
296
|
const sizeMap = {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
9: `size-9`,
|
|
298
|
-
10: `size-10`,
|
|
297
|
+
xs: 'size-4',
|
|
298
|
+
sm: 'size-5',
|
|
299
|
+
md: 'size-6',
|
|
300
|
+
lg: 'size-8',
|
|
301
|
+
xl: 'size-10',
|
|
299
302
|
};
|
|
300
303
|
const IconMap = {
|
|
301
304
|
info: SvgInfo,
|
|
@@ -303,14 +306,17 @@ const IconMap = {
|
|
|
303
306
|
success: SvgCircleCheck,
|
|
304
307
|
warning: SvgTriangleAlert,
|
|
305
308
|
};
|
|
309
|
+
const TypeClassMap = {
|
|
310
|
+
info: 'bg-[var(--ui-info-light)] ring-[var(--ui-info-ring-subtle)] text-[var(--ui-info-text)]',
|
|
311
|
+
error: 'bg-[var(--ui-danger-light)] ring-[var(--ui-danger-ring-subtle)] text-[var(--ui-danger-text)]',
|
|
312
|
+
success: 'bg-[var(--ui-success-light)] ring-[var(--ui-success-ring-subtle)] text-[var(--ui-success-text)]',
|
|
313
|
+
warning: 'bg-[var(--ui-warning-light)] ring-[var(--ui-warning-ring-subtle)] text-[var(--ui-warning-text)]',
|
|
314
|
+
};
|
|
306
315
|
const Banner = forwardRef((props, ref) => {
|
|
307
|
-
const { type = 'info', iconSize =
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
return (jsx(Icon, { "data-testid": `banner-${type}-icon`, className: buildClassName('ml-1 mr-3', sizeMap[iconSize]) }));
|
|
312
|
-
};
|
|
313
|
-
return (jsxs("div", { ref: ref, className: className, "data-testid": `banner-${type}`, ...restProps, children: [renderIcon(), jsx("div", { className: "flex items-center w-full justify-between", children: children })] }));
|
|
316
|
+
const { type = 'info', iconSize = 'sm', children, icon, removable = false, onRemove, className, ...restProps } = props;
|
|
317
|
+
const DefaultIcon = IconMap[type];
|
|
318
|
+
const iconNode = icon !== undefined ? (icon) : (jsx(DefaultIcon, { "data-testid": `banner-${type}-icon`, className: buildClassName('shrink-0', sizeMap[iconSize]) }));
|
|
319
|
+
return (jsxs("div", { ref: ref, className: buildClassName('text-sm rounded-md flex w-full p-3 items-center gap-3 ring-1 ring-inset', TypeClassMap[type], className), "data-testid": `banner-${type}`, ...restProps, children: [iconNode, jsx("div", { className: "flex items-center w-full justify-between", children: children }), removable && (jsx(Button, { iconOnly: true, "aria-label": "Dismiss banner", size: "xs", variant: "plain", theme: "secondary", className: "hover:bg-black/10 dark:hover:bg-white/10 shrink-0", onClick: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(), "data-testid": "banner-remove-btn", children: jsx(SvgX, { className: "size-4.5", "data-testid": "banner-remove-icon" }) }))] }));
|
|
314
320
|
});
|
|
315
321
|
Banner.displayName = 'Banner';
|
|
316
322
|
|
|
@@ -318,7 +324,7 @@ const BodyText = forwardRef((props, ref) => {
|
|
|
318
324
|
const { as = 'p', small = false, strong = false, muted = false, error = false, inline = false, className, ...rest } = props;
|
|
319
325
|
return React__default.createElement(as, {
|
|
320
326
|
ref: ref,
|
|
321
|
-
className: buildClassName(small && 'text-sm/6', strong && 'font-semibold', muted && 'text-gray-500', error && 'text-red-500', inline && 'inline-flex items-center gap-2', className),
|
|
327
|
+
className: buildClassName('text-gray-900 dark:text-gray-100', small && 'text-sm/6', strong && 'font-semibold', muted && 'text-gray-500 dark:text-gray-400', error && 'text-red-500 dark:text-red-400', inline && 'inline-flex items-center gap-2', className),
|
|
322
328
|
...rest,
|
|
323
329
|
});
|
|
324
330
|
});
|