idea-react 3.0.0-rc.0 → 3.0.0-rc.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.
@@ -5,18 +5,19 @@ import { ComponentTheme } from '../Base/Button';
5
5
  import { Icon, IconProps } from '../Extension/Icon';
6
6
  import { polymorphic } from '../Helper/Polymorphic';
7
7
 
8
- export type ChipProps = ComponentPropsWithRef<'button'> & {
8
+ export type ChipProps = ComponentPropsWithRef<'span'> & {
9
9
  active?: boolean;
10
10
  theme?: ComponentTheme;
11
+ type?: ComponentPropsWithRef<'button'>['type'];
11
12
  };
12
13
 
13
14
  export const Chip = polymorphic<ChipProps>(
14
- ({ as: Root = 'button', className, active, theme, type = 'button', ...props }) => (
15
+ ({ as: Root = 'span', className, active, theme, type = 'button', ...props }) => (
15
16
  <Root
16
17
  {...props}
17
18
  className={classNames('chip', { active }, theme && `theme-${theme}`, className)}
18
19
  type={Root === 'button' ? type : undefined}
19
- aria-pressed={active}
20
+ aria-pressed={Root === 'button' ? active : undefined}
20
21
  />
21
22
  )
22
23
  );
@@ -44,21 +45,8 @@ export const ChipDismiss = polymorphic<ComponentPropsWithRef<'button'>>(
44
45
  aria-label={label}
45
46
  className={classNames('chip-dismiss', className)}
46
47
  >
47
- {children ?? <Icon name="x-lg" aria-hidden="true" />}
48
+ {children ?? <Icon name="x-lg" />}
48
49
  </Root>
49
50
  )
50
51
  );
51
52
  ChipDismiss.displayName = 'ChipDismiss';
52
-
53
- export type ChipTokenProps = ComponentPropsWithRef<'span'> & Pick<ChipProps, 'active' | 'theme'>;
54
-
55
- export const ChipToken = polymorphic<ChipTokenProps>(
56
- ({ as: Root = 'span', className, active, theme, ...props }) => (
57
- <Root
58
- {...props}
59
- tabIndex={props.tabIndex ?? 0}
60
- className={classNames('chip', { active }, theme && `theme-${theme}`, className)}
61
- />
62
- )
63
- );
64
- ChipToken.displayName = 'ChipToken';
@@ -58,7 +58,7 @@ class ChipInputComponent extends FormPlugin<ChipInputComponentProps, Pick<Chips,
58
58
  createOnBlur,
59
59
  dismissible,
60
60
  placeholder,
61
- dismissIcon: renderToStaticMarkup(<Icon name="x-lg" aria-hidden="true" />)
61
+ dismissIcon: renderToStaticMarkup(<Icon name="x-lg" />)
62
62
  });
63
63
  element.addEventListener('change.bs.chips', this.handleValuesChange);
64
64
 
@@ -53,7 +53,7 @@ export const ComboboxOption = polymorphic<ComboboxOptionProps>(
53
53
  data-label={optionText(children)}
54
54
  data-option-hidden={props.hidden || undefined}
55
55
  >
56
- {icon && <Icon name={icon} className="menu-item-icon" aria-hidden="true" />}
56
+ {icon && <Icon name={icon} className="menu-item-icon" />}
57
57
  {description ? (
58
58
  <MenuItemContent>
59
59
  {children}
@@ -62,7 +62,7 @@ export const ComboboxOption = polymorphic<ComboboxOptionProps>(
62
62
  ) : (
63
63
  children
64
64
  )}
65
- {checkedIcon && <Icon name="check-lg" className="menu-item-check" aria-hidden="true" />}
65
+ {checkedIcon && <Icon name="check-lg" className="menu-item-check" />}
66
66
  </Root>
67
67
  )
68
68
  );
@@ -335,11 +335,7 @@ export class Combobox<T extends ElementType | undefined = 'div'> extends Compone
335
335
  >
