@remember-web/primitive 0.1.10 → 0.1.12
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/src/Control/BaseToggle/ToggleIcon/index.cjs.js +5 -0
- package/dist/src/Control/BaseToggle/ToggleIcon/index.cjs.js.map +1 -1
- package/dist/src/Control/BaseToggle/ToggleIcon/index.d.ts.map +1 -1
- package/dist/src/Control/BaseToggle/ToggleIcon/index.esm.js +6 -1
- package/dist/src/Control/BaseToggle/ToggleIcon/index.esm.js.map +1 -1
- package/dist/src/Control/BaseToggle/index.cjs.js +16 -3
- package/dist/src/Control/BaseToggle/index.cjs.js.map +1 -1
- package/dist/src/Control/BaseToggle/index.d.ts +1 -0
- package/dist/src/Control/BaseToggle/index.d.ts.map +1 -1
- package/dist/src/Control/BaseToggle/index.esm.js +16 -3
- package/dist/src/Control/BaseToggle/index.esm.js.map +1 -1
- package/dist/src/Control/BaseToggle/styles.cjs.js +1 -1
- package/dist/src/Control/BaseToggle/styles.cjs.js.map +1 -1
- package/dist/src/Control/BaseToggle/styles.d.ts.map +1 -1
- package/dist/src/Control/BaseToggle/styles.esm.js +1 -1
- package/dist/src/Control/BaseToggle/styles.esm.js.map +1 -1
- package/dist/src/Control/BaseToggle/types.d.ts +2 -1
- package/dist/src/Control/BaseToggle/types.d.ts.map +1 -1
- package/dist/src/Control/Checkbox.cjs.js.map +1 -1
- package/dist/src/Control/Checkbox.d.ts +14 -6
- package/dist/src/Control/Checkbox.d.ts.map +1 -1
- package/dist/src/Control/Checkbox.esm.js.map +1 -1
- package/dist/src/Control/Radio.cjs.js.map +1 -1
- package/dist/src/Control/Radio.d.ts +1 -1
- package/dist/src/Control/Radio.d.ts.map +1 -1
- package/dist/src/Control/Radio.esm.js.map +1 -1
- package/dist/src/Control/Toggle.cjs.js.map +1 -1
- package/dist/src/Control/Toggle.d.ts +4 -2
- package/dist/src/Control/Toggle.d.ts.map +1 -1
- package/dist/src/Control/Toggle.esm.js.map +1 -1
- package/dist/src/Inputs/Select/DesignedSelect/index.cjs.js +3 -1
- package/dist/src/Inputs/Select/DesignedSelect/index.cjs.js.map +1 -1
- package/dist/src/Inputs/Select/DesignedSelect/index.d.ts.map +1 -1
- package/dist/src/Inputs/Select/DesignedSelect/index.esm.js +3 -1
- package/dist/src/Inputs/Select/DesignedSelect/index.esm.js.map +1 -1
- package/dist/src/Inputs/Select/NativeSelect/index.cjs.js +3 -1
- package/dist/src/Inputs/Select/NativeSelect/index.cjs.js.map +1 -1
- package/dist/src/Inputs/Select/NativeSelect/index.d.ts.map +1 -1
- package/dist/src/Inputs/Select/NativeSelect/index.esm.js +3 -1
- package/dist/src/Inputs/Select/NativeSelect/index.esm.js.map +1 -1
- package/dist/src/Inputs/Select/index.cjs.js +4 -1
- package/dist/src/Inputs/Select/index.cjs.js.map +1 -1
- package/dist/src/Inputs/Select/index.d.ts.map +1 -1
- package/dist/src/Inputs/Select/index.esm.js +4 -1
- package/dist/src/Inputs/Select/index.esm.js.map +1 -1
- package/dist/src/Inputs/Select/types.d.ts +1 -0
- package/dist/src/Inputs/Select/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Control/BaseToggle/ToggleIcon/index.tsx +27 -5
- package/src/Control/BaseToggle/index.tsx +16 -1
- package/src/Control/BaseToggle/styles.ts +9 -0
- package/src/Control/BaseToggle/types.ts +2 -1
- package/src/Control/Checkbox.stories.tsx +28 -1
- package/src/Control/Checkbox.tsx +9 -3
- package/src/Control/Radio.tsx +1 -1
- package/src/Control/Toggle.tsx +1 -1
- package/src/Inputs/Select/DesignedSelect/index.tsx +2 -0
- package/src/Inputs/Select/NativeSelect/index.tsx +11 -1
- package/src/Inputs/Select/Select.stories.tsx +3 -0
- package/src/Inputs/Select/index.tsx +3 -0
- package/src/Inputs/Select/types.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../../../src/Inputs/Select/DesignedSelect/index.tsx"],"sourcesContent":["'use client';\n\nimport type { KeyboardEvent, ReactNode, Ref, RefCallback } from 'react';\nimport {\n Children,\n forwardRef,\n isValidElement,\n useCallback,\n useRef,\n useState,\n useId,\n} from 'react';\nimport { IconArrow2Down, IconArrow2Up } from '@remember-web/icon';\n\nimport useMouseEventAway from '@/hooks/useMouseEventAway';\n\nimport { focusSibling } from '../utils';\nimport { OptionHolder } from '../Option';\nimport { SelectContainer } from '../styles';\nimport type { OptionElementType, SelectValue } from '../types';\nimport { DEFAULT_MAX_HEIGHT_PX, OPTION_ITEM_HEIGHT_PX } from './const';\nimport {\n SelectDownIcon,\n SelectOption,\n SelectOptionWrapper,\n StyledSelect,\n} from './styles';\nimport type { DesignedSelectInternalProps, ExpandedType } from './types';\n\nconst DesignedSelect = <Value extends SelectValue>(\n {\n children,\n value,\n maxHeight = DEFAULT_MAX_HEIGHT_PX,\n placeholder,\n onChange,\n width,\n extendDirection,\n disabled,\n ...props\n }: DesignedSelectInternalProps<Value>,\n ref?: Ref<HTMLDivElement>\n) => {\n const id = useId();\n const [expandedDirection, _setExpandedDirection] =\n useState<ExpandedType>('none');\n const selectContainerRef = useRef<HTMLDivElement | null>(null);\n const selectListRef = useRef<HTMLUListElement | null>(null);\n const clickAwayRef = useMouseEventAway<HTMLDivElement, 'pointerdown'>(\n 'pointerdown',\n () => {\n setExpandedDirection('none');\n }\n );\n\n const setExpandedDirection = useCallback(\n (...args: Parameters<typeof _setExpandedDirection>) => {\n if (disabled) {\n return;\n }\n _setExpandedDirection(...args);\n },\n [disabled]\n );\n\n const options = Children.toArray(children)\n .filter(\n (child): child is OptionElementType<Value> =>\n isValidElement(child) && child.type === OptionHolder\n )\n .map(\n ({\n props: { children: _children, value: _value, disabled: _disabled },\n }) => ({\n label: _children,\n value: _value,\n disabled: _disabled,\n })\n );\n\n const selectedOption = options.find((option) => value === option.value);\n\n const isExpanded = expandedDirection !== 'none';\n\n const onSelectOption = (_value: Value, _label: ReactNode) => {\n onChange?.(_value, _label);\n setExpandedDirection('none');\n selectContainerRef.current?.focus();\n };\n\n // 리스트가 하단으로 나와야하는지 상단으로 나와야하는지 계산하는 함수\n // 현재 Viewport기준으로 Select컴포넌트가 아래로 확장되었을 때 뷰포트 내에 리스트박스가 노출될 수 있다면 하단으로 확장, 아니라면 상단으로 확장\n // direction이 props로 전달되었다면 해당 방향으로 확장\n const expandSelectListAtComputedPosition = () => {\n if (extendDirection) {\n setExpandedDirection(extendDirection);\n return;\n }\n\n const selectContainerRect =\n selectContainerRef.current?.getBoundingClientRect();\n\n if (!selectContainerRect) {\n setExpandedDirection('below');\n return;\n }\n\n // SelectOptionWrapper가 마운트되기 전에 계산해야 하기 때문에 clientHeight를 사용하지 못하고 직접 계산\n const currentSelectHeight = Math.min(\n maxHeight,\n options.length * OPTION_ITEM_HEIGHT_PX\n );\n const bottomGap = document.body.clientHeight - selectContainerRect.bottom;\n\n setExpandedDirection(currentSelectHeight > bottomGap ? 'above' : 'below');\n };\n\n const optionItemRef = useCallback<RefCallback<HTMLLIElement>>(\n (ele) => {\n if (!ele) {\n return;\n }\n\n // 선택한 요소가 없을때는 첫번째 요소에 focus\n if (!value && !ele.previousSibling) {\n setTimeout(() => ele.focus());\n return;\n }\n\n // 선택한 요소가 있다면 해당 요소에 focus\n const optionValue = ele.dataset.optionValue || null;\n if (optionValue === value) {\n setTimeout(() => ele.focus());\n }\n },\n [value]\n );\n\n const keyDownHandler = (e: KeyboardEvent) => {\n const focusedElement = document.activeElement;\n\n if (!focusedElement || !(focusedElement instanceof HTMLElement)) {\n return;\n }\n\n switch (e.key) {\n case 'Tab':\n if (isExpanded) {\n e.preventDefault();\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!isExpanded) {\n expandSelectListAtComputedPosition();\n break;\n }\n focusSibling(focusedElement, 'previous');\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (!isExpanded) {\n expandSelectListAtComputedPosition();\n break;\n }\n focusSibling(focusedElement, 'next');\n break;\n case 'Escape':\n e.preventDefault();\n setExpandedDirection('none');\n selectContainerRef.current?.focus();\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n\n if (e.target === e.currentTarget) {\n if (isExpanded) {\n setExpandedDirection('none');\n return;\n }\n expandSelectListAtComputedPosition();\n }\n\n if (\n focusedElement?.matches('[data-option-value]') &&\n focusedElement instanceof HTMLLIElement &&\n focusedElement.dataset.optionValue\n ) {\n onSelectOption(\n focusedElement.dataset.optionValue as Value,\n focusedElement.innerText\n );\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <SelectContainer\n ref={(el) => {\n if (!el) {\n return;\n }\n selectContainerRef.current = el;\n clickAwayRef.current = el;\n }}\n $width={width}\n tabIndex={disabled ? undefined : 0}\n aria-expanded={isExpanded}\n aria-haspopup=\"listbox\"\n aria-disabled={disabled}\n onKeyDown={keyDownHandler}\n {...props}\n >\n <StyledSelect\n ref={ref}\n expandedDirection={expandedDirection}\n isPlaceholder={!selectedOption && !!placeholder}\n onPointerDown={(e) => {\n if (isExpanded) {\n setExpandedDirection('none');\n return;\n }\n\n e.stopPropagation();\n\n expandSelectListAtComputedPosition();\n }}\n >\n {selectedOption?.label || placeholder || 'ㅤ'}\n </StyledSelect>\n <SelectDownIcon>\n {isExpanded ? (\n <IconArrow2Up size=\"small\" />\n ) : (\n <IconArrow2Down size=\"small\" />\n )}\n </SelectDownIcon>\n {isExpanded && (\n <SelectOptionWrapper\n role=\"listbox\"\n aria-activedescendant={\n value != null ? `${id}-select-option-${value}` : undefined\n }\n ref={selectListRef}\n expandedDirection={expandedDirection}\n maxHeight={maxHeight}\n >\n {options.map(({ value: optionValue, label, disabled: _disabled }) => (\n <SelectOption\n id={`${id}-select-option-${optionValue}`}\n role=\"option\"\n key={optionValue}\n tabIndex={_disabled ? undefined : 0}\n aria-selected={optionValue === value}\n aria-disabled={_disabled}\n ref={optionItemRef}\n isSelected={optionValue === value}\n data-option-value={optionValue}\n // onMouseEnter를 사용하게 되면 키보드로 스크롤 할 때도 focus가 이동하게 되기 때문에 onMouseMove를 사용\n onMouseMove={(e) => {\n if (e.currentTarget === document.activeElement) {\n return;\n }\n e.currentTarget.focus({\n preventScroll: true,\n });\n }}\n onFocus={() => {\n selectListRef.current?.setAttribute(\n 'aria-activedescendant',\n `${id}-select-option-${optionValue}`\n );\n }}\n onClick={() => {\n if (_disabled) {\n return;\n }\n\n onSelectOption(optionValue, label);\n }}\n >\n {label}\n </SelectOption>\n ))}\n </SelectOptionWrapper>\n )}\n </SelectContainer>\n );\n};\n\nexport default forwardRef(DesignedSelect);\n"],"names":["maxHeight","props","expandedDirection","_setExpandedDirection","label","value","disabled","setTimeout","expandSelectListAtComputedPosition","focusSibling","ref","$width","tabIndex","onKeyDown","isPlaceholder","onPointerDown","children","size","role","onMouseMove","e","preventScroll","onSelectOption"],"mappings":";;;;;;;;;;;;;;AAAa;AAAA;AAAA;AA6Bb;
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../../src/Inputs/Select/DesignedSelect/index.tsx"],"sourcesContent":["'use client';\n\nimport type { KeyboardEvent, ReactNode, Ref, RefCallback } from 'react';\nimport {\n Children,\n forwardRef,\n isValidElement,\n useCallback,\n useRef,\n useState,\n useId,\n} from 'react';\nimport { IconArrow2Down, IconArrow2Up } from '@remember-web/icon';\n\nimport useMouseEventAway from '@/hooks/useMouseEventAway';\n\nimport { focusSibling } from '../utils';\nimport { OptionHolder } from '../Option';\nimport { SelectContainer } from '../styles';\nimport type { OptionElementType, SelectValue } from '../types';\nimport { DEFAULT_MAX_HEIGHT_PX, OPTION_ITEM_HEIGHT_PX } from './const';\nimport {\n SelectDownIcon,\n SelectOption,\n SelectOptionWrapper,\n StyledSelect,\n} from './styles';\nimport type { DesignedSelectInternalProps, ExpandedType } from './types';\n\nconst DesignedSelect = <Value extends SelectValue>(\n {\n children,\n value,\n maxHeight = DEFAULT_MAX_HEIGHT_PX,\n placeholder,\n onChange,\n width,\n extendDirection,\n disabled,\n onClick,\n ...props\n }: DesignedSelectInternalProps<Value>,\n ref?: Ref<HTMLDivElement>\n) => {\n const id = useId();\n const [expandedDirection, _setExpandedDirection] =\n useState<ExpandedType>('none');\n const selectContainerRef = useRef<HTMLDivElement | null>(null);\n const selectListRef = useRef<HTMLUListElement | null>(null);\n const clickAwayRef = useMouseEventAway<HTMLDivElement, 'pointerdown'>(\n 'pointerdown',\n () => {\n setExpandedDirection('none');\n }\n );\n\n const setExpandedDirection = useCallback(\n (...args: Parameters<typeof _setExpandedDirection>) => {\n if (disabled) {\n return;\n }\n _setExpandedDirection(...args);\n },\n [disabled]\n );\n\n const options = Children.toArray(children)\n .filter(\n (child): child is OptionElementType<Value> =>\n isValidElement(child) && child.type === OptionHolder\n )\n .map(\n ({\n props: { children: _children, value: _value, disabled: _disabled },\n }) => ({\n label: _children,\n value: _value,\n disabled: _disabled,\n })\n );\n\n const selectedOption = options.find((option) => value === option.value);\n\n const isExpanded = expandedDirection !== 'none';\n\n const onSelectOption = (_value: Value, _label: ReactNode) => {\n onChange?.(_value, _label);\n setExpandedDirection('none');\n selectContainerRef.current?.focus();\n };\n\n // 리스트가 하단으로 나와야하는지 상단으로 나와야하는지 계산하는 함수\n // 현재 Viewport기준으로 Select컴포넌트가 아래로 확장되었을 때 뷰포트 내에 리스트박스가 노출될 수 있다면 하단으로 확장, 아니라면 상단으로 확장\n // direction이 props로 전달되었다면 해당 방향으로 확장\n const expandSelectListAtComputedPosition = () => {\n if (extendDirection) {\n setExpandedDirection(extendDirection);\n return;\n }\n\n const selectContainerRect =\n selectContainerRef.current?.getBoundingClientRect();\n\n if (!selectContainerRect) {\n setExpandedDirection('below');\n return;\n }\n\n // SelectOptionWrapper가 마운트되기 전에 계산해야 하기 때문에 clientHeight를 사용하지 못하고 직접 계산\n const currentSelectHeight = Math.min(\n maxHeight,\n options.length * OPTION_ITEM_HEIGHT_PX\n );\n const bottomGap = document.body.clientHeight - selectContainerRect.bottom;\n\n setExpandedDirection(currentSelectHeight > bottomGap ? 'above' : 'below');\n };\n\n const optionItemRef = useCallback<RefCallback<HTMLLIElement>>(\n (ele) => {\n if (!ele) {\n return;\n }\n\n // 선택한 요소가 없을때는 첫번째 요소에 focus\n if (!value && !ele.previousSibling) {\n setTimeout(() => ele.focus());\n return;\n }\n\n // 선택한 요소가 있다면 해당 요소에 focus\n const optionValue = ele.dataset.optionValue || null;\n if (optionValue === value) {\n setTimeout(() => ele.focus());\n }\n },\n [value]\n );\n\n const keyDownHandler = (e: KeyboardEvent) => {\n const focusedElement = document.activeElement;\n\n if (!focusedElement || !(focusedElement instanceof HTMLElement)) {\n return;\n }\n\n switch (e.key) {\n case 'Tab':\n if (isExpanded) {\n e.preventDefault();\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!isExpanded) {\n expandSelectListAtComputedPosition();\n break;\n }\n focusSibling(focusedElement, 'previous');\n break;\n case 'ArrowDown':\n e.preventDefault();\n if (!isExpanded) {\n expandSelectListAtComputedPosition();\n break;\n }\n focusSibling(focusedElement, 'next');\n break;\n case 'Escape':\n e.preventDefault();\n setExpandedDirection('none');\n selectContainerRef.current?.focus();\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n\n if (e.target === e.currentTarget) {\n if (isExpanded) {\n setExpandedDirection('none');\n return;\n }\n expandSelectListAtComputedPosition();\n }\n\n if (\n focusedElement?.matches('[data-option-value]') &&\n focusedElement instanceof HTMLLIElement &&\n focusedElement.dataset.optionValue\n ) {\n onSelectOption(\n focusedElement.dataset.optionValue as Value,\n focusedElement.innerText\n );\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <SelectContainer\n ref={(el) => {\n if (!el) {\n return;\n }\n selectContainerRef.current = el;\n clickAwayRef.current = el;\n }}\n $width={width}\n tabIndex={disabled ? undefined : 0}\n aria-expanded={isExpanded}\n aria-haspopup=\"listbox\"\n aria-disabled={disabled}\n onKeyDown={keyDownHandler}\n {...props}\n >\n <StyledSelect\n ref={ref}\n onClick={onClick}\n expandedDirection={expandedDirection}\n isPlaceholder={!selectedOption && !!placeholder}\n onPointerDown={(e) => {\n if (isExpanded) {\n setExpandedDirection('none');\n return;\n }\n\n e.stopPropagation();\n\n expandSelectListAtComputedPosition();\n }}\n >\n {selectedOption?.label || placeholder || 'ㅤ'}\n </StyledSelect>\n <SelectDownIcon>\n {isExpanded ? (\n <IconArrow2Up size=\"small\" />\n ) : (\n <IconArrow2Down size=\"small\" />\n )}\n </SelectDownIcon>\n {isExpanded && (\n <SelectOptionWrapper\n role=\"listbox\"\n aria-activedescendant={\n value != null ? `${id}-select-option-${value}` : undefined\n }\n ref={selectListRef}\n expandedDirection={expandedDirection}\n maxHeight={maxHeight}\n >\n {options.map(({ value: optionValue, label, disabled: _disabled }) => (\n <SelectOption\n id={`${id}-select-option-${optionValue}`}\n role=\"option\"\n key={optionValue}\n tabIndex={_disabled ? undefined : 0}\n aria-selected={optionValue === value}\n aria-disabled={_disabled}\n ref={optionItemRef}\n isSelected={optionValue === value}\n data-option-value={optionValue}\n // onMouseEnter를 사용하게 되면 키보드로 스크롤 할 때도 focus가 이동하게 되기 때문에 onMouseMove를 사용\n onMouseMove={(e) => {\n if (e.currentTarget === document.activeElement) {\n return;\n }\n e.currentTarget.focus({\n preventScroll: true,\n });\n }}\n onFocus={() => {\n selectListRef.current?.setAttribute(\n 'aria-activedescendant',\n `${id}-select-option-${optionValue}`\n );\n }}\n onClick={() => {\n if (_disabled) {\n return;\n }\n\n onSelectOption(optionValue, label);\n }}\n >\n {label}\n </SelectOption>\n ))}\n </SelectOptionWrapper>\n )}\n </SelectContainer>\n );\n};\n\nexport default forwardRef(DesignedSelect);\n"],"names":["maxHeight","props","expandedDirection","_setExpandedDirection","label","value","disabled","setTimeout","expandSelectListAtComputedPosition","focusSibling","ref","$width","tabIndex","onKeyDown","onClick","isPlaceholder","onPointerDown","children","size","role","onMouseMove","e","preventScroll","onSelectOption"],"mappings":";;;;;;;;;;;;;;AAAa;AAAA;AAAA;AA6Bb;AAcK;;;AAVDA;;;;;;;AAOGC;AAIL;AACA;;AAAOC;AAAmBC;AAE1B;AACA;AACA;;AAIE;AAGF;AAEI;AACE;AACF;AACAA;AACF;AAIF;;AAG0D;AAGtD;;;;;AAGEC;AACAC;AACAC;;AACD;AAGL;AAA2C;;AAE3C;;AAE6D;;;AAG3D;;;AAGF;AACA;AACA;AACA;AAAiD;AAC/C;;AAEE;AACF;AAEA;;;AAKE;AACF;;AAEA;AACA;;;;AASF;;AAGM;AACF;;AAEA;AACA;AACEC;AAAW;;AACX;AACF;;AAEA;;;AAGEA;AAAW;;AACb;AACF;AAIF;AAA6C;AAC3C;;AAGE;AACF;;AAGE;AACE;;AAEA;AACA;AACF;;;AAGIC;AACA;AACF;AACAC;AACA;AACF;;;AAGID;AACA;AACF;AACAC;AACA;AACF;;;AAGE;AACA;AACF;AACA;;AAGE;AACE;;AAEE;AACF;AACAD;AACF;;;AAWA;AACA;AAGJ;;AAGF;AAEIE;;AAEI;AACF;;;;AAIFC;AACAC;AACA;AACA;AACA;AACAC;AAA0B;;AAIxBH;AACAI;AACAZ;AACAa;AACAC;AACE;;AAEE;AACF;;AAIAR;;;AAG0C;AAE/BS;AAEGC;AAAY;AAEVA;;AACjB;AAICC;AACA;AAGAT;AACAR;AACAF;AAAqBiB;AAER;;;;;AAGTE;AAEAP;;AAEA;AACAF;;;AAGA;AAAA;AACAU;AACE;AACE;AACF;AACAC;AACEC;AACF;;;AAEa;;;;AAOb;AACE;AACF;AAEAC;;AACAN;AAEI;;AAER;AAEL;AAGP;AAEA;;"}
|
|
@@ -14,7 +14,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
14
14
|
var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
|
|
15
15
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
|
|
16
16
|
|
|
17
|
-
var _excluded = ["children", "className", "width", "placeholder", "value", "disabled"];
|
|
17
|
+
var _excluded = ["children", "className", "width", "placeholder", "value", "disabled", "onClick"];
|
|
18
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
19
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
20
|
var NativeSelect = function NativeSelect(_ref, ref) {
|
|
@@ -24,6 +24,7 @@ var NativeSelect = function NativeSelect(_ref, ref) {
|
|
|
24
24
|
placeholder = _ref.placeholder,
|
|
25
25
|
value = _ref.value,
|
|
26
26
|
disabled = _ref.disabled,
|
|
27
|
+
onClick = _ref.onClick,
|
|
27
28
|
props = _objectWithoutProperties__default.default(_ref, _excluded);
|
|
28
29
|
var showPlaceholder = !value && !!placeholder;
|
|
29
30
|
return /*#__PURE__*/jsxRuntime.jsxs(styles.SelectContainer, {
|
|
@@ -35,6 +36,7 @@ var NativeSelect = function NativeSelect(_ref, ref) {
|
|
|
35
36
|
ref: ref,
|
|
36
37
|
isPlaceholder: showPlaceholder,
|
|
37
38
|
disabled: disabled,
|
|
39
|
+
onClick: onClick,
|
|
38
40
|
children: [!value && /*#__PURE__*/jsxRuntime.jsx("option", {
|
|
39
41
|
value: "",
|
|
40
42
|
selected: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../../../../src/Inputs/Select/NativeSelect/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ForwardRefRenderFunction } from 'react';\nimport { forwardRef } from 'react';\nimport { IconArrow2Down } from '@remember-web/icon';\n\nimport { SelectDownIcon, StyledSelect } from './styles';\nimport type { NativeSelectInternalProps } from './types';\nimport { SelectContainer } from '../styles';\n\nconst NativeSelect: ForwardRefRenderFunction<\n HTMLSelectElement,\n NativeSelectInternalProps\n> = (\n {
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../../src/Inputs/Select/NativeSelect/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ForwardRefRenderFunction } from 'react';\nimport { forwardRef } from 'react';\nimport { IconArrow2Down } from '@remember-web/icon';\n\nimport { SelectDownIcon, StyledSelect } from './styles';\nimport type { NativeSelectInternalProps } from './types';\nimport { SelectContainer } from '../styles';\n\nconst NativeSelect: ForwardRefRenderFunction<\n HTMLSelectElement,\n NativeSelectInternalProps\n> = (\n {\n children,\n className,\n width,\n placeholder,\n value,\n disabled,\n onClick,\n ...props\n },\n ref\n) => {\n const showPlaceholder = !value && !!placeholder;\n\n return (\n <SelectContainer aria-disabled={disabled} className={className}>\n <StyledSelect\n {...props}\n value={value}\n $width={width}\n ref={ref}\n isPlaceholder={showPlaceholder}\n disabled={disabled}\n onClick={onClick}\n >\n {!value && (\n <option value=\"\" selected>\n {placeholder || 'ㅤ'}\n </option>\n )}\n {children}\n </StyledSelect>\n <SelectDownIcon>\n <IconArrow2Down size=\"small\" />\n </SelectDownIcon>\n </SelectContainer>\n );\n};\n\nexport default forwardRef(NativeSelect);\n"],"names":["props","className","value","$width","ref","isPlaceholder","disabled","onClick","children","size"],"mappings":";;;;;;;;;;;;;;;;AAAa;AAAA;AAAA;AAUb;AAeK;;;;;;;AAHEA;AAIL;;AAGmB;AAAyBC;;AAGtCC;AACAC;AACAC;AACAC;AACAC;AACAC;AAAiBC;AAGPN;;;;AAID;;AAGOO;;AAAe;AAChB;AAGvB;AAEA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Inputs/Select/NativeSelect/index.tsx"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Inputs/Select/NativeSelect/index.tsx"],"names":[],"mappings":";;;;;;AAqDA,wBAAwC"}
|
|
@@ -7,7 +7,7 @@ import { StyledSelect, SelectDownIcon } from './styles.esm.js';
|
|
|
7
7
|
import { SelectContainer } from '../styles.esm.js';
|
|
8
8
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
|
-
var _excluded = ["children", "className", "width", "placeholder", "value", "disabled"];
|
|
10
|
+
var _excluded = ["children", "className", "width", "placeholder", "value", "disabled", "onClick"];
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
13
|
var NativeSelect = function NativeSelect(_ref, ref) {
|
|
@@ -17,6 +17,7 @@ var NativeSelect = function NativeSelect(_ref, ref) {
|
|
|
17
17
|
placeholder = _ref.placeholder,
|
|
18
18
|
value = _ref.value,
|
|
19
19
|
disabled = _ref.disabled,
|
|
20
|
+
onClick = _ref.onClick,
|
|
20
21
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
22
|
var showPlaceholder = !value && !!placeholder;
|
|
22
23
|
return /*#__PURE__*/jsxs(SelectContainer, {
|
|
@@ -28,6 +29,7 @@ var NativeSelect = function NativeSelect(_ref, ref) {
|
|
|
28
29
|
ref: ref,
|
|
29
30
|
isPlaceholder: showPlaceholder,
|
|
30
31
|
disabled: disabled,
|
|
32
|
+
onClick: onClick,
|
|
31
33
|
children: [!value && /*#__PURE__*/jsx("option", {
|
|
32
34
|
value: "",
|
|
33
35
|
selected: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../../../src/Inputs/Select/NativeSelect/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ForwardRefRenderFunction } from 'react';\nimport { forwardRef } from 'react';\nimport { IconArrow2Down } from '@remember-web/icon';\n\nimport { SelectDownIcon, StyledSelect } from './styles';\nimport type { NativeSelectInternalProps } from './types';\nimport { SelectContainer } from '../styles';\n\nconst NativeSelect: ForwardRefRenderFunction<\n HTMLSelectElement,\n NativeSelectInternalProps\n> = (\n {
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../../src/Inputs/Select/NativeSelect/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ForwardRefRenderFunction } from 'react';\nimport { forwardRef } from 'react';\nimport { IconArrow2Down } from '@remember-web/icon';\n\nimport { SelectDownIcon, StyledSelect } from './styles';\nimport type { NativeSelectInternalProps } from './types';\nimport { SelectContainer } from '../styles';\n\nconst NativeSelect: ForwardRefRenderFunction<\n HTMLSelectElement,\n NativeSelectInternalProps\n> = (\n {\n children,\n className,\n width,\n placeholder,\n value,\n disabled,\n onClick,\n ...props\n },\n ref\n) => {\n const showPlaceholder = !value && !!placeholder;\n\n return (\n <SelectContainer aria-disabled={disabled} className={className}>\n <StyledSelect\n {...props}\n value={value}\n $width={width}\n ref={ref}\n isPlaceholder={showPlaceholder}\n disabled={disabled}\n onClick={onClick}\n >\n {!value && (\n <option value=\"\" selected>\n {placeholder || 'ㅤ'}\n </option>\n )}\n {children}\n </StyledSelect>\n <SelectDownIcon>\n <IconArrow2Down size=\"small\" />\n </SelectDownIcon>\n </SelectContainer>\n );\n};\n\nexport default forwardRef(NativeSelect);\n"],"names":["props","className","value","$width","ref","isPlaceholder","disabled","onClick","children","size"],"mappings":";;;;;;;;;AAAa;AAAA;AAAA;AAUb;AAeK;;;;;;;AAHEA;AAIL;;AAGmB;AAAyBC;;AAGtCC;AACAC;AACAC;AACAC;AACAC;AACAC;AAAiBC;AAGPN;;;;AAID;;AAGOO;;AAAe;AAChB;AAGvB;AAEA;;"}
|
|
@@ -25,7 +25,8 @@ function Select(props, ref) {
|
|
|
25
25
|
_onChange = props.onChange,
|
|
26
26
|
placeholder = props.placeholder,
|
|
27
27
|
width = props.width,
|
|
28
|
-
required = props.required
|
|
28
|
+
required = props.required,
|
|
29
|
+
onClick = props.onClick;
|
|
29
30
|
if (props["native"]) {
|
|
30
31
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
31
32
|
children: [label && /*#__PURE__*/jsxRuntime.jsxs(styles.SelectLabel, {
|
|
@@ -35,6 +36,7 @@ function Select(props, ref) {
|
|
|
35
36
|
}), /*#__PURE__*/jsxRuntime.jsx(index$2, {
|
|
36
37
|
disabled: disabled,
|
|
37
38
|
className: className,
|
|
39
|
+
onClick: onClick,
|
|
38
40
|
onChange: function onChange(e) {
|
|
39
41
|
_onChange === null || _onChange === void 0 || _onChange(e.target.value, e.target.innerText);
|
|
40
42
|
},
|
|
@@ -58,6 +60,7 @@ function Select(props, ref) {
|
|
|
58
60
|
className: className,
|
|
59
61
|
value: value,
|
|
60
62
|
disabled: disabled,
|
|
63
|
+
onClick: onClick,
|
|
61
64
|
onChange: function onChange(_value, _label) {
|
|
62
65
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(_value, _label);
|
|
63
66
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../../../src/Inputs/Select/index.tsx"],"sourcesContent":["'use client';\n\nimport type { Ref, RefAttributes } from 'react';\nimport { Children, forwardRef } from 'react';\n\nimport DesignedSelect from './DesignedSelect';\nimport NativeSelect from './NativeSelect';\nimport { NativeOption } from './NativeSelect/Option';\nimport { OptionHolder } from './Option';\nimport { SelectLabel } from './styles';\nimport type {\n DesignedSelectProps,\n NativeSelectProps,\n SelectProps,\n SelectValue,\n} from './types';\n\nfunction Select<Value extends SelectValue>(\n props: SelectProps<Value>,\n ref: Ref<HTMLDivElement | HTMLSelectElement>\n) {\n const {\n children,\n label,\n value,\n className,\n disabled,\n onChange,\n placeholder,\n width,\n required,\n } = props;\n\n if (props.native) {\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <NativeSelect\n disabled={disabled}\n className={className}\n onChange={(e) => {\n onChange?.(e.target.value as Value, e.target.innerText);\n }}\n value={value}\n required={required}\n placeholder={placeholder}\n width={width}\n ref={ref as Ref<HTMLSelectElement>}\n >\n {Children.map(children, (child) => (\n <NativeOption {...child.props} />\n ))}\n </NativeSelect>\n </div>\n );\n }\n\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <DesignedSelect\n className={className}\n value={value}\n disabled={disabled}\n onChange={(_value, _label) => onChange?.(_value as Value, _label)}\n placeholder={placeholder}\n width={width}\n maxHeight={props.maxHeight}\n extendDirection={props.extendDirection}\n ref={ref as Ref<HTMLDivElement>}\n >\n {children}\n </DesignedSelect>\n </div>\n );\n}\n\nexport default Object.assign(\n forwardRef(Select) as <Value extends SelectValue>(\n props:\n | (DesignedSelectProps<Value> & RefAttributes<HTMLDivElement>)\n | (NativeSelectProps<Value> & RefAttributes<HTMLSelectElement>)\n ) => JSX.Element,\n { Option: OptionHolder }\n);\n"],"names":["children","disabled","className","onChange","value","required","placeholder","width","ref","Option"],"mappings":";;;;;;;;;;;;;;;;AAAa;AAAA;AAiBb;AAIE
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../src/Inputs/Select/index.tsx"],"sourcesContent":["'use client';\n\nimport type { Ref, RefAttributes } from 'react';\nimport { Children, forwardRef } from 'react';\n\nimport DesignedSelect from './DesignedSelect';\nimport NativeSelect from './NativeSelect';\nimport { NativeOption } from './NativeSelect/Option';\nimport { OptionHolder } from './Option';\nimport { SelectLabel } from './styles';\nimport type {\n DesignedSelectProps,\n NativeSelectProps,\n SelectProps,\n SelectValue,\n} from './types';\n\nfunction Select<Value extends SelectValue>(\n props: SelectProps<Value>,\n ref: Ref<HTMLDivElement | HTMLSelectElement>\n) {\n const {\n children,\n label,\n value,\n className,\n disabled,\n onChange,\n placeholder,\n width,\n required,\n onClick,\n } = props;\n\n if (props.native) {\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <NativeSelect\n disabled={disabled}\n className={className}\n onClick={onClick}\n onChange={(e) => {\n onChange?.(e.target.value as Value, e.target.innerText);\n }}\n value={value}\n required={required}\n placeholder={placeholder}\n width={width}\n ref={ref as Ref<HTMLSelectElement>}\n >\n {Children.map(children, (child) => (\n <NativeOption {...child.props} />\n ))}\n </NativeSelect>\n </div>\n );\n }\n\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <DesignedSelect\n className={className}\n value={value}\n disabled={disabled}\n onClick={onClick}\n onChange={(_value, _label) => onChange?.(_value as Value, _label)}\n placeholder={placeholder}\n width={width}\n maxHeight={props.maxHeight}\n extendDirection={props.extendDirection}\n ref={ref as Ref<HTMLDivElement>}\n >\n {children}\n </DesignedSelect>\n </div>\n );\n}\n\nexport default Object.assign(\n forwardRef(Select) as <Value extends SelectValue>(\n props:\n | (DesignedSelectProps<Value> & RefAttributes<HTMLDivElement>)\n | (NativeSelectProps<Value> & RefAttributes<HTMLSelectElement>)\n ) => JSX.Element,\n { Option: OptionHolder }\n);\n"],"names":["children","disabled","className","onClick","onChange","value","required","placeholder","width","ref","Option"],"mappings":";;;;;;;;;;;;;;;;AAAa;AAAA;AAiBb;AAIE;;;;;;;;;;;AAcE;AACEA;AAEgBA;AAEGA;AAAO;AAAO;AAI7BC;AACAC;AACAC;AACAC;AACEA;;AAEFC;AACAC;AACAC;AACAC;AACAC;;;;AAIE;AACW;AAGrB;AAEA;AACET;AAEgBA;AAEGA;AAAO;AAAO;AAI7BE;AACAG;AACAJ;AACAE;AACAC;;;AACAG;AACAC;;;AAGAC;AAAgCT;AAEvB;AACM;AAGvB;AAEA;AAMIU;AAAqB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Inputs/Select/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAO,aAAa,EAAE,MAAM,OAAO,CAAC;AAQhD,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EAEjB,WAAW,EACZ,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Inputs/Select/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAO,aAAa,EAAE,MAAM,OAAO,CAAC;AAQhD,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EAEjB,WAAW,EACZ,MAAM,SAAS,CAAC;4DA8ET,CAAC,oBAAoB,KAAK,CAAC,GAAG,cAAc,cAAc,CAAC,CAAC,GAC5D,CAAC,kBAAkB,KAAK,CAAC,GAAG,cAAc,iBAAiB,CAAC,CAAC,KAC9D,WAAW;;;;;;AALlB,wBAOE"}
|
|
@@ -19,7 +19,8 @@ function Select(props, ref) {
|
|
|
19
19
|
_onChange = props.onChange,
|
|
20
20
|
placeholder = props.placeholder,
|
|
21
21
|
width = props.width,
|
|
22
|
-
required = props.required
|
|
22
|
+
required = props.required,
|
|
23
|
+
onClick = props.onClick;
|
|
23
24
|
if (props["native"]) {
|
|
24
25
|
return /*#__PURE__*/jsxs("div", {
|
|
25
26
|
children: [label && /*#__PURE__*/jsxs(SelectLabel, {
|
|
@@ -29,6 +30,7 @@ function Select(props, ref) {
|
|
|
29
30
|
}), /*#__PURE__*/jsx(NativeSelect, {
|
|
30
31
|
disabled: disabled,
|
|
31
32
|
className: className,
|
|
33
|
+
onClick: onClick,
|
|
32
34
|
onChange: function onChange(e) {
|
|
33
35
|
_onChange === null || _onChange === void 0 || _onChange(e.target.value, e.target.innerText);
|
|
34
36
|
},
|
|
@@ -52,6 +54,7 @@ function Select(props, ref) {
|
|
|
52
54
|
className: className,
|
|
53
55
|
value: value,
|
|
54
56
|
disabled: disabled,
|
|
57
|
+
onClick: onClick,
|
|
55
58
|
onChange: function onChange(_value, _label) {
|
|
56
59
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(_value, _label);
|
|
57
60
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../../src/Inputs/Select/index.tsx"],"sourcesContent":["'use client';\n\nimport type { Ref, RefAttributes } from 'react';\nimport { Children, forwardRef } from 'react';\n\nimport DesignedSelect from './DesignedSelect';\nimport NativeSelect from './NativeSelect';\nimport { NativeOption } from './NativeSelect/Option';\nimport { OptionHolder } from './Option';\nimport { SelectLabel } from './styles';\nimport type {\n DesignedSelectProps,\n NativeSelectProps,\n SelectProps,\n SelectValue,\n} from './types';\n\nfunction Select<Value extends SelectValue>(\n props: SelectProps<Value>,\n ref: Ref<HTMLDivElement | HTMLSelectElement>\n) {\n const {\n children,\n label,\n value,\n className,\n disabled,\n onChange,\n placeholder,\n width,\n required,\n } = props;\n\n if (props.native) {\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <NativeSelect\n disabled={disabled}\n className={className}\n onChange={(e) => {\n onChange?.(e.target.value as Value, e.target.innerText);\n }}\n value={value}\n required={required}\n placeholder={placeholder}\n width={width}\n ref={ref as Ref<HTMLSelectElement>}\n >\n {Children.map(children, (child) => (\n <NativeOption {...child.props} />\n ))}\n </NativeSelect>\n </div>\n );\n }\n\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <DesignedSelect\n className={className}\n value={value}\n disabled={disabled}\n onChange={(_value, _label) => onChange?.(_value as Value, _label)}\n placeholder={placeholder}\n width={width}\n maxHeight={props.maxHeight}\n extendDirection={props.extendDirection}\n ref={ref as Ref<HTMLDivElement>}\n >\n {children}\n </DesignedSelect>\n </div>\n );\n}\n\nexport default Object.assign(\n forwardRef(Select) as <Value extends SelectValue>(\n props:\n | (DesignedSelectProps<Value> & RefAttributes<HTMLDivElement>)\n | (NativeSelectProps<Value> & RefAttributes<HTMLSelectElement>)\n ) => JSX.Element,\n { Option: OptionHolder }\n);\n"],"names":["children","disabled","className","onChange","value","required","placeholder","width","ref","Option"],"mappings":";;;;;;;;;;AAAa;AAAA;AAiBb;AAIE
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../src/Inputs/Select/index.tsx"],"sourcesContent":["'use client';\n\nimport type { Ref, RefAttributes } from 'react';\nimport { Children, forwardRef } from 'react';\n\nimport DesignedSelect from './DesignedSelect';\nimport NativeSelect from './NativeSelect';\nimport { NativeOption } from './NativeSelect/Option';\nimport { OptionHolder } from './Option';\nimport { SelectLabel } from './styles';\nimport type {\n DesignedSelectProps,\n NativeSelectProps,\n SelectProps,\n SelectValue,\n} from './types';\n\nfunction Select<Value extends SelectValue>(\n props: SelectProps<Value>,\n ref: Ref<HTMLDivElement | HTMLSelectElement>\n) {\n const {\n children,\n label,\n value,\n className,\n disabled,\n onChange,\n placeholder,\n width,\n required,\n onClick,\n } = props;\n\n if (props.native) {\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <NativeSelect\n disabled={disabled}\n className={className}\n onClick={onClick}\n onChange={(e) => {\n onChange?.(e.target.value as Value, e.target.innerText);\n }}\n value={value}\n required={required}\n placeholder={placeholder}\n width={width}\n ref={ref as Ref<HTMLSelectElement>}\n >\n {Children.map(children, (child) => (\n <NativeOption {...child.props} />\n ))}\n </NativeSelect>\n </div>\n );\n }\n\n return (\n <div>\n {label && (\n <SelectLabel>\n {label}\n {required && <mark>*</mark>}\n </SelectLabel>\n )}\n <DesignedSelect\n className={className}\n value={value}\n disabled={disabled}\n onClick={onClick}\n onChange={(_value, _label) => onChange?.(_value as Value, _label)}\n placeholder={placeholder}\n width={width}\n maxHeight={props.maxHeight}\n extendDirection={props.extendDirection}\n ref={ref as Ref<HTMLDivElement>}\n >\n {children}\n </DesignedSelect>\n </div>\n );\n}\n\nexport default Object.assign(\n forwardRef(Select) as <Value extends SelectValue>(\n props:\n | (DesignedSelectProps<Value> & RefAttributes<HTMLDivElement>)\n | (NativeSelectProps<Value> & RefAttributes<HTMLSelectElement>)\n ) => JSX.Element,\n { Option: OptionHolder }\n);\n"],"names":["children","disabled","className","onClick","onChange","value","required","placeholder","width","ref","Option"],"mappings":";;;;;;;;;;AAAa;AAAA;AAiBb;AAIE;;;;;;;;;;;AAcE;AACEA;AAEgBA;AAEGA;AAAO;AAAO;AAI7BC;AACAC;AACAC;AACAC;AACEA;;AAEFC;AACAC;AACAC;AACAC;AACAC;;;;AAIE;AACW;AAGrB;AAEA;AACET;AAEgBA;AAEGA;AAAO;AAAO;AAI7BE;AACAG;AACAJ;AACAE;AACAC;;;AACAG;AACAC;;;AAGAC;AAAgCT;AAEvB;AACM;AAGvB;AAEA;AAMIU;AAAqB;;"}
|
|
@@ -15,6 +15,7 @@ export type SelectBaseProps<Value extends SelectValue> = {
|
|
|
15
15
|
placeholder?: string;
|
|
16
16
|
width?: number | string;
|
|
17
17
|
onChange?: (targetValue: Value, targetLabel: ReactNode) => Promise<void> | void;
|
|
18
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
18
19
|
};
|
|
19
20
|
export type DesignedSelectProps<Value extends SelectValue> = SelectBaseProps<Value> & {
|
|
20
21
|
native?: false | never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Inputs/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,WAAW,IAAI,YAAY,CACrE,WAAW,CAAC,KAAK,CAAC,EAClB,OAAO,YAAY,CACpB,CAAC;AAEF,KAAK,eAAe,CAAC,KAAK,SAAS,WAAW,IAAI;IAChD,QAAQ,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtD,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,WAAW,IAAI;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,CACT,WAAW,EAAE,KAAK,EAClB,WAAW,EAAE,SAAS,KACnB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Inputs/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,WAAW,IAAI,YAAY,CACrE,WAAW,CAAC,KAAK,CAAC,EAClB,OAAO,YAAY,CACpB,CAAC;AAEF,KAAK,eAAe,CAAC,KAAK,SAAS,WAAW,IAAI;IAChD,QAAQ,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtD,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,WAAW,IAAI;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,CACT,WAAW,EAAE,KAAK,EAClB,WAAW,EAAE,SAAS,KACnB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,KAAK,SAAS,WAAW,IACvD,eAAe,CAAC,KAAK,CAAC,GAAG;IACvB,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CACrC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAE7B,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,WAAW,IACrD,eAAe,CAAC,KAAK,CAAC,GAAG;IACvB,MAAM,EAAE,IAAI,CAAC;CACd,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAE7B,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,WAAW,IAC7C,mBAAmB,CAAC,KAAK,CAAC,GAC1B,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAE7B,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,WAAW,IAAI;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remember-web/primitive",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Remember Web Primitive Components",
|
|
5
5
|
"homepage": "https://dramancompany.github.io/remember-web-packages/",
|
|
6
6
|
"author": "Remember",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@radix-ui/react-separator": "^1.0.3",
|
|
43
43
|
"@radix-ui/react-switch": "^1.0.3",
|
|
44
44
|
"@radix-ui/react-tooltip": "^1.0.7",
|
|
45
|
-
"@remember-web/icon": "^0.1.
|
|
45
|
+
"@remember-web/icon": "^0.1.9",
|
|
46
46
|
"@remember-web/mixin": "^0.1.14",
|
|
47
47
|
"@remember-web/shared": "^0.1.0"
|
|
48
48
|
},
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ControlBookmarkOn,
|
|
6
6
|
ControlCheckOff,
|
|
7
7
|
ControlCheckOn,
|
|
8
|
+
ControlCheckboxIndeterminate,
|
|
8
9
|
ControlCheckboxOff,
|
|
9
10
|
ControlCheckboxOn,
|
|
10
11
|
ControlFavoriteOff,
|
|
@@ -22,11 +23,31 @@ import {
|
|
|
22
23
|
import type { ToggleStatusType, ToggleVariantType } from '../types';
|
|
23
24
|
|
|
24
25
|
const ICON_NAME = {
|
|
25
|
-
check: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
check: {
|
|
27
|
+
on: ControlCheckOn,
|
|
28
|
+
indeterminate: ControlCheckOn,
|
|
29
|
+
off: ControlCheckOff,
|
|
30
|
+
},
|
|
31
|
+
checkbox: {
|
|
32
|
+
on: ControlCheckboxOn,
|
|
33
|
+
indeterminate: ControlCheckboxIndeterminate,
|
|
34
|
+
off: ControlCheckboxOff,
|
|
35
|
+
},
|
|
36
|
+
favorite: {
|
|
37
|
+
on: ControlFavoriteOn,
|
|
38
|
+
indeterminate: ControlFavoriteOn,
|
|
39
|
+
off: ControlFavoriteOff,
|
|
40
|
+
},
|
|
41
|
+
bookmark: {
|
|
42
|
+
on: ControlBookmarkOn,
|
|
43
|
+
indeterminate: ControlBookmarkOn,
|
|
44
|
+
off: ControlBookmarkOff,
|
|
45
|
+
},
|
|
46
|
+
radio: {
|
|
47
|
+
on: ControlRadioOn,
|
|
48
|
+
indeterminate: ControlRadioOn,
|
|
49
|
+
off: ControlRadioOff,
|
|
50
|
+
},
|
|
30
51
|
} as const satisfies Record<
|
|
31
52
|
ToggleVariantType,
|
|
32
53
|
Record<ToggleStatusType, WithSvgSizeComponentType>
|
|
@@ -44,6 +65,7 @@ export function ToggleIcon({
|
|
|
44
65
|
} & SvgSizeProps) {
|
|
45
66
|
const iconSize =
|
|
46
67
|
typeof size === 'string' && isSvgRegularSize(size) ? SVG_SIZES[size] : size;
|
|
68
|
+
|
|
47
69
|
const Icon = ICON_NAME[variant][status];
|
|
48
70
|
|
|
49
71
|
return <Icon className={className} size={iconSize} />;
|
|
@@ -24,6 +24,7 @@ const _BaseToggle: ForwardRefRenderFunction<
|
|
|
24
24
|
type = 'checkbox',
|
|
25
25
|
onToggle,
|
|
26
26
|
onChange,
|
|
27
|
+
indeterminate,
|
|
27
28
|
...props
|
|
28
29
|
},
|
|
29
30
|
ref
|
|
@@ -38,7 +39,15 @@ const _BaseToggle: ForwardRefRenderFunction<
|
|
|
38
39
|
return (
|
|
39
40
|
<ToggleRoot className={className} $gap={labelGap}>
|
|
40
41
|
<ToggleInput
|
|
41
|
-
ref={
|
|
42
|
+
ref={(input) => {
|
|
43
|
+
if (typeof ref !== 'function' && ref) {
|
|
44
|
+
ref.current = input;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (input) {
|
|
48
|
+
input.indeterminate = indeterminate ?? false;
|
|
49
|
+
}
|
|
50
|
+
}}
|
|
42
51
|
className={inputClassName}
|
|
43
52
|
type={type}
|
|
44
53
|
{...props}
|
|
@@ -54,6 +63,12 @@ const _BaseToggle: ForwardRefRenderFunction<
|
|
|
54
63
|
status="on"
|
|
55
64
|
variant={variant}
|
|
56
65
|
/>
|
|
66
|
+
<ToggleIcon
|
|
67
|
+
className="indeterminateIcon"
|
|
68
|
+
size={size}
|
|
69
|
+
status="indeterminate"
|
|
70
|
+
variant={variant}
|
|
71
|
+
/>
|
|
57
72
|
<ToggleIcon
|
|
58
73
|
className="offIcon"
|
|
59
74
|
size={size}
|
|
@@ -44,6 +44,15 @@ export const ToggleInput = styled.input`
|
|
|
44
44
|
display: none;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
&:indeterminate ~ svg.offIcon,
|
|
48
|
+
&:indeterminate ~ svg.onIcon {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&:not(:indeterminate) ~ svg.indeterminateIcon {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
47
56
|
&:disabled ~ svg {
|
|
48
57
|
filter: grayscale(1) brightness(1.1);
|
|
49
58
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
export type ToggleStatusType = 'on' | 'off';
|
|
3
|
+
export type ToggleStatusType = 'on' | 'off' | 'indeterminate';
|
|
4
4
|
export type ToggleVariantType =
|
|
5
5
|
| 'check'
|
|
6
6
|
| 'checkbox'
|
|
@@ -24,6 +24,7 @@ export type BaseToggleProps = {
|
|
|
24
24
|
onToggle?: (checked: boolean) => void;
|
|
25
25
|
size?: ToggleIconSizeType;
|
|
26
26
|
type?: 'checkbox' | 'radio';
|
|
27
|
+
indeterminate?: boolean;
|
|
27
28
|
} & Omit<
|
|
28
29
|
React.InputHTMLAttributes<HTMLInputElement>,
|
|
29
30
|
'type' | `aria-${string}` | 'size'
|
|
@@ -19,10 +19,10 @@ export const Default: Story = {
|
|
|
19
19
|
disabled: false,
|
|
20
20
|
required: false,
|
|
21
21
|
checked: false,
|
|
22
|
-
variant: 'checkbox',
|
|
23
22
|
label: "I'm a Checkbox",
|
|
24
23
|
size: 'medium',
|
|
25
24
|
labelPosition: 'right',
|
|
25
|
+
indeterminate: false,
|
|
26
26
|
},
|
|
27
27
|
render: ({ ...args }) => {
|
|
28
28
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -30,6 +30,33 @@ export const Default: Story = {
|
|
|
30
30
|
return (
|
|
31
31
|
<Checkbox
|
|
32
32
|
{...args}
|
|
33
|
+
variant="checkbox"
|
|
34
|
+
checked={checked}
|
|
35
|
+
onToggle={(v) => updateArgs({ checked: v })}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Check: Story = {
|
|
42
|
+
args: {
|
|
43
|
+
disabled: false,
|
|
44
|
+
required: false,
|
|
45
|
+
checked: false,
|
|
46
|
+
label: "I'm a Check",
|
|
47
|
+
size: 'medium',
|
|
48
|
+
labelPosition: 'right',
|
|
49
|
+
},
|
|
50
|
+
argTypes: {
|
|
51
|
+
indeterminate: { table: { disable: true } },
|
|
52
|
+
},
|
|
53
|
+
render: ({ ...args }) => {
|
|
54
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
55
|
+
const [{ checked }, updateArgs] = useArgs();
|
|
56
|
+
return (
|
|
57
|
+
<Checkbox
|
|
58
|
+
{...args}
|
|
59
|
+
variant="check"
|
|
33
60
|
checked={checked}
|
|
34
61
|
onToggle={(v) => updateArgs({ checked: v })}
|
|
35
62
|
/>
|
package/src/Control/Checkbox.tsx
CHANGED
|
@@ -5,11 +5,17 @@ import { forwardRef, type ForwardRefRenderFunction } from 'react';
|
|
|
5
5
|
import type { BaseToggleProps } from './BaseToggle/types';
|
|
6
6
|
import { CircleBaseToggle } from './Toggle';
|
|
7
7
|
|
|
8
|
+
type CheckboxProps<T> = Omit<BaseToggleProps, 'variant' | 'indeterminate'> & T;
|
|
9
|
+
|
|
8
10
|
export const _Checkbox: ForwardRefRenderFunction<
|
|
9
11
|
HTMLInputElement,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
| CheckboxProps<{
|
|
13
|
+
variant: 'checkbox';
|
|
14
|
+
indeterminate?: boolean;
|
|
15
|
+
}>
|
|
16
|
+
| CheckboxProps<{
|
|
17
|
+
variant: 'check';
|
|
18
|
+
}>
|
|
13
19
|
> = ({ variant = 'checkbox', ...props }, ref) => (
|
|
14
20
|
<CircleBaseToggle ref={ref} variant={variant} {...props} />
|
|
15
21
|
);
|
package/src/Control/Radio.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { CircleBaseToggle } from './Toggle';
|
|
|
7
7
|
|
|
8
8
|
const _Radio: ForwardRefRenderFunction<
|
|
9
9
|
HTMLInputElement,
|
|
10
|
-
Omit<BaseToggleProps, 'variant' | 'onToggle' | 'type'>
|
|
10
|
+
Omit<BaseToggleProps, 'variant' | 'onToggle' | 'type' | 'indeterminate'>
|
|
11
11
|
> = ({ ...props }, ref) => (
|
|
12
12
|
<CircleBaseToggle ref={ref} variant="radio" type="radio" {...props} />
|
|
13
13
|
);
|
package/src/Control/Toggle.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import type { BaseToggleProps } from './BaseToggle/types';
|
|
|
8
8
|
|
|
9
9
|
export const _Toggle: ForwardRefRenderFunction<
|
|
10
10
|
HTMLInputElement,
|
|
11
|
-
Omit<BaseToggleProps, 'variant' | 'type'> & {
|
|
11
|
+
Omit<BaseToggleProps, 'variant' | 'type' | 'indeterminate'> & {
|
|
12
12
|
variant: 'bookmark' | 'favorite';
|
|
13
13
|
}
|
|
14
14
|
> = ({ variant, ...props }, ref) => (
|
|
@@ -37,6 +37,7 @@ const DesignedSelect = <Value extends SelectValue>(
|
|
|
37
37
|
width,
|
|
38
38
|
extendDirection,
|
|
39
39
|
disabled,
|
|
40
|
+
onClick,
|
|
40
41
|
...props
|
|
41
42
|
}: DesignedSelectInternalProps<Value>,
|
|
42
43
|
ref?: Ref<HTMLDivElement>
|
|
@@ -217,6 +218,7 @@ const DesignedSelect = <Value extends SelectValue>(
|
|
|
217
218
|
>
|
|
218
219
|
<StyledSelect
|
|
219
220
|
ref={ref}
|
|
221
|
+
onClick={onClick}
|
|
220
222
|
expandedDirection={expandedDirection}
|
|
221
223
|
isPlaceholder={!selectedOption && !!placeholder}
|
|
222
224
|
onPointerDown={(e) => {
|
|
@@ -12,7 +12,16 @@ const NativeSelect: ForwardRefRenderFunction<
|
|
|
12
12
|
HTMLSelectElement,
|
|
13
13
|
NativeSelectInternalProps
|
|
14
14
|
> = (
|
|
15
|
-
{
|
|
15
|
+
{
|
|
16
|
+
children,
|
|
17
|
+
className,
|
|
18
|
+
width,
|
|
19
|
+
placeholder,
|
|
20
|
+
value,
|
|
21
|
+
disabled,
|
|
22
|
+
onClick,
|
|
23
|
+
...props
|
|
24
|
+
},
|
|
16
25
|
ref
|
|
17
26
|
) => {
|
|
18
27
|
const showPlaceholder = !value && !!placeholder;
|
|
@@ -26,6 +35,7 @@ const NativeSelect: ForwardRefRenderFunction<
|
|
|
26
35
|
ref={ref}
|
|
27
36
|
isPlaceholder={showPlaceholder}
|
|
28
37
|
disabled={disabled}
|
|
38
|
+
onClick={onClick}
|
|
29
39
|
>
|
|
30
40
|
{!value && (
|
|
31
41
|
<option value="" selected>
|
|
@@ -18,6 +18,7 @@ const meta = {
|
|
|
18
18
|
width: { type: 'string' },
|
|
19
19
|
maxHeight: { type: 'string' },
|
|
20
20
|
native: { type: 'boolean' },
|
|
21
|
+
onClick: { action: 'clicked' },
|
|
21
22
|
},
|
|
22
23
|
} satisfies Meta<typeof Select>;
|
|
23
24
|
|
|
@@ -36,6 +37,7 @@ export const Native: Story = {
|
|
|
36
37
|
onChange={(tV) => {
|
|
37
38
|
setValue(tV);
|
|
38
39
|
}}
|
|
40
|
+
onClick={() => console.log('clicked native select')}
|
|
39
41
|
>
|
|
40
42
|
<Select.Option value="1">Option 1</Select.Option>
|
|
41
43
|
<Select.Option value="2">Option 2</Select.Option>
|
|
@@ -66,6 +68,7 @@ export const Custom: Story = {
|
|
|
66
68
|
onChange={(tV) => {
|
|
67
69
|
setValue(tV);
|
|
68
70
|
}}
|
|
71
|
+
onClick={() => console.log('clicked custom select')}
|
|
69
72
|
>
|
|
70
73
|
<Select.Option value="1">Option 1</Select.Option>
|
|
71
74
|
<Select.Option value="2">Option 2</Select.Option>
|
|
@@ -29,6 +29,7 @@ function Select<Value extends SelectValue>(
|
|
|
29
29
|
placeholder,
|
|
30
30
|
width,
|
|
31
31
|
required,
|
|
32
|
+
onClick,
|
|
32
33
|
} = props;
|
|
33
34
|
|
|
34
35
|
if (props.native) {
|
|
@@ -43,6 +44,7 @@ function Select<Value extends SelectValue>(
|
|
|
43
44
|
<NativeSelect
|
|
44
45
|
disabled={disabled}
|
|
45
46
|
className={className}
|
|
47
|
+
onClick={onClick}
|
|
46
48
|
onChange={(e) => {
|
|
47
49
|
onChange?.(e.target.value as Value, e.target.innerText);
|
|
48
50
|
}}
|
|
@@ -72,6 +74,7 @@ function Select<Value extends SelectValue>(
|
|
|
72
74
|
className={className}
|
|
73
75
|
value={value}
|
|
74
76
|
disabled={disabled}
|
|
77
|
+
onClick={onClick}
|
|
75
78
|
onChange={(_value, _label) => onChange?.(_value as Value, _label)}
|
|
76
79
|
placeholder={placeholder}
|
|
77
80
|
width={width}
|