@paroicms/react-ui 0.4.4 → 0.5.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 (133) hide show
  1. package/dist/Accordion.d.ts +10 -0
  2. package/dist/{PuAccordion.jsx → Accordion.js} +5 -8
  3. package/dist/Alert.d.ts +10 -0
  4. package/dist/Alert.js +7 -0
  5. package/dist/Badge.d.ts +8 -0
  6. package/dist/Badge.js +6 -0
  7. package/dist/Breadcrumb.d.ts +14 -0
  8. package/dist/Breadcrumb.js +10 -0
  9. package/dist/Button.d.ts +36 -0
  10. package/dist/Button.js +74 -0
  11. package/dist/Card.d.ts +10 -0
  12. package/dist/Card.js +7 -0
  13. package/dist/Checkbox.d.ts +9 -0
  14. package/dist/Checkbox.js +12 -0
  15. package/dist/Chip.d.ts +8 -0
  16. package/dist/Chip.js +7 -0
  17. package/dist/Column.d.ts +14 -0
  18. package/dist/Column.js +7 -0
  19. package/dist/DataTable.d.ts +30 -0
  20. package/dist/DataTable.js +26 -0
  21. package/dist/DateInput.d.ts +9 -0
  22. package/dist/DateInput.js +7 -0
  23. package/dist/Dialog.d.ts +13 -0
  24. package/dist/Dialog.js +51 -0
  25. package/dist/Inplace.d.ts +12 -0
  26. package/dist/Inplace.js +16 -0
  27. package/dist/InputNumber.d.ts +10 -0
  28. package/dist/InputNumber.js +19 -0
  29. package/dist/InputText.d.ts +14 -0
  30. package/dist/InputText.js +11 -0
  31. package/dist/MenuItem.d.ts +8 -0
  32. package/dist/MenuItem.js +18 -0
  33. package/dist/MultiSelect.d.ts +18 -0
  34. package/dist/MultiSelect.js +53 -0
  35. package/dist/Panel.d.ts +11 -0
  36. package/dist/Panel.js +9 -0
  37. package/dist/PasswordInput.d.ts +8 -0
  38. package/dist/PasswordInput.js +10 -0
  39. package/dist/PopupMenu.d.ts +19 -0
  40. package/dist/PopupMenu.js +106 -0
  41. package/dist/RadioButton.d.ts +9 -0
  42. package/dist/RadioButton.js +12 -0
  43. package/dist/Select.d.ts +18 -0
  44. package/dist/Select.js +11 -0
  45. package/dist/SideMenu.d.ts +5 -0
  46. package/dist/SideMenu.js +13 -0
  47. package/dist/SortableList.d.ts +19 -0
  48. package/dist/SortableList.js +27 -0
  49. package/dist/Spinner.d.ts +2 -0
  50. package/dist/Spinner.js +5 -0
  51. package/dist/SplitButton.d.ts +25 -0
  52. package/dist/SplitButton.js +39 -0
  53. package/dist/Switch.d.ts +9 -0
  54. package/dist/Switch.js +12 -0
  55. package/dist/Tabs.d.ts +22 -0
  56. package/dist/Tabs.js +21 -0
  57. package/dist/Textarea.d.ts +8 -0
  58. package/dist/Textarea.js +7 -0
  59. package/dist/ToggleButton.d.ts +11 -0
  60. package/dist/ToggleButton.js +6 -0
  61. package/dist/ToggleGroup.d.ts +15 -0
  62. package/dist/ToggleGroup.js +6 -0
  63. package/dist/Tooltip.d.ts +10 -0
  64. package/dist/Tooltip.js +29 -0
  65. package/dist/Tree.d.ts +22 -0
  66. package/dist/Tree.js +43 -0
  67. package/dist/alert-stack.d.ts +20 -0
  68. package/dist/alert-stack.js +72 -0
  69. package/dist/index.d.ts +36 -10
  70. package/dist/index.js +45 -10
  71. package/dist/paroi-ui-lib-types.d.ts +4 -4
  72. package/dist/popup-positioning.d.ts +10 -0
  73. package/dist/popup-positioning.js +160 -0
  74. package/dist/react-ui-provider.d.ts +15 -0
  75. package/dist/react-ui-provider.js +22 -0
  76. package/package.json +16 -2
  77. package/styles/Accordion.css +46 -0
  78. package/styles/Alert.css +77 -0
  79. package/styles/Badge.css +59 -0
  80. package/styles/Breadcrumb.css +57 -0
  81. package/styles/Button.css +167 -0
  82. package/styles/Card.css +28 -0
  83. package/styles/Checkbox.css +61 -0
  84. package/styles/Chip.css +35 -0
  85. package/styles/DataTable.css +176 -0
  86. package/styles/DateInput.css +59 -0
  87. package/styles/Dialog.css +88 -0
  88. package/styles/Inplace.css +44 -0
  89. package/styles/InputNumber.css +60 -0
  90. package/styles/InputText.css +99 -0
  91. package/styles/MenuItem.css +169 -0
  92. package/styles/MultiSelect.css +143 -0
  93. package/styles/Panel.css +40 -0
  94. package/styles/PasswordInput.css +80 -0
  95. package/styles/PopupMenu.css +37 -0
  96. package/styles/RadioButton.css +60 -0
  97. package/styles/Select.css +72 -0
  98. package/styles/SideMenu.css +7 -0
  99. package/styles/SortableList.css +32 -0
  100. package/styles/Spinner.css +30 -0
  101. package/styles/SplitButton.css +137 -0
  102. package/styles/Switch.css +60 -0
  103. package/styles/Tabs.css +94 -0
  104. package/styles/Textarea.css +66 -0
  105. package/styles/ToggleButton.css +36 -0
  106. package/styles/ToggleGroup.css +55 -0
  107. package/styles/Tooltip.css +20 -0
  108. package/styles/Tree.css +162 -0
  109. package/styles/theme/base.css +40 -0
  110. package/styles/theme/common.css +410 -0
  111. package/styles/theme/index.css +15 -0
  112. package/styles/theme/margins.css +119 -0
  113. package/styles/theme/reset.css +119 -0
  114. package/styles/theme/tokens.css +226 -0
  115. package/dist/PuAccordion.d.ts +0 -9
  116. package/dist/PuButton.d.ts +0 -14
  117. package/dist/PuButton.jsx +0 -15
  118. package/dist/PuCheckbox.d.ts +0 -8
  119. package/dist/PuCheckbox.jsx +0 -13
  120. package/dist/PuInput.d.ts +0 -10
  121. package/dist/PuInput.jsx +0 -13
  122. package/dist/PuMenuItem.d.ts +0 -7
  123. package/dist/PuMenuItem.jsx +0 -33
  124. package/dist/PuPopupMenu.d.ts +0 -14
  125. package/dist/PuPopupMenu.jsx +0 -135
  126. package/dist/PuSelect.d.ts +0 -17
  127. package/dist/PuSelect.jsx +0 -24
  128. package/dist/PuSideMenu.d.ts +0 -4
  129. package/dist/PuSideMenu.jsx +0 -15
  130. package/dist/PuSpinner.d.ts +0 -1
  131. package/dist/PuSpinner.jsx +0 -3
  132. package/dist/svg-icons.d.ts +0 -5
  133. package/dist/svg-icons.jsx +0 -30
