@laser-ui/components 2.2.0 → 2.3.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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
4
4
 
5
+ # [2.3.0](https://github.com/laser-ui/laser-ui/compare/v2.2.0...v2.3.0) (2025-08-07)
6
+
7
+ ### Features
8
+
9
+ - **components:** dropdown support theme ([1b45410](https://github.com/laser-ui/laser-ui/commit/1b454104bffd7e1b2b473fe9254afe95ed3d432e))
10
+
5
11
  # [2.2.0](https://github.com/laser-ui/laser-ui/compare/v2.1.3...v2.2.0) (2025-06-23)
6
12
 
7
13
  ### Bug Fixes
@@ -29,7 +29,7 @@ export function DropdownList(props) {
29
29
  vsRef.current = null;
30
30
  };
31
31
  }, enable: virtual !== false, listSize: 200 + 32 * 2, listPadding: 4, itemRender: (item, index, props, ancestry, childrenNode) => {
32
- const { id: itemId, title: itemTitle, type: itemType, icon: itemIcon, disabled: itemDisabled = false, separator: itemSeparator, children, } = item;
32
+ const { id: itemId, title: itemTitle, type: itemType, icon: itemIcon, theme: itemTheme, disabled: itemDisabled = false, separator: itemSeparator, children, } = item;
33
33
  const id = getItemId(itemId);
34
34
  const isFocus = itemId === focusId;
35
35
  const popupState = popupIds.find((v) => v.id === itemId);
@@ -129,6 +129,7 @@ export function DropdownList(props) {
129
129
  };
130
130
  }
131
131
  return (_jsxs(Fragment, { children: [itemSeparator && _jsx(Separator, { style: { margin: '2px 0' } }), itemType === 'item' ? (_jsxs("li", Object.assign({}, styled('dropdown__item', 'dropdown__item--item', {
132
+ [`dropdown__item.t-${itemTheme}`]: !itemDisabled && itemTheme,
132
133
  'dropdown__item.is-disabled': itemDisabled,
133
134
  }), { id: id, role: "menuitem", "aria-disabled": itemDisabled, onClick: handleItemClick, children: [focusVisible && isFocus && _jsx("div", { className: `${namespace}-focus-outline` }), checkNodeExist(itemIcon) && _jsx("div", Object.assign({}, styled('dropdown__item-icon'), { children: itemIcon })), _jsx("div", Object.assign({}, styled('dropdown__item-content'), { children: itemTitle }))] }))) : itemType === 'group' ? (_jsxs(_Fragment, { children: [_jsx("li", Object.assign({}, styled('dropdown__group-title'), { id: id, role: "presentation", children: itemTitle })), _jsx("ul", Object.assign({}, mergeCS(styled('dropdown__group-list'), {
134
135
  style: {
@@ -152,7 +153,7 @@ export function DropdownList(props) {
152
153
  return () => {
153
154
  updateSubPosition.current.delete(itemId);
154
155
  };
155
- }, namespace: namespace, styled: styled, id: id, icon: itemIcon, list: _jsx(DropdownList, { namespace: namespace, styled: styled, ulProps: { 'aria-labelledby': id }, list: (children !== null && children !== void 0 ? children : []), ancestryOfSub: currentAncestryOfSub, virtual: virtual, focusVisible: focusVisible, focusId: focusId, popupIds: popupIds, updateSubPosition: updateSubPosition, trigger: trigger, zIndex: zIndex, handleKeyDown: handleKeyDown, getItemId: getItemId, onClick: onClick, onFocusIdsChange: onFocusIdsChange, onPopupIdsChange: onPopupIdsChange, addPopupId: addPopupId, removePopupId: removePopupId, onVisibleChange: onVisibleChange }), popupState: popupState === null || popupState === void 0 ? void 0 : popupState.visible, trigger: trigger, focus: focusVisible && isFocus, disabled: itemDisabled, zIndex: isUndefined(zIndex)
156
+ }, namespace: namespace, styled: styled, id: id, icon: itemIcon, theme: itemTheme, list: _jsx(DropdownList, { namespace: namespace, styled: styled, ulProps: { 'aria-labelledby': id }, list: (children !== null && children !== void 0 ? children : []), ancestryOfSub: currentAncestryOfSub, virtual: virtual, focusVisible: focusVisible, focusId: focusId, popupIds: popupIds, updateSubPosition: updateSubPosition, trigger: trigger, zIndex: zIndex, handleKeyDown: handleKeyDown, getItemId: getItemId, onClick: onClick, onFocusIdsChange: onFocusIdsChange, onPopupIdsChange: onPopupIdsChange, addPopupId: addPopupId, removePopupId: removePopupId, onVisibleChange: onVisibleChange }), popupState: popupState === null || popupState === void 0 ? void 0 : popupState.visible, trigger: trigger, focus: focusVisible && isFocus, disabled: itemDisabled, zIndex: isUndefined(zIndex)
156
157
  ? zIndex
157
158
  : isNumber(zIndex)
158
159
  ? zIndex + 1 + ancestryOfSub.length
@@ -8,6 +8,7 @@ interface DropdownSubProps {
8
8
  styled: Styled<typeof CLASSES>;
9
9
  id: string;
10
10
  icon: React.ReactNode | undefined;
11
+ theme: 'primary' | 'success' | 'warning' | 'danger' | undefined;
11
12
  list: React.ReactNode;
12
13
  popupState: boolean | undefined;
13
14
  trigger: 'hover' | 'click';
@@ -11,7 +11,7 @@ import { Transition } from '../../transition';
11
11
  import { getHorizontalSidePosition, mergeCS } from '../../utils';
12
12
  import { TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../../vars';
13
13
  export function DropdownSub(props) {
14
- const { ref, children, namespace, styled, id, icon, list, popupState, trigger, focus, disabled, zIndex, onVisibleChange } = props;
14
+ const { ref, children, namespace, styled, id, icon, theme, list, popupState, trigger, focus, disabled, zIndex, onVisibleChange } = props;
15
15
  const triggerRef = useRef(null);
16
16
  const popupRef = useRef(null);
17
17
  const visible = !isUndefined(popupState);
@@ -34,6 +34,7 @@ export function DropdownSub(props) {
34
34
  popupRef,
35
35
  scroll: false,
36
36
  }, onVisibleChange: onVisibleChange, children: (popupProps) => (_jsxs(_Fragment, { children: [_jsxs("li", Object.assign({}, styled('dropdown__item', 'dropdown__item--sub', {
37
+ [`dropdown__item.t-${theme}`]: !disabled && theme,
37
38
  'dropdown__item.is-expand': visible,
38
39
  'dropdown__item.is-disabled': disabled,
39
40
  }), { ref: (instance) => {
@@ -10,6 +10,7 @@ export interface DropdownItem<ID extends React.Key> {
10
10
  title: React.ReactNode;
11
11
  type: 'item' | 'group' | 'sub';
12
12
  icon?: React.ReactNode;
13
+ theme?: 'primary' | 'success' | 'warning' | 'danger';
13
14
  disabled?: boolean;
14
15
  separator?: boolean;
15
16
  children?: DropdownItem<ID>[];
@@ -7,6 +7,10 @@ export declare const CLASSES: {
7
7
  'dropdown--bottom-left': string;
8
8
  'dropdown--bottom-right': string;
9
9
  dropdown__item: string;
10
+ 'dropdown__item.t-primary': string;
11
+ 'dropdown__item.t-success': string;
12
+ 'dropdown__item.t-warning': string;
13
+ 'dropdown__item.t-danger': string;
10
14
  'dropdown__item--item': string;
11
15
  'dropdown__item--sub': string;
12
16
  'dropdown__item.is-expand': string;
@@ -15,6 +19,10 @@ export declare const CLASSES: {
15
19
  'dropdown__item-content': string;
16
20
  'dropdown__group-list': string;
17
21
  'dropdown__group-title': string;
22
+ 'dropdown__group-title.t-primary': string;
23
+ 'dropdown__group-title.t-success': string;
24
+ 'dropdown__group-title.t-warning': string;
25
+ 'dropdown__group-title.t-danger': string;
18
26
  'dropdown__sub-arrow': string;
19
27
  dropdown__list: string;
20
28
  dropdown__empty: string;
package/dropdown/vars.js CHANGED
@@ -7,6 +7,10 @@ export const CLASSES = {
7
7
  'dropdown--bottom-left': '^dropdown--bottom-left',
8
8
  'dropdown--bottom-right': '^dropdown--bottom-right',
9
9
  dropdown__item: '^dropdown__item',
10
+ 'dropdown__item.t-primary': 't-primary',
11
+ 'dropdown__item.t-success': 't-success',
12
+ 'dropdown__item.t-warning': 't-warning',
13
+ 'dropdown__item.t-danger': 't-danger',
10
14
  'dropdown__item--item': '^dropdown__item--item',
11
15
  'dropdown__item--sub': '^dropdown__item--sub',
12
16
  'dropdown__item.is-expand': 'is-expand',
@@ -15,6 +19,10 @@ export const CLASSES = {
15
19
  'dropdown__item-content': '^dropdown__item-content',
16
20
  'dropdown__group-list': '^dropdown__group-list',
17
21
  'dropdown__group-title': '^dropdown__group-title',
22
+ 'dropdown__group-title.t-primary': 't-primary',
23
+ 'dropdown__group-title.t-success': 't-success',
24
+ 'dropdown__group-title.t-warning': 't-warning',
25
+ 'dropdown__group-title.t-danger': 't-danger',
18
26
  'dropdown__sub-arrow': '^dropdown__sub-arrow',
19
27
  dropdown__list: '^dropdown__list',
20
28
  dropdown__empty: '^dropdown__empty',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laser-ui/components",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "React components.",
5
5
  "keywords": [
6
6
  "ui",
@@ -37,5 +37,5 @@
37
37
  "access": "public",
38
38
  "directory": "../../dist/libs/components"
39
39
  },
40
- "gitHead": "be091d302eaa1c5a3fa73cebbcdab245ec8b1e1f"
40
+ "gitHead": "aff4c4046d630e70c12a57491faed6d84cd21a77"
41
41
  }