@pallasoft/ps-core-components 2.28.0 → 2.29.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/ps-rating-display.d.ts +9 -0
- package/dist/components/ps-rating-display.js +12 -0
- package/dist/components/ps-sortable-list.d.ts +1 -1
- package/dist/components/ps-sortable-list.js +2 -2
- package/dist/constants/ps-rating-display-config.d.ts +10 -0
- package/dist/constants/ps-rating-display-config.js +14 -0
- package/dist/constants/ps-rating-display-size.d.ts +5 -0
- package/dist/constants/ps-rating-display-size.js +9 -0
- package/dist/esm/components/ps-rating-display.js +8 -0
- package/dist/esm/components/ps-sortable-list.js +3 -3
- package/dist/esm/constants/ps-rating-display-config.js +11 -0
- package/dist/esm/constants/ps-rating-display-size.js +6 -0
- package/dist/esm/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/models/ps-sortable-list.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PsRatingDisplaySize } from '../constants/ps-rating-display-size';
|
|
2
|
+
export interface PsRatingDisplayProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
max?: number;
|
|
6
|
+
score: number;
|
|
7
|
+
size?: PsRatingDisplaySize;
|
|
8
|
+
}
|
|
9
|
+
export declare const PsRatingDisplay: ({ className, label, max, score, size, }: PsRatingDisplayProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsRatingDisplay = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ps_design_system_1 = require("@pallasoft/ps-design-system");
|
|
6
|
+
const ps_icons_1 = require("@pallasoft/ps-icons");
|
|
7
|
+
const ps_rating_display_config_1 = require("../constants/ps-rating-display-config");
|
|
8
|
+
const ps_rating_display_size_1 = require("../constants/ps-rating-display-size");
|
|
9
|
+
const PsRatingDisplay = ({ className, label, max = ps_rating_display_config_1.PsRatingDisplayConfig.defaultMax, score, size = ps_rating_display_size_1.PsRatingDisplaySize.Medium, }) => ((0, jsx_runtime_1.jsx)("div", { "aria-label": label, className: ps_design_system_1.PallasoftClassNameService.merge('flex items-center gap-1', className), role: 'img', children: Array.from({ length: max }, (_, index) => index + 1).map((value) => ((0, jsx_runtime_1.jsx)(ps_icons_1.PsIcon, { className: ps_design_system_1.PallasoftClassNameService.merge(ps_rating_display_config_1.PsRatingDisplayConfig.iconClassNames[size], value <= score
|
|
10
|
+
? ps_rating_display_config_1.PsRatingDisplayConfig.filledClassName
|
|
11
|
+
: ps_rating_display_config_1.PsRatingDisplayConfig.emptyClassName), iconKey: ps_icons_1.PsIconKey.Star }, value))) }));
|
|
12
|
+
exports.PsRatingDisplay = PsRatingDisplay;
|
|
@@ -19,4 +19,4 @@ export interface PsSortableListRowProps<TItem extends PsSortableListItem> {
|
|
|
19
19
|
item: TItem;
|
|
20
20
|
renderItem: (options: PsSortableListRenderOptions<TItem>) => JSX.Element | null;
|
|
21
21
|
}
|
|
22
|
-
export declare const PsSortableList: <TItem extends PsSortableListItem>({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, role, items, onMove, renderItem, }: PsSortableListProps<TItem>) => JSX.Element;
|
|
22
|
+
export declare const PsSortableList: <TItem extends PsSortableListItem>({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, isHorizontal, role, items, onMove, renderItem, }: PsSortableListProps<TItem>) => JSX.Element;
|
|
@@ -30,7 +30,7 @@ const PsSortableListRow = ({ className, handleClassName, handleIcon, getHandleLa
|
|
|
30
30
|
transition: isReduced ? undefined : transition,
|
|
31
31
|
}, children: rendered }));
|
|
32
32
|
};
|
|
33
|
-
const PsSortableList = ({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, role, items, onMove, renderItem, }) => {
|
|
33
|
+
const PsSortableList = ({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, isHorizontal = false, role, items, onMove, renderItem, }) => {
|
|
34
34
|
const [activeId, setActiveId] = (0, react_1.useState)(null);
|
|
35
35
|
const sensors = (0, use_ps_drag_sensors_1.usePsDragSensors)();
|
|
36
36
|
const activeIndex = items.findIndex((item) => item.id === activeId);
|
|
@@ -66,7 +66,7 @@ const PsSortableList = ({ announcements: texts, className, getHandleLabel, getIt
|
|
|
66
66
|
onMove(String(active.id), from, to);
|
|
67
67
|
};
|
|
68
68
|
const activeGroup = activeItem === null ? undefined : activeItem.groupKey;
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)(core_1.DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: core_1.closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [(0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: items.map((item) => item.id), strategy: sortable_1.verticalListSortingStrategy, children: (0, jsx_runtime_1.jsx)("div", { className: className, role: role, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), (0, jsx_runtime_1.jsx)(ps_drag_overlay_1.PsDragOverlay, { className: ps_drag_config_1.PsDragClasses.lifted, frames: ps_drag_config_1.PsDragListLiftFrames, children: activeItem !== null
|
|
69
|
+
return ((0, jsx_runtime_1.jsxs)(core_1.DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: core_1.closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [(0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: items.map((item) => item.id), strategy: isHorizontal ? sortable_1.horizontalListSortingStrategy : sortable_1.verticalListSortingStrategy, children: (0, jsx_runtime_1.jsx)("div", { className: className, role: role, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), (0, jsx_runtime_1.jsx)(ps_drag_overlay_1.PsDragOverlay, { className: ps_drag_config_1.PsDragClasses.lifted, frames: ps_drag_config_1.PsDragListLiftFrames, children: activeItem !== null
|
|
70
70
|
? renderItem({
|
|
71
71
|
handle: ((0, jsx_runtime_1.jsx)(PsSortableListHandle, { className: handleClassName, icon: handleIcon, label: getHandleLabel(activeItem.label) })),
|
|
72
72
|
index: activeIndex,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const PsRatingDisplayConfig: {
|
|
2
|
+
readonly defaultMax: 5;
|
|
3
|
+
readonly filledClassName: "fill-current text-primary";
|
|
4
|
+
readonly emptyClassName: "text-ink/30 dark:text-white/30";
|
|
5
|
+
readonly iconClassNames: {
|
|
6
|
+
readonly large: "h-8 w-8";
|
|
7
|
+
readonly medium: "h-6 w-6";
|
|
8
|
+
readonly small: "h-4 w-4";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsRatingDisplayConfig = void 0;
|
|
4
|
+
const ps_rating_display_size_1 = require("./ps-rating-display-size");
|
|
5
|
+
exports.PsRatingDisplayConfig = {
|
|
6
|
+
defaultMax: 5,
|
|
7
|
+
filledClassName: 'fill-current text-primary',
|
|
8
|
+
emptyClassName: 'text-ink/30 dark:text-white/30',
|
|
9
|
+
iconClassNames: {
|
|
10
|
+
[ps_rating_display_size_1.PsRatingDisplaySize.Large]: 'h-8 w-8',
|
|
11
|
+
[ps_rating_display_size_1.PsRatingDisplaySize.Medium]: 'h-6 w-6',
|
|
12
|
+
[ps_rating_display_size_1.PsRatingDisplaySize.Small]: 'h-4 w-4',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsRatingDisplaySize = void 0;
|
|
4
|
+
var PsRatingDisplaySize;
|
|
5
|
+
(function (PsRatingDisplaySize) {
|
|
6
|
+
PsRatingDisplaySize["Large"] = "large";
|
|
7
|
+
PsRatingDisplaySize["Medium"] = "medium";
|
|
8
|
+
PsRatingDisplaySize["Small"] = "small";
|
|
9
|
+
})(PsRatingDisplaySize || (exports.PsRatingDisplaySize = PsRatingDisplaySize = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PallasoftClassNameService } from '@pallasoft/ps-design-system';
|
|
3
|
+
import { PsIcon, PsIconKey } from '@pallasoft/ps-icons';
|
|
4
|
+
import { PsRatingDisplayConfig } from '../constants/ps-rating-display-config';
|
|
5
|
+
import { PsRatingDisplaySize } from '../constants/ps-rating-display-size';
|
|
6
|
+
export const PsRatingDisplay = ({ className, label, max = PsRatingDisplayConfig.defaultMax, score, size = PsRatingDisplaySize.Medium, }) => (_jsx("div", { "aria-label": label, className: PallasoftClassNameService.merge('flex items-center gap-1', className), role: 'img', children: Array.from({ length: max }, (_, index) => index + 1).map((value) => (_jsx(PsIcon, { className: PallasoftClassNameService.merge(PsRatingDisplayConfig.iconClassNames[size], value <= score
|
|
7
|
+
? PsRatingDisplayConfig.filledClassName
|
|
8
|
+
: PsRatingDisplayConfig.emptyClassName), iconKey: PsIconKey.Star }, value))) }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { DndContext, closestCenter, } from '@dnd-kit/core';
|
|
4
|
-
import { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
4
|
+
import { SortableContext, horizontalListSortingStrategy, useSortable, verticalListSortingStrategy, } from '@dnd-kit/sortable';
|
|
5
5
|
import { CSS } from '@dnd-kit/utilities';
|
|
6
6
|
import { PsDragClasses, PsDragConfig, PsDragListLiftFrames } from '../constants/ps-drag-config';
|
|
7
7
|
import { usePsDragSensors } from '../hooks/use-ps-drag-sensors';
|
|
@@ -27,7 +27,7 @@ const PsSortableListRow = ({ className, handleClassName, handleIcon, getHandleLa
|
|
|
27
27
|
transition: isReduced ? undefined : transition,
|
|
28
28
|
}, children: rendered }));
|
|
29
29
|
};
|
|
30
|
-
export const PsSortableList = ({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, role, items, onMove, renderItem, }) => {
|
|
30
|
+
export const PsSortableList = ({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, isHorizontal = false, role, items, onMove, renderItem, }) => {
|
|
31
31
|
const [activeId, setActiveId] = useState(null);
|
|
32
32
|
const sensors = usePsDragSensors();
|
|
33
33
|
const activeIndex = items.findIndex((item) => item.id === activeId);
|
|
@@ -63,7 +63,7 @@ export const PsSortableList = ({ announcements: texts, className, getHandleLabel
|
|
|
63
63
|
onMove(String(active.id), from, to);
|
|
64
64
|
};
|
|
65
65
|
const activeGroup = activeItem === null ? undefined : activeItem.groupKey;
|
|
66
|
-
return (_jsxs(DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [_jsx(SortableContext, { items: items.map((item) => item.id), strategy: verticalListSortingStrategy, children: _jsx("div", { className: className, role: role, children: items.map((item, index) => (_jsx(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), _jsx(PsDragOverlay, { className: PsDragClasses.lifted, frames: PsDragListLiftFrames, children: activeItem !== null
|
|
66
|
+
return (_jsxs(DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [_jsx(SortableContext, { items: items.map((item) => item.id), strategy: isHorizontal ? horizontalListSortingStrategy : verticalListSortingStrategy, children: _jsx("div", { className: className, role: role, children: items.map((item, index) => (_jsx(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), _jsx(PsDragOverlay, { className: PsDragClasses.lifted, frames: PsDragListLiftFrames, children: activeItem !== null
|
|
67
67
|
? renderItem({
|
|
68
68
|
handle: (_jsx(PsSortableListHandle, { className: handleClassName, icon: handleIcon, label: getHandleLabel(activeItem.label) })),
|
|
69
69
|
index: activeIndex,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PsRatingDisplaySize } from './ps-rating-display-size';
|
|
2
|
+
export const PsRatingDisplayConfig = {
|
|
3
|
+
defaultMax: 5,
|
|
4
|
+
filledClassName: 'fill-current text-primary',
|
|
5
|
+
emptyClassName: 'text-ink/30 dark:text-white/30',
|
|
6
|
+
iconClassNames: {
|
|
7
|
+
[PsRatingDisplaySize.Large]: 'h-8 w-8',
|
|
8
|
+
[PsRatingDisplaySize.Medium]: 'h-6 w-6',
|
|
9
|
+
[PsRatingDisplaySize.Small]: 'h-4 w-4',
|
|
10
|
+
},
|
|
11
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -154,3 +154,5 @@ export * from './hooks/use-ps-drag-sensors';
|
|
|
154
154
|
export * from './hooks/use-ps-reduced-motion';
|
|
155
155
|
export * from './components/ps-divider';
|
|
156
156
|
export * from './models/ps-divider-orientation';
|
|
157
|
+
export * from './components/ps-rating-display';
|
|
158
|
+
export * from './constants/ps-rating-display-size';
|
package/dist/index.d.ts
CHANGED
|
@@ -154,3 +154,5 @@ export * from './hooks/use-ps-drag-sensors';
|
|
|
154
154
|
export * from './hooks/use-ps-reduced-motion';
|
|
155
155
|
export * from './components/ps-divider';
|
|
156
156
|
export * from './models/ps-divider-orientation';
|
|
157
|
+
export * from './components/ps-rating-display';
|
|
158
|
+
export * from './constants/ps-rating-display-size';
|
package/dist/index.js
CHANGED
|
@@ -170,3 +170,5 @@ __exportStar(require("./hooks/use-ps-drag-sensors"), exports);
|
|
|
170
170
|
__exportStar(require("./hooks/use-ps-reduced-motion"), exports);
|
|
171
171
|
__exportStar(require("./components/ps-divider"), exports);
|
|
172
172
|
__exportStar(require("./models/ps-divider-orientation"), exports);
|
|
173
|
+
__exportStar(require("./components/ps-rating-display"), exports);
|
|
174
|
+
__exportStar(require("./constants/ps-rating-display-size"), exports);
|
|
@@ -27,6 +27,7 @@ export interface PsSortableListProps<TItem extends PsSortableListItem> {
|
|
|
27
27
|
handleIcon?: JSX.Element;
|
|
28
28
|
instructions: string;
|
|
29
29
|
items: TItem[];
|
|
30
|
+
isHorizontal?: boolean;
|
|
30
31
|
onMove: (itemId: string, fromIndex: number, toIndex: number) => void;
|
|
31
32
|
renderItem: (options: PsSortableListRenderOptions<TItem>) => JSX.Element | null;
|
|
32
33
|
}
|