@@ -1,135 +0,0 @@
1
- import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
2
- import { PuButton } from "./PuButton.jsx";
3
- import { PuMenuItem } from "./PuMenuItem.jsx";
4
- import { PopupMenuBtnSvg, SubMenuIconLeft } from "./svg-icons.jsx";
5
- const isPopoverSupported = typeof HTMLElement !== "undefined" && "showPopover" in HTMLElement.prototype;
6
- if (!isPopoverSupported) {
7
- console?.error("PuPopupMenu: Popover API is not supported in this browser.");
8
- }
9
- let seq = 0;
10
- /**
11
- * Utility function to configure popup positioning
12
- */
13
- function setupPopoverPositioning(element, getPosition) {
14
- const handleToggle = (e) => {
15
- const newState = e.newState;
16
- if (newState === "open") {
17
- const position = getPosition();
18
- element.style.position = "absolute";
19
- element.style.top = `${position.top}px`;
20
- element.style.left = `${position.left}px`;
21
- }
22
- };
23
- element.addEventListener("toggle", handleToggle);
24
- return () => element.removeEventListener("toggle", handleToggle);
25
- }
26
- export const PuPopupMenu = forwardRef(function PuPopupMenu({ items, className = "", id, autoPosition = true }, ref) {
27
- const menuRef = useRef(null);
28
- const buttonRef = useRef(null);
29
- const menuIdRef = useRef(undefined);
30
- if (menuIdRef.current === undefined) {
31
- menuIdRef.current = id ?? `pu-popup-menu-${++seq}`;
32
- }
33
- const toggle = (_ev) => {
34
- if (menuRef.current) {
35
- menuRef.current.togglePopover();
36
- }
37
- };
38
- const show = (_ev) => {
39
- if (menuRef.current) {
40
- menuRef.current.showPopover();
41
- }
42
- };
43
- const hide = () => {
44
- if (menuRef.current) {
45
- menuRef.current.hidePopover();
46
- }
47
- };
48
- useImperativeHandle(ref, () => ({
49
- toggle,
50
- show,
51
- hide,
52
- }));
53
- // Position popover when it opens
54
- useEffect(() => {
55
- if (!autoPosition || !menuRef.current || !buttonRef.current)
56
- return;
57
- const menuEl = menuRef.current;
58
- return setupPopoverPositioning(menuEl, () => {
59
- const rect = buttonRef.current?.getBoundingClientRect();
60
- return {
61
- top: rect ? rect.bottom + window.scrollY : 0,
62
- left: rect ? rect.left + window.scrollX : 0,
63
- };
64
- });
65
- }, [autoPosition]);
66
- const buttonProps = {
67
- popoverTarget: menuIdRef.current,
68
- popoverTargetAction: "toggle",
69
- };
70
- return (<>
71
- <PuButton ref={buttonRef} className={className} outlined severity="secondary" aria-label="unfold" // should be localized
72
- aria-controls={menuIdRef.current} aria-haspopup {...buttonProps}>
73
- <PopupMenuBtnSvg />
74
- </PuButton>
75
-
76
- <div className="PuPopupMenu" ref={menuRef} id={menuIdRef.current} popover="auto">
77
- <div className="PuPopupMenu-content">
78
- {items.map((item) => (<PopupMenuItemWrapper key={item.key} item={item} onHide={hide}/>))}
79
- </div>
80
- </div>
81
- </>);
82
- });
83
- function PopupMenuItemWrapper({ item, onHide }) {
84
- const subMenuRef = useRef(null);
85
- const subMenuId = useRef(`pu-submenu-${item.key}-${Math.random().toString(36).substring(2, 9)}`);
86
- // For items with submenu, override the command to toggle the submenu
87
- const itemWithSubmenuHandling = { ...item };
88
- if (item.subMenu && item.subMenu.length > 0) {
89
- // Create submenu trigger icon
90
- const originalIcon = item.icon;
91
- itemWithSubmenuHandling.icon = originalIcon || <SubMenuIconLeft />;
92
- // Create a command that opens the submenu
93
- const originalCommand = item.command;
94
- itemWithSubmenuHandling.command = () => {
95
- if (originalCommand) {
96
- originalCommand();
97
- }
98
- // Will be handled by popovertarget attribute
99
- };
100
- }
101
- else {
102
- // For regular items, add onHide to the command
103
- const originalCommand = item.command;
104
- itemWithSubmenuHandling.command = () => {
105
- if (originalCommand) {
106
- originalCommand();
107
- }
108
- onHide();
109
- };
110
- }
111
- // Handle submenu positioning with Popover API
112
- useEffect(() => {
113
- if (!subMenuRef.current || !item.subMenu)
114
- return;
115
- const subMenuEl = subMenuRef.current;
116
- return setupPopoverPositioning(subMenuEl, () => {
117
- const parentEl = subMenuEl.parentElement;
118
- if (parentEl) {
119
- const rect = parentEl.getBoundingClientRect();
120
- return {
121
- top: rect.top,
122
- left: rect.right + 5, // 5px gap
123
- };
124
- }
125
- return { top: 0, left: 0 };
126
- });
127
- }, [item.subMenu]);
128
- return (<div className="PuPopupMenu-item" popoverTargetAction="toggle" popoverTarget={subMenuId.current}>
129
- <PuMenuItem item={itemWithSubmenuHandling}/>
130
-
131
- {item.subMenu && (<div className="PuPopupMenu-submenu" popover="auto" id={subMenuId.current} ref={subMenuRef}>
132
- {item.subMenu.map((subItem) => (<PopupMenuItemWrapper key={subItem.key} item={subItem} onHide={onHide}/>))}
133
- </div>)}
134
- </div>);
135
- }
@@ -1,17 +0,0 @@
1
- import type { SelectHTMLAttributes } from "react";
2
- export interface PuSelectOption {
3
- value: string;
4
- label: string;
5
- disabled?: boolean;
6
- }
7
- export interface PuSelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "onChange"> {
8
- value: string;
9
- onChange: (value: string) => void;
10
- options: PuSelectOption[];
11
- label?: string;
12
- error?: string;
13
- className?: string;
14
- fullWidth?: boolean;
15
- placeholder?: string;
16
- }
17
- export declare function PuSelect({ value, onChange, options, label, error, className, fullWidth, placeholder, ...rest }: PuSelectProps): import("react").JSX.Element;
package/dist/PuSelect.jsx DELETED
@@ -1,24 +0,0 @@
1
- import { ChevronDownIcon } from "./svg-icons.jsx";
2
- export function PuSelect({ value, onChange, options, label, error, className = "", fullWidth = false, placeholder, ...rest }) {
3
- const handleChange = (e) => {
4
- onChange(e.target.value);
5
- };
6
- const selectClasses = ["PuSelect", error ? "error" : "", fullWidth ? "fullWidth" : "", className]
7
- .filter(Boolean)
8
- .join(" ");
9
- return (<div className={selectClasses}>
10
- {label && <label className="PuSelect-label">{label}</label>}
11
- <div className="PuSelect-wrapper">
12
- <select className="PuSelect-field" value={value} onChange={handleChange} {...rest}>
13
- {placeholder && (<option value="" disabled>
14
- {placeholder}
15
- </option>)}
16
- {options.map((option) => (<option key={option.value} value={option.value} disabled={option.disabled}>
17
- {option.label}
18
- </option>))}
19
- </select>
20
- <ChevronDownIcon />
21
- </div>
22
- {error && <div className="PuSelect-error">{error}</div>}
23
- </div>);
24
- }
@@ -1,4 +0,0 @@
1
- import type { PuMenuNode } from "./paroi-ui-lib-types.js";
2
- export declare function PuSideMenu({ menu }: {
3
- menu: PuMenuNode[];
4
- }): import("react").JSX.Element;
@@ -1,15 +0,0 @@
1
- import { PuAccordion } from "./PuAccordion.jsx";
2
- import { PuMenuItem } from "./PuMenuItem.jsx";
3
- export function PuSideMenu({ menu }) {
4
- return (<>
5
- {menu.map((child) => (<PuAccordionOrMenuItem item={child} key={child.key}/>))}
6
- </>);
7
- }
8
- function PuAccordionOrMenuItem({ item }) {
9
- if (item.subMenu) {
10
- return (<PuAccordion header={item} expanded={item.expanded}>
11
- {item.subMenu.map((child) => (<PuAccordionOrMenuItem item={child} key={child.key}/>))}
12
- </PuAccordion>);
13
- }
14
- return <PuMenuItem item={item}/>;
15
- }
@@ -1 +0,0 @@
1
- export declare function PuSpinner(): import("react").JSX.Element;
@@ -1,3 +0,0 @@
1
- export function PuSpinner() {
2
- return <div className="PuSpinner"/>;
3
- }
@@ -1,5 +0,0 @@
1
- export declare function PopupMenuBtnSvg(): import("react").JSX.Element;
2
- export declare function SubMenuIconLeft(): import("react").JSX.Element;
3
- export declare function SubMenuIconBottom(): import("react").JSX.Element;
4
- export declare function ChevronDownIcon(): import("react").JSX.Element;
5
- export declare function SubMenuIcon(): import("react").JSX.Element;
@@ -1,30 +0,0 @@
1
- export function PopupMenuBtnSvg() {
2
- return (<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
3
- <title>⇓</title>
4
- <path fill="currentColor" d="M12.146 7.146a.5.5 0 0 1 .708.708l-4.5 4.5a.5.5 0 0 1-.708 0l-4.5-4.5a.5.5 0 1 1 .708-.708L8 11.293zm0-4a.5.5 0 0 1 .708.708l-4.5 4.5a.5.5 0 0 1-.708 0l-4.5-4.5a.5.5 0 1 1 .708-.708L8 7.293z"/>
5
- </svg>);
6
- }
7
- export function SubMenuIconLeft() {
8
- return (<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" className="submenu-icon">
9
- <title>→</title>
10
- <path d="M4.38708 13C4.28408 13.0005 4.18203 12.9804 4.08691 12.9409C3.99178 12.9014 3.9055 12.8433 3.83313 12.7701C3.68634 12.6231 3.60388 12.4238 3.60388 12.2161C3.60388 12.0084 3.68634 11.8091 3.83313 11.6622L8.50507 6.99022L3.83313 2.31827C3.69467 2.16968 3.61928 1.97313 3.62287 1.77005C3.62645 1.56698 3.70872 1.37322 3.85234 1.22959C3.99596 1.08597 4.18972 1.00371 4.3928 1.00012C4.59588 0.996539 4.79242 1.07192 4.94102 1.21039L10.1669 6.43628C10.3137 6.58325 10.3962 6.78249 10.3962 6.99022C10.3962 7.19795 10.3137 7.39718 10.1669 7.54416L4.94102 12.7701C4.86865 12.8433 4.78237 12.9014 4.68724 12.9409C4.59212 12.9804 4.49007 13.0005 4.38708 13Z" fill="currentColor"/>
11
- </svg>);
12
- }
13
- export function SubMenuIconBottom() {
14
- return (<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" className="submenu-icon">
15
- <title>↓</title>
16
- <path d="M7.01744 10.398C6.91269 10.3985 6.8089 10.378 6.71215 10.3379C6.61541 10.2977 6.52766 10.2386 6.45405 10.1641L1.13907 4.84913C1.03306 4.69404 0.985221 4.5065 1.00399 4.31958C1.02276 4.13266 1.10693 3.95838 1.24166 3.82747C1.37639 3.69655 1.55301 3.61742 1.74039 3.60402C1.92777 3.59062 2.11386 3.64382 2.26584 3.75424L7.01744 8.47394L11.769 3.75424C11.9189 3.65709 12.097 3.61306 12.2748 3.62921C12.4527 3.64535 12.6199 3.72073 12.7498 3.84328C12.8797 3.96582 12.9647 4.12842 12.9912 4.30502C13.0177 4.48162 12.9841 4.662 12.8958 4.81724L7.58083 10.1322C7.50996 10.2125 7.42344 10.2775 7.32656 10.3232C7.22968 10.3689 7.12449 10.3944 7.01744 10.398Z" fill="currentColor"/>
17
- </svg>);
18
- }
19
- export function ChevronDownIcon() {
20
- return (<svg className="PuSelect-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
21
- <title>DOWN</title>
22
- <path d="M7.01744 10.398C6.91269 10.3985 6.8089 10.378 6.71215 10.3379C6.61541 10.2977 6.52766 10.2386 6.45405 10.1641L1.13907 4.84913C1.03306 4.69404 0.985221 4.5065 1.00399 4.31958C1.02276 4.13266 1.10693 3.95838 1.24166 3.82747C1.37639 3.69655 1.55301 3.61742 1.74039 3.60402C1.92777 3.59062 2.11386 3.64382 2.26584 3.75424L7.01744 8.47394L11.769 3.75424C11.9189 3.65709 12.097 3.61306 12.2748 3.62921C12.4527 3.64535 12.6199 3.72073 12.7498 3.84328C12.8797 3.96582 12.9647 4.12842 12.9912 4.30502C13.0177 4.48162 12.9841 4.662 12.8958 4.81724L7.58083 10.1322C7.50996 10.2125 7.42344 10.2775 7.32656 10.3232C7.22968 10.3689 7.12449 10.3944 7.01744 10.398Z" fill="currentColor"/>
23
- </svg>);
24
- }
25
- export function SubMenuIcon() {
26
- return (<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
27
- <title>...</title>
28
- <path d="M4.38708 13C4.28408 13.0005 4.18203 12.9804 4.08691 12.9409C3.99178 12.9014 3.9055 12.8433 3.83313 12.7701C3.68634 12.6231 3.60388 12.4238 3.60388 12.2161C3.60388 12.0084 3.68634 11.8091 3.83313 11.6622L8.50507 6.99022L3.83313 2.31827C3.69467 2.16968 3.61928 1.97313 3.62287 1.77005C3.62645 1.56698 3.70872 1.37322 3.85234 1.22959C3.99596 1.08597 4.18972 1.00371 4.3928 1.00012C4.59588 0.996539 4.79242 1.07192 4.94102 1.21039L10.1669 6.43628C10.3137 6.58325 10.3962 6.78249 10.3962 6.99022C10.3962 7.19795 10.3137 7.39718 10.1669 7.54416L4.94102 12.7701C4.86865 12.8433 4.78237 12.9014 4.68724 12.9409C4.59212 12.9804 4.49007 13.0005 4.38708 13Z" fill="currentColor"/>
29
- </svg>);
30
- }