@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.
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
- var tailwindMerge = require('tailwind-merge');
5
4
  var React = require('react');
5
+ var tailwindMerge = require('tailwind-merge');
6
6
  var react = require('@headlessui/react');
7
7
  var reactWindow = require('react-window');
8
8
 
@@ -151,7 +151,7 @@ const TextContent = React.forwardRef((props, ref) => {
151
151
  return React.createElement('span', {
152
152
  ...rest,
153
153
  ref,
154
- className: buildClassName(xsmall && 'text-xs/5', small && 'text-sm/6', strong && 'font-semibold', muted && 'text-gray-500', error && 'text-red-500 dark:text-red-500', className),
154
+ 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),
155
155
  });
156
156
  });
157
157
  TextContent.displayName = 'TextContent';
@@ -235,17 +235,18 @@ const AlertTypeIconMap = {
235
235
  warning: SvgCircleAlert,
236
236
  info: SvgInfo,
237
237
  };
238
- const TypeClassMap = {
238
+ const TypeClassMap$1 = {
239
239
  success: 'bg-[var(--ui-success-light)] ring-[var(--ui-success-ring-subtle)] text-[var(--ui-success-text)]',
240
- danger: 'bg-[var(--ui-danger-light)] ring-[var(--ui-danger-ring-subtle)] text-[var(--ui-danger-text)]',
240
+ danger: 'bg-[var(--ui-danger-light)] ring-[var(--ui-danger-ring-subtle)] text-[var(--ui-danger-text)]',
241
241
  warning: 'bg-[var(--ui-warning-light)] ring-[var(--ui-warning-ring-subtle)] text-[var(--ui-warning-text)]',
242
- info: 'bg-[var(--ui-info-light)] ring-[var(--ui-info-ring-subtle)] text-[var(--ui-info-text)]',
243
- };
244
- const Alert = (props) => {
245
- const { type = 'info', className = '', message, children, removable = false, onRemove = () => { }, ...restProps } = props;
246
- const Icon = AlertTypeIconMap[type] || SvgInfo;
247
- return (jsxRuntime.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: [jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-2", children: [jsxRuntime.jsx(Icon, { className: "size-5", "data-testid": `alert-${type}-icon` }), jsxRuntime.jsx("span", { className: "pr-2 inline-flex items-center", children: message || children })] }), removable && (jsxRuntime.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: jsxRuntime.jsx(SvgX, { className: "size-4.5", "data-testid": "alert-remove-icon" }) }))] }));
242
+ info: 'bg-[var(--ui-info-light)] ring-[var(--ui-info-ring-subtle)] text-[var(--ui-info-text)]',
248
243
  };
244
+ const Alert = React.forwardRef((props, ref) => {
245
+ const { type = 'info', className, message, children, removable = false, onRemove, icon, title, ...restProps } = props;
246
+ const DefaultIcon = AlertTypeIconMap[type] || SvgInfo;
247
+ const iconNode = icon !== undefined ? (icon) : (jsxRuntime.jsx(DefaultIcon, { className: "size-5 shrink-0", "data-testid": `alert-${type}-icon` }));
248
+ return (jsxRuntime.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: [jsxRuntime.jsxs("span", { className: "inline-flex items-start gap-2 min-w-0", children: [iconNode && jsxRuntime.jsx("span", { className: "shrink-0 inline-flex mt-0.5", children: iconNode }), jsxRuntime.jsxs("span", { className: "inline-flex flex-col gap-0.5 min-w-0", children: [title && jsxRuntime.jsx("span", { className: "font-semibold", children: title }), jsxRuntime.jsx("span", { className: "inline-flex items-center", children: message !== null && message !== void 0 ? message : children })] })] }), removable && (jsxRuntime.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: jsxRuntime.jsx(SvgX, { className: "size-4.5", "data-testid": "alert-remove-icon" }) }))] }));
249
+ });
249
250
  Alert.displayName = 'Alert';
250
251
 