336
336
  {hasSelection ? label : placeholder}
337
337
  </span>
338
- <Icon
339
- name="chevron-down"
340
- className="combobox-caret"
341
- aria-hidden="true"
342
- />
338
+ <Icon name="chevron-down" className="combobox-caret" />
343
339
  </>
344
340
  }
345
341
  toggleProps={{
@@ -163,7 +163,7 @@ class DatePickerComponent extends FormPlugin<
163
163
 
164
164
  return (
165
165
  <Button as={as} {...buttonProps} {...attributes} ref={this.setRef}>
166
- {leadingIcon && <Icon name={leadingIcon} aria-hidden="true" />}
166
+ {leadingIcon && <Icon name={leadingIcon} />}
167
167
  <span data-bs-datepicker-display="">{children}</span>
168
168
  </Button>
169
169
  );
@@ -14,14 +14,6 @@ export const Form = polymorphic<FormProps>(
14
14
  );
15
15
  Form.displayName = 'Form';
16
16
 
17
- export type FormFieldsetProps = ComponentPropsWithRef<'fieldset'>;
18
-
19
- export const FormFieldset = polymorphic<FormFieldsetProps>(
20
- ({ as: Root = 'fieldset', ...props }) => <Root {...props} />
21
- );
22
-
23
- FormFieldset.displayName = 'FormFieldset';
24
-
25
17
  export type FormFieldProps = ComponentPropsWithRef<'div'> & {
26
18
  card?: boolean;
27
19
  };
@@ -33,14 +33,24 @@ Radio.displayName = 'Radio';
33
33
  export type FormCheckProps = CheckboxProps &
34
34
  Pick<ComponentPropsWithRef<'input'>, 'ref'> & {
35
35
  type?: 'checkbox' | 'radio';
36
+ listGroup?: boolean;
36
37
  };
37
38
 
38
39
  export const FormCheck = polymorphic<FormCheckProps>(
39
- ({ as: RootAs, type = 'checkbox', indeterminate, ...props }) =>
40
+ ({ as: RootAs, type = 'checkbox', indeterminate, listGroup, className, ...props }) =>
40
41
  type === 'checkbox' ? (
41
- <Checkbox as={RootAs} {...props} indeterminate={indeterminate} />
42
+ <Checkbox
43
+ as={RootAs}
44
+ {...props}
45
+ className={classNames(listGroup && 'list-group-item-check', className)}
46
+ indeterminate={indeterminate}
47
+ />
42
48
  ) : (
43
- <Radio as={RootAs} {...props} />
49
+ <Radio
50
+ as={RootAs}
51
+ {...props}
52
+ className={classNames(listGroup && 'list-group-item-check', className)}
53
+ />
44
54
  )
45
55
  );
46
56
  FormCheck.displayName = 'FormCheck';
@@ -64,42 +64,52 @@ export const Row = polymorphic<RowProps>(
64
64
  Row.displayName = 'Row';
65
65
 
66
66
  export interface ColProps extends ComponentPropsWithRef<'div'> {
67
- xs?: BreakpointColSize;
68
- sm?: BreakpointColSize;
69
- md?: BreakpointColSize;
70
- lg?: BreakpointColSize;
71
- xl?: BreakpointColSize;
72
- '2xl'?: BreakpointColSize;
67
+ xs?: ColBreakpoint;
68
+ sm?: ColBreakpoint;
69
+ md?: ColBreakpoint;
70
+ lg?: ColBreakpoint;
71
+ xl?: ColBreakpoint;
72
+ '2xl'?: ColBreakpoint;
73
73
  }
74
74
 
75
+ export type ColOrder = number | 'first' | 'last';
76
+
77
+ export interface ColBreakpointOptions {
78
+ span?: BreakpointColSize;
79
+ offset?: number;
80
+ order?: ColOrder;
81
+ }
82
+
83
+ export type ColBreakpoint = BreakpointColSize | ColBreakpointOptions;
84
+
75
85
  export const Col = polymorphic<ColProps>(
76
86
  ({ as: Root = 'div', xs, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
77
- const sizes: [Breakpoint, BreakpointColSize | undefined][] = [
87
+ const sizes: [Breakpoint | undefined, ColBreakpoint | undefined][] = [
88
+ [undefined, xs],
78
89
  ['sm', sm],
79
90
  ['md', md],
80
91
  ['lg', lg],
81
92
  ['xl', xl],
82
93
  ['2xl', xxl]
83
94
  ];
84
- const sized = sizes.some(([, size]) => size !== undefined);
85
-
86
- return (
87
- <Root
88
- {...props}
89
- className={classNames(
90
- {
91
- col: (xs === undefined && !sized) || xs === true,
92
- [`col-${xs}`]: xs !== undefined && xs !== true
93
- },
94
- sizes.map(
95
- ([breakpoint, size]) =>
96
- size !== undefined &&
97
- (size === true ? `${breakpoint}:col` : `${breakpoint}:col-${size}`)
98
- ),
99
- className
100
- )}
101
- />
95
+ const hasSpan = sizes.some(([, options]) =>
96
+ typeof options === 'object' ? options.span !== undefined : options !== undefined
102
97
  );
98
+ const classes = sizes.map(([breakpoint, options]) => {
99
+ if (options === undefined) return [];
100
+
101
+ const prefix = breakpoint ? `${breakpoint}:` : '';
102
+ const { span, offset, order } =
103
+ typeof options === 'object' ? options : { span: options };
104
+
105
+ return [
106
+ span !== undefined && `${prefix}col${span === true ? '' : `-${span}`}`,
107
+ offset !== undefined && `${prefix}offset-${offset}`,
108
+ order !== undefined && `${prefix}order-${order}`
109
+ ];
110
+ });
111
+
112
+ return <Root {...props} className={classNames(!hasSpan && 'col', classes, className)} />;
103
113
  }
104
114
  );
105
115
  Col.displayName = 'Col';
@@ -0,0 +1,29 @@
1
+ import classNames from 'classnames';
2
+ import { ComponentPropsWithRef, CSSProperties } from 'react';
3
+
4
+ import { polymorphic } from '../Helper/Polymorphic';
5
+
6
+ export type AspectRatio = 'auto' | '1x1' | '4x3' | '16x9' | '21x9';
7
+ export type CustomAspectRatio = `${number} / ${number}`;
8
+
9
+ export type RatioProps = ComponentPropsWithRef<'div'> & {
10
+ aspectRatio?: AspectRatio | CustomAspectRatio;
11
+ };
12
+
13
+ export const Ratio = polymorphic<RatioProps>(
14
+ ({ as: Root = 'div', aspectRatio = '1x1', className, style, ...props }) => {
15
+ const preset = /^(auto|1x1|4x3|16x9|21x9)$/.test(aspectRatio);
16
+ const ratioStyle: CSSProperties & { '--bs-ratio'?: string } = preset
17
+ ? (style ?? {})
18
+ : { ...style, '--bs-ratio': aspectRatio };
19
+
20
+ return (
21
+ <Root
22
+ {...props}
23
+ className={classNames(`ratio-${preset ? aspectRatio : 'auto'}`, className)}
24
+ style={ratioStyle}
25
+ />
26
+ );
27
+ }
28
+ );
29
+ Ratio.displayName = 'Ratio';
@@ -1 +1,2 @@
1
1
  export * from './Grid';
2
+ export * from './Ratio';
package/source/types.d.ts CHANGED
@@ -10,3 +10,7 @@ declare module '*.module.css' {
10
10
  const classes: Readonly<Record<string, string>>;
11
11
  export default classes;
12
12
  }
13
+ declare module '*.module.less' {
14
+ const classes: Readonly<Record<string, string>>;
15
+ export default classes;
16
+ }