@scaleflex/ui-tw 0.0.158 → 0.0.160
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/accordion/accordion.component.d.ts +2 -1
- package/accordion/accordion.component.js +22 -5
- package/accordion/accordion.constants.d.ts +3 -0
- package/accordion/accordion.constants.js +14 -0
- package/accordion/accordion.types.d.ts +12 -0
- package/accordion/accordion.types.js +1 -0
- package/accordion/index.d.ts +2 -0
- package/accordion/index.js +2 -1
- package/badge/badge.constants.d.ts +1 -1
- package/dialog/dialog.component.d.ts +2 -2
- package/dialog/dialog.component.js +15 -1
- package/dialog/dialog.types.d.ts +4 -0
- package/dialog/index.d.ts +1 -1
- package/package.json +3 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { ComponentProps } from 'react';
|
|
4
|
+
import { AccordionTriggerProps } from './accordion.types';
|
|
4
5
|
declare function Accordion({ ...props }: ComponentProps<typeof AccordionPrimitive.Root>): React.JSX.Element;
|
|
5
6
|
declare function AccordionItem({ className, ...props }: ComponentProps<typeof AccordionPrimitive.Item>): React.JSX.Element;
|
|
6
|
-
declare function AccordionTrigger({ className, children, ...props }:
|
|
7
|
+
declare function AccordionTrigger({ className, children, chevronPosition, chevronRotation, icon, hideChevron, style, ...props }: AccordionTriggerProps): React.JSX.Element;
|
|
7
8
|
declare function AccordionContent({ className, children, ...props }: ComponentProps<typeof AccordionPrimitive.Content>): React.JSX.Element;
|
|
8
9
|
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
|
|
3
4
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
5
|
var _excluded = ["className"],
|
|
5
|
-
_excluded2 = ["className", "children"],
|
|
6
|
+
_excluded2 = ["className", "children", "chevronPosition", "chevronRotation", "icon", "hideChevron", "style"],
|
|
6
7
|
_excluded3 = ["className", "children"];
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
10
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
11
|
+
import { accordionTriggerVariants } from '@scaleflex/ui-tw/accordion/accordion.constants';
|
|
8
12
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
9
13
|
import { ChevronDownIcon } from 'lucide-react';
|
|
10
14
|
import * as React from 'react';
|
|
@@ -25,15 +29,28 @@ function AccordionItem(_ref2) {
|
|
|
25
29
|
function AccordionTrigger(_ref3) {
|
|
26
30
|
var className = _ref3.className,
|
|
27
31
|
children = _ref3.children,
|
|
32
|
+
chevronPosition = _ref3.chevronPosition,
|
|
33
|
+
_ref3$chevronRotation = _ref3.chevronRotation,
|
|
34
|
+
chevronRotation = _ref3$chevronRotation === void 0 ? 180 : _ref3$chevronRotation,
|
|
35
|
+
icon = _ref3.icon,
|
|
36
|
+
_ref3$hideChevron = _ref3.hideChevron,
|
|
37
|
+
hideChevron = _ref3$hideChevron === void 0 ? false : _ref3$hideChevron,
|
|
38
|
+
style = _ref3.style,
|
|
28
39
|
props = _objectWithoutProperties(_ref3, _excluded2);
|
|
29
40
|
return /*#__PURE__*/React.createElement(AccordionPrimitive.Header, {
|
|
30
41
|
className: "flex"
|
|
31
42
|
}, /*#__PURE__*/React.createElement(AccordionPrimitive.Trigger, _extends({
|
|
32
43
|
"data-slot": "accordion-trigger",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
style: _objectSpread(_defineProperty({}, '--accordion-chevron-rotation', "".concat(chevronRotation, "deg")), style),
|
|
45
|
+
className: cn(accordionTriggerVariants({
|
|
46
|
+
chevronPosition: chevronPosition
|
|
47
|
+
}), '[&[data-state=open]>[data-slot=accordion-chevron]]:rotate-(--accordion-chevron-rotation)', className)
|
|
48
|
+
}, props), children, !hideChevron && /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
"data-slot": "accordion-chevron",
|
|
50
|
+
className: "text-muted-foreground pointer-events-none shrink-0 translate-y-0.5 transition-transform duration-200"
|
|
51
|
+
}, icon !== null && icon !== void 0 ? icon : /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
52
|
+
className: "size-4"
|
|
53
|
+
}))));
|
|
37
54
|
}
|
|
38
55
|
function AccordionContent(_ref4) {
|
|
39
56
|
var className = _ref4.className,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
export var accordionTriggerVariants = cva('focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 cursor-pointer items-start rounded-md py-4 text-left text-sm font-medium transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50', {
|
|
3
|
+
variants: {
|
|
4
|
+
// Where the chevron sits relative to the label.
|
|
5
|
+
// `end` pushes it to the far right (default), `inline` keeps it right next to the label.
|
|
6
|
+
chevronPosition: {
|
|
7
|
+
end: 'justify-between gap-4',
|
|
8
|
+
inline: 'justify-start gap-2'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
defaultVariants: {
|
|
12
|
+
chevronPosition: 'end'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
4
|
+
import { accordionTriggerVariants } from './accordion.constants';
|
|
5
|
+
export type AccordionTriggerProps = ComponentProps<typeof AccordionPrimitive.Trigger> & VariantProps<typeof accordionTriggerVariants> & {
|
|
6
|
+
/** Custom indicator icon. Defaults to a chevron-down icon. */
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
/** Rotation in degrees applied to the icon when the item is open. Defaults to 180. */
|
|
9
|
+
chevronRotation?: number;
|
|
10
|
+
/** Hide the indicator icon entirely. */
|
|
11
|
+
hideChevron?: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/accordion/index.d.ts
CHANGED
package/accordion/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './accordion.component';
|
|
1
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './accordion.component';
|
|
2
|
+
export { accordionTriggerVariants } from './accordion.constants';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const badgeVariants: (props?: ({
|
|
2
|
-
variant?: "
|
|
2
|
+
variant?: "green" | "yellow" | "neutral" | "greenSoft" | null | undefined;
|
|
3
3
|
size?: "md" | "lg" | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
2
2
|
import React, { type ComponentProps } from 'react';
|
|
3
|
-
import type { DialogContentProps, DialogHeaderProps, DialogTitleProps } from './dialog.types';
|
|
3
|
+
import type { DialogContentProps, DialogDescriptionProps, DialogHeaderProps, DialogTitleProps } from './dialog.types';
|
|
4
4
|
declare function Dialog({ ...props }: ComponentProps<typeof DialogPrimitive.Root>): React.JSX.Element;
|
|
5
5
|
declare function DialogTrigger({ ...props }: ComponentProps<typeof DialogPrimitive.Trigger>): React.JSX.Element;
|
|
6
6
|
declare function DialogPortal({ ...props }: ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
|
|
@@ -9,7 +9,7 @@ declare function DialogOverlay({ className, ...props }: ComponentProps<typeof Di
|
|
|
9
9
|
declare function DialogContent({ className, children, overlayClassName, variant, headerSize, maxWidth, hideCloseButton, ...props }: DialogContentProps): React.JSX.Element;
|
|
10
10
|
declare function DialogHeader({ className, size, ...props }: DialogHeaderProps): React.JSX.Element;
|
|
11
11
|
declare function DialogTitle({ className, size, align, ...props }: DialogTitleProps): React.JSX.Element;
|
|
12
|
-
declare function DialogDescription({ className, ...props }:
|
|
12
|
+
declare function DialogDescription({ className, visuallyHidden, ...props }: DialogDescriptionProps): React.JSX.Element;
|
|
13
13
|
declare function DialogBody({ className, ...props }: ComponentProps<'div'>): React.JSX.Element;
|
|
14
14
|
declare function DialogFooter({ className, ...props }: ComponentProps<'div'>): React.JSX.Element;
|
|
15
15
|
declare function DialogIcon({ className, ...props }: ComponentProps<'div'>): React.JSX.Element;
|
|
@@ -5,13 +5,14 @@ var _excluded = ["className"],
|
|
|
5
5
|
_excluded2 = ["className", "children", "overlayClassName", "variant", "headerSize", "maxWidth", "hideCloseButton"],
|
|
6
6
|
_excluded3 = ["className", "size"],
|
|
7
7
|
_excluded4 = ["className", "size", "align"],
|
|
8
|
-
_excluded5 = ["className"],
|
|
8
|
+
_excluded5 = ["className", "visuallyHidden"],
|
|
9
9
|
_excluded6 = ["className"],
|
|
10
10
|
_excluded7 = ["className"],
|
|
11
11
|
_excluded8 = ["className"],
|
|
12
12
|
_excluded9 = ["className"],
|
|
13
13
|
_excluded10 = ["className"];
|
|
14
14
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
15
|
+
import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
|
|
15
16
|
import { Button } from '@scaleflex/ui-tw/button';
|
|
16
17
|
import { focusRingClassNames } from '@scaleflex/ui-tw/styles/shared-classes';
|
|
17
18
|
import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
@@ -160,9 +161,22 @@ function DialogTitle(_ref8) {
|
|
|
160
161
|
}), className)
|
|
161
162
|
}, props));
|
|
162
163
|
}
|
|
164
|
+
|
|
165
|
+
// Radix warns ("Missing `Description`...") when a Dialog has no description in the a11y tree.
|
|
166
|
+
// `visuallyHidden` keeps the description for screen readers (silencing the warning) but hides it visually.
|
|
163
167
|
function DialogDescription(_ref9) {
|
|
164
168
|
var className = _ref9.className,
|
|
169
|
+
visuallyHidden = _ref9.visuallyHidden,
|
|
165
170
|
props = _objectWithoutProperties(_ref9, _excluded5);
|
|
171
|
+
if (visuallyHidden) {
|
|
172
|
+
// `asChild` applies the hidden styles to the Description itself, so it stays the `aria-describedby` target without an extra wrapper.
|
|
173
|
+
return /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
174
|
+
asChild: true
|
|
175
|
+
}, /*#__PURE__*/React.createElement(DialogPrimitive.Description, _extends({
|
|
176
|
+
"data-slot": "dialog-description",
|
|
177
|
+
className: className
|
|
178
|
+
}, props)));
|
|
179
|
+
}
|
|
166
180
|
return /*#__PURE__*/React.createElement(DialogPrimitive.Description, _extends({
|
|
167
181
|
"data-slot": "dialog-description",
|
|
168
182
|
className: cn('text-muted-foreground text-sm', className)
|
package/dialog/dialog.types.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export interface DialogTitleProps extends ComponentProps<typeof DialogPrimitive.
|
|
|
20
20
|
size?: DialogHeaderSize;
|
|
21
21
|
align?: DialogTitleAlign;
|
|
22
22
|
}
|
|
23
|
+
export interface DialogDescriptionProps extends ComponentProps<typeof DialogPrimitive.Description> {
|
|
24
|
+
/** Render the description in the a11y tree but hide it visually. Satisfies Radix's `aria-describedby` requirement without showing description text. */
|
|
25
|
+
visuallyHidden?: boolean;
|
|
26
|
+
}
|
|
23
27
|
/** @deprecated Use `DialogHeaderSize` instead */
|
|
24
28
|
export type DialogSize = DialogHeaderSize;
|
|
25
29
|
/** @deprecated Use `DialogTitleAlign` instead */
|
package/dialog/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogErrorIcon, DialogFooter, DialogHeader, DialogIcon, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DialogWarningIcon, DialogFormBody, DialogFormContent, DialogFormDescription, DialogFormErrorIcon, DialogFormFooter, DialogFormHeader, DialogFormIcon, DialogFormTitle, DialogFormWarningIcon, DialogWideBody, DialogWideContent, DialogWideFooter, DialogWideHeader, DialogWideTitle, } from './dialog.component';
|
|
2
2
|
export { dialogCloseButtonPositionVariants, dialogContentWidthVariants, dialogHeaderDefaultVariants, dialogTitleDefaultVariants, dialogWideHeaderVariants, dialogWideTitleVariants, } from './dialog.constants';
|
|
3
|
-
export type { DialogAlign, DialogContentProps, DialogContentWidth, DialogFormContentProps, DialogHeaderProps, DialogHeaderSize, DialogSize, DialogTitleAlign, DialogTitleProps, DialogVariant, DialogWideContentProps, DialogWideHeaderProps, DialogWideTitleProps, } from './dialog.types';
|
|
3
|
+
export type { DialogAlign, DialogContentProps, DialogContentWidth, DialogDescriptionProps, DialogFormContentProps, DialogHeaderProps, DialogHeaderSize, DialogSize, DialogTitleAlign, DialogTitleProps, DialogVariant, DialogWideContentProps, DialogWideHeaderProps, DialogWideTitleProps, } from './dialog.types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.160",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"@radix-ui/react-switch": "^1.0.1",
|
|
30
30
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
31
31
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
32
|
-
"@
|
|
32
|
+
"@radix-ui/react-visually-hidden": "^1.2.4",
|
|
33
|
+
"@scaleflex/icons-tw": "^0.0.160",
|
|
33
34
|
"@tanstack/react-table": "^8.21.3",
|
|
34
35
|
"@types/lodash.merge": "^4.6.9",
|
|
35
36
|
"class-variance-authority": "^0.7.1",
|