Browse Source

Update options display

Add menuselect starting height, as well as remove extra code for option
elements.
pull/1/head
TheoryOfNekomata 1 year ago
parent
commit
ef7c5e6e2e
4 changed files with 4 additions and 84 deletions
  1. +0
    -5
      packages/web-kitchensink-reactnext/src/categories/option/react/components/DropdownSelect/index.tsx
  2. +4
    -2
      packages/web-kitchensink-reactnext/src/categories/option/react/components/MenuSelect/index.tsx
  3. +0
    -76
      packages/web-kitchensink-reactnext/src/categories/option/react/components/RenderOptions/index.tsx
  4. +0
    -1
      packages/web-kitchensink-reactnext/src/categories/option/react/index.ts

+ 0
- 5
packages/web-kitchensink-reactnext/src/categories/option/react/components/DropdownSelect/index.tsx View File

@@ -1,8 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import * as TextControlBase from '@tesseract-design/web-base-textcontrol'; import * as TextControlBase from '@tesseract-design/web-base-textcontrol';
import * as SelectControlBase from '@tesseract-design/web-base-selectcontrol';
import clsx from 'clsx'; import clsx from 'clsx';
import {RenderOptions} from '@/categories/option/react';


export type DropdownSelectDerivedElement = HTMLSelectElement; export type DropdownSelectDerivedElement = HTMLSelectElement;


@@ -43,7 +41,6 @@ export interface DropdownSelectProps extends Omit<React.HTMLProps<DropdownSelect
* Is the label hidden? * Is the label hidden?
*/ */
hiddenLabel?: boolean, hiddenLabel?: boolean,
options?: SelectControlBase.SelectOption[],
} }


/** /**
@@ -64,14 +61,12 @@ export const DropdownSelect = React.forwardRef<DropdownSelectDerivedElement, Dro
variant = 'default' as const, variant = 'default' as const,
hiddenLabel = false, hiddenLabel = false,
className, className,
options = [],
children, children,
...etcProps ...etcProps
}: DropdownSelectProps, }: DropdownSelectProps,
ref, ref,
) => { ) => {
const labelId = React.useId(); const labelId = React.useId();
console.log(children);


return ( return (
<div <div


+ 4
- 2
packages/web-kitchensink-reactnext/src/categories/option/react/components/MenuSelect/index.tsx View File

@@ -37,6 +37,7 @@ export interface MenuSelectProps extends Omit<React.HTMLProps<MenuSelectDerivedE
* Is the label hidden? * Is the label hidden?
*/ */
hiddenLabel?: boolean, hiddenLabel?: boolean,
startingHeight?: number | string,
} }


/** /**
@@ -56,6 +57,7 @@ export const MenuSelect = React.forwardRef<MenuSelectDerivedElement, MenuSelectP
variant = 'default' as const, variant = 'default' as const,
hiddenLabel = false, hiddenLabel = false,
className, className,
startingHeight = '15rem',
...etcProps ...etcProps
}: MenuSelectProps, }: MenuSelectProps,
ref, ref,
@@ -81,10 +83,10 @@ export const MenuSelect = React.forwardRef<MenuSelectDerivedElement, MenuSelectP
data-testid="input" data-testid="input"
size={2} size={2}
style={{ style={{
height: 0,
height: startingHeight,
}} }}
className={clsx( className={clsx(
'bg-negative rounded-inherit w-full peer block',
'bg-negative rounded-inherit w-full peer block overflow-auto',
'focus:outline-0', 'focus:outline-0',
'disabled:opacity-50 disabled:cursor-not-allowed', 'disabled:opacity-50 disabled:cursor-not-allowed',
{ {


+ 0
- 76
packages/web-kitchensink-reactnext/src/categories/option/react/components/RenderOptions/index.tsx View File

@@ -1,76 +0,0 @@
import * as SelectControlBase from '@/base/selectcontrol';
import * as React from 'react';

export interface RenderOptionsProps {
options: SelectControlBase.SelectOption[],
optionComponent?: React.ElementType,
optgroupComponent?: React.ElementType,
level?: number,
}

export const RenderOptions: React.FC<RenderOptionsProps> = ({
options,
optionComponent: Option = 'option',
optgroupComponent: Optgroup = 'optgroup',
level = 0,
}: RenderOptionsProps) => (
options.map((o) => {
if (typeof o === 'number' || typeof o === 'string') {
return (
<Option
key={`${o}:${o}`}
value={o}
/>
);
}

if (typeof o.value !== 'undefined') {
return (
<Option
key={`${o.label}:${o.value.toString()}`}
value={o.value}
label={o.label}
>
{o.label}
</Option>
);
}

if (typeof o.children !== 'undefined') {
if (level === 0) {
return (
<Optgroup
key={o.label}
label={o.label}
>
<RenderOptions
options={o.children}
optionComponent={Option}
optgroupComponent={Optgroup}
level={level + 1}
/>
</Optgroup>
);
}
return (
<React.Fragment
key={o.label}
>
<Option
disabled
>
{o.label}
</Option>
<RenderOptions
options={o.children}
optionComponent={Option}
optgroupComponent={Optgroup}
level={level + 1}
/>
</React.Fragment>
);
}

return null;
})
);

+ 0
- 1
packages/web-kitchensink-reactnext/src/categories/option/react/index.ts View File

@@ -3,7 +3,6 @@ export * from './components/DropdownSelect';
export * from './components/MenuSelect'; export * from './components/MenuSelect';
export * from './components/RadioButton'; export * from './components/RadioButton';
export * from './components/RadioTickBox'; export * from './components/RadioTickBox';
export * from './components/RenderOptions';
export * from './components/TagInput'; export * from './components/TagInput';
export * from './components/ToggleButton'; export * from './components/ToggleButton';
export * from './components/ToggleSwitch'; export * from './components/ToggleSwitch';


Loading…
Cancel
Save