251
252
  const ThemeClassMap = {
@@ -255,14 +256,18 @@ const ThemeClassMap = {
255
256
  info: 'bg-[var(--ui-info-light)] text-[var(--ui-info-text)] ring-[var(--ui-info-ring-subtle)]',
256
257
  secondary: 'bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-200 ring-[var(--ui-secondary-ring-subtle)]',
257
258
  };
259
+ const SIZE_CLASS = {
260
+ sm: 'text-xs py-0.5 px-2',
261
+ md: 'text-xs py-1 px-3',
262
+ };
258
263
  const Badge = React.forwardRef((props, ref) => {
259
- const { theme = 'info', className = '', children, removable = false, rounded = false, onRemove = () => { }, ...restProps } = props;
260
- return (jsxRuntime.jsxs(TextContent, { ref: ref, className: buildClassName(className, 'inline-flex items-center pl-3 py-1 text-xs font-medium ring-1 ring-inset', ThemeClassMap[theme], rounded ? 'rounded-full' : 'rounded-md'), "data-testid": `badge-${theme}`, ...restProps, children: [jsxRuntime.jsx(TextContent, { className: "pr-3 inline-flex items-center", children: children }), removable ? (jsxRuntime.jsx(SvgX, { className: "size-5 px-0.5 mr-1 hover:bg-slate-200 dark:hover:bg-white/10 rounded-sm cursor-pointer text-gray-600 dark:text-gray-300", role: "button", tabIndex: 0, "aria-label": "Remove", onClick: () => onRemove(), onKeyDown: (e) => {
264
+ const { theme = 'info', className, children, removable = false, rounded = false, onRemove, size = 'md', icon, ...restProps } = props;
265
+ return (jsxRuntime.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 && jsxRuntime.jsx("span", { className: "shrink-0 inline-flex", children: icon }), children, removable && (jsxRuntime.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) => {
261
266
  if (e.key === 'Enter' || e.key === ' ') {
262
267
  e.preventDefault();
263
- onRemove();
268
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
264
269
  }
265
- } })) : null] }));
270
+ } }))] }));
266
271
  });
267
272
  Badge.displayName = 'Badge';
268
273
 
@@ -309,13 +314,11 @@ var SvgCircleCheck = function SvgCircleCheck(props) {
309
314
  };
310
315
 
311
316
  const sizeMap = {
312
- 4: `size-4`,
313
- 5: `size-5`,
314
- 6: `size-6`,
315
- 7: `size-7`,
316
- 8: `size-8`,
317
- 9: `size-9`,
318
- 10: `size-10`,
317
+ xs: 'size-4',
318
+ sm: 'size-5',
319
+ md: 'size-6',
320
+ lg: 'size-8',
321
+ xl: 'size-10',
319
322
  };
320
323
  const IconMap = {
321
324
  info: SvgInfo,
@@ -323,14 +326,17 @@ const IconMap = {
323
326
  success: SvgCircleCheck,
324
327
  warning: SvgTriangleAlert,
325
328
  };
329
+ const TypeClassMap = {
330
+ info: 'bg-[var(--ui-info-light)] ring-[var(--ui-info-ring-subtle)] text-[var(--ui-info-text)]',
331
+ error: 'bg-[var(--ui-danger-light)] ring-[var(--ui-danger-ring-subtle)] text-[var(--ui-danger-text)]',
332
+ success: 'bg-[var(--ui-success-light)] ring-[var(--ui-success-ring-subtle)] text-[var(--ui-success-text)]',
333
+ warning: 'bg-[var(--ui-warning-light)] ring-[var(--ui-warning-ring-subtle)] text-[var(--ui-warning-text)]',
334
+ };
326
335
  const Banner = React.forwardRef((props, ref) => {
327
- const { type = 'info', iconSize = 5, children, ...restProps } = props;
328
- const className = buildClassName('text-sm banner rounded-md flex w-full p-3 items-center', type === 'info' ? 'bg-blue-50 text-blue-700' : '', type === 'error' ? 'bg-red-50 text-red-700' : '', type === 'success' ? 'bg-green-50 text-green-700' : '', type === 'warning' ? 'bg-orange-50 text-orange-700' : '');
329
- const renderIcon = () => {
330
- const Icon = IconMap[type];
331
- return (jsxRuntime.jsx(Icon, { "data-testid": `banner-${type}-icon`, className: buildClassName('ml-1 mr-3', sizeMap[iconSize]) }));
332
- };
333
- return (jsxRuntime.jsxs("div", { ref: ref, className: className, "data-testid": `banner-${type}`, ...restProps, children: [renderIcon(), jsxRuntime.jsx("div", { className: "flex items-center w-full justify-between", children: children })] }));
336
+ const { type = 'info', iconSize = 'sm', children, icon, removable = false, onRemove, className, ...restProps } = props;
337
+ const DefaultIcon = IconMap[type];
338
+ const iconNode = icon !== undefined ? (icon) : (jsxRuntime.jsx(DefaultIcon, { "data-testid": `banner-${type}-icon`, className: buildClassName('shrink-0', sizeMap[iconSize]) }));
339
+ return (jsxRuntime.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, jsxRuntime.jsx("div", { className: "flex items-center w-full justify-between", children: children }), removable && (jsxRuntime.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: jsxRuntime.jsx(SvgX, { className: "size-4.5", "data-testid": "banner-remove-icon" }) }))] }));
334
340
  });
335
341
  Banner.displayName = 'Banner';
336
342
 
@@ -338,7 +344,7 @@ const BodyText = React.forwardRef((props, ref) => {
338
344
  const { as = 'p', small = false, strong = false, muted = false, error = false, inline = false, className, ...rest } = props;
339
345
  return React.createElement(as, {
340
346
  ref: ref,
341
- 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),
347
+ 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),
342
348
  ...rest,
343
349
  });
344
350
  });