@ceed/ads 1.16.0-next.5 → 1.16.0-next.7
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.
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
interface FilterableCheckboxGroupOption {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export type FilterableCheckboxGroupProps = {
|
|
7
8
|
value?: string[];
|
|
@@ -13,6 +14,7 @@ export type FilterableCheckboxGroupProps = {
|
|
|
13
14
|
required?: boolean;
|
|
14
15
|
onChange?: (value: string[]) => void;
|
|
15
16
|
maxHeight?: string | number;
|
|
17
|
+
disabled?: boolean;
|
|
16
18
|
};
|
|
17
19
|
declare function FilterableCheckboxGroup(props: FilterableCheckboxGroupProps): React.JSX.Element;
|
|
18
20
|
declare namespace FilterableCheckboxGroup {
|
|
@@ -177,3 +177,29 @@ function MyComponent() {
|
|
|
177
177
|
</Typography>
|
|
178
178
|
</Stack>
|
|
179
179
|
```
|
|
180
|
+
|
|
181
|
+
### Disabled
|
|
182
|
+
|
|
183
|
+
컴포넌트 전체 또는 특정 옵션을 비활성화할 수 있습니다.
|
|
184
|
+
|
|
185
|
+
- **컴포넌트 전체 비활성화**: `disabled` prop을 사용하여 검색 input, "Select all", 모든 옵션을 비활성화합니다.
|
|
186
|
+
- **특정 옵션 비활성화**: 옵션 객체의 `disabled` 속성을 사용하여 개별 옵션을 비활성화합니다.
|
|
187
|
+
- **"Select all" 동작**: 비활성화된 옵션은 "Select all"의 영향을 받지 않으며, 선택 상태가 유지됩니다.
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
<Stack spacing={3}>
|
|
191
|
+
<FilterableCheckboxGroup label="Entirely Disabled" placeholder="Search..." helperText="All inputs are disabled" options={defaultOptions.slice(0, 5)} disabled />
|
|
192
|
+
<FilterableCheckboxGroup label="Partially Disabled Options" placeholder="Search..." helperText="Some options are disabled" options={disabledOptions} />
|
|
193
|
+
<Stack spacing={2}>
|
|
194
|
+
<FilterableCheckboxGroup label="Controlled + Partially Disabled" placeholder="Search..." helperText="Disabled options (Banana, Date) maintain their selected state" options={disabledOptions} value={controlledValue} onChange={setControlledValue} />
|
|
195
|
+
<Typography level="body-sm">
|
|
196
|
+
Selected: {controlledValue.length > 0 ? controlledValue.join(', ') : 'None'}
|
|
197
|
+
</Typography>
|
|
198
|
+
<Typography level="body-sm" sx={{
|
|
199
|
+
color: 'text.secondary'
|
|
200
|
+
}}>
|
|
201
|
+
Try "Select all" - it will only affect enabled options (Apple, Cherry, Elderberry)
|
|
202
|
+
</Typography>
|
|
203
|
+
</Stack>
|
|
204
|
+
</Stack>
|
|
205
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -4480,7 +4480,18 @@ var import_joy43 = require("@mui/joy");
|
|
|
4480
4480
|
var import_Search = __toESM(require("@mui/icons-material/Search"));
|
|
4481
4481
|
var import_react_virtual3 = require("@tanstack/react-virtual");
|
|
4482
4482
|
function FilterableCheckboxGroup(props) {
|
|
4483
|
-
const {
|
|
4483
|
+
const {
|
|
4484
|
+
value,
|
|
4485
|
+
options,
|
|
4486
|
+
label,
|
|
4487
|
+
placeholder,
|
|
4488
|
+
helperText,
|
|
4489
|
+
size = "md",
|
|
4490
|
+
required,
|
|
4491
|
+
onChange,
|
|
4492
|
+
maxHeight = 300,
|
|
4493
|
+
disabled
|
|
4494
|
+
} = props;
|
|
4484
4495
|
const [searchTerm, setSearchTerm] = (0, import_react33.useState)("");
|
|
4485
4496
|
const [sortedOptions, setSortedOptions] = (0, import_react33.useState)(options);
|
|
4486
4497
|
const [internalValue, setInternalValue] = useControlledState(
|
|
@@ -4558,16 +4569,25 @@ function FilterableCheckboxGroup(props) {
|
|
|
4558
4569
|
const handleSelectAll = (0, import_react33.useCallback)(
|
|
4559
4570
|
(event) => {
|
|
4560
4571
|
const checked = event.target.checked;
|
|
4572
|
+
const enabledOptions = filteredOptions.filter((option) => !option.disabled);
|
|
4573
|
+
const disabledSelectedValues = internalValue.filter(
|
|
4574
|
+
(v) => filteredOptions.some((opt) => opt.value === v && opt.disabled)
|
|
4575
|
+
);
|
|
4561
4576
|
if (checked) {
|
|
4562
|
-
|
|
4577
|
+
const enabledValues = enabledOptions.map((option) => option.value);
|
|
4578
|
+
setInternalValue([...disabledSelectedValues, ...enabledValues]);
|
|
4563
4579
|
} else {
|
|
4564
|
-
setInternalValue(
|
|
4580
|
+
setInternalValue(disabledSelectedValues);
|
|
4565
4581
|
}
|
|
4566
4582
|
},
|
|
4567
|
-
[filteredOptions, setInternalValue]
|
|
4583
|
+
[filteredOptions, internalValue, setInternalValue]
|
|
4584
|
+
);
|
|
4585
|
+
const enabledFilteredOptions = (0, import_react33.useMemo)(
|
|
4586
|
+
() => filteredOptions.filter((option) => !option.disabled),
|
|
4587
|
+
[filteredOptions]
|
|
4568
4588
|
);
|
|
4569
|
-
const isAllSelected =
|
|
4570
|
-
const isIndeterminate = !isAllSelected &&
|
|
4589
|
+
const isAllSelected = enabledFilteredOptions.length > 0 && enabledFilteredOptions.every((option) => internalValue.includes(option.value));
|
|
4590
|
+
const isIndeterminate = !isAllSelected && enabledFilteredOptions.some((option) => internalValue.includes(option.value));
|
|
4571
4591
|
return /* @__PURE__ */ import_react33.default.createElement("div", { style: { width: "100%" } }, /* @__PURE__ */ import_react33.default.createElement(FormControl_default, { required, size }, label && /* @__PURE__ */ import_react33.default.createElement(FormLabel_default, null, label), /* @__PURE__ */ import_react33.default.createElement(
|
|
4572
4592
|
import_joy43.Input,
|
|
4573
4593
|
{
|
|
@@ -4577,6 +4597,7 @@ function FilterableCheckboxGroup(props) {
|
|
|
4577
4597
|
value: searchTerm,
|
|
4578
4598
|
onChange: handleSearchChange,
|
|
4579
4599
|
size,
|
|
4600
|
+
disabled,
|
|
4580
4601
|
endDecorator: /* @__PURE__ */ import_react33.default.createElement(import_Search.default, null)
|
|
4581
4602
|
}
|
|
4582
4603
|
), helperText && /* @__PURE__ */ import_react33.default.createElement(FormHelperText_default, null, helperText)), filteredOptions.length === 0 ? /* @__PURE__ */ import_react33.default.createElement(
|
|
@@ -4610,6 +4631,7 @@ function FilterableCheckboxGroup(props) {
|
|
|
4610
4631
|
indeterminate: isIndeterminate,
|
|
4611
4632
|
onChange: handleSelectAll,
|
|
4612
4633
|
size,
|
|
4634
|
+
disabled,
|
|
4613
4635
|
slotProps: {
|
|
4614
4636
|
action: {
|
|
4615
4637
|
sx: { top: 0, left: 0, bottom: 0, right: 0 }
|
|
@@ -4636,6 +4658,7 @@ function FilterableCheckboxGroup(props) {
|
|
|
4636
4658
|
checked: internalValue.includes(option.value),
|
|
4637
4659
|
onChange: handleCheckboxChange(option.value),
|
|
4638
4660
|
size,
|
|
4661
|
+
disabled: disabled || option.disabled,
|
|
4639
4662
|
slotProps: {
|
|
4640
4663
|
action: {
|
|
4641
4664
|
sx: { top: 0, left: 0, bottom: 0, right: 0 }
|
|
@@ -4717,7 +4740,8 @@ function FilterableCheckboxGroup2(props) {
|
|
|
4717
4740
|
onChange: handleChange,
|
|
4718
4741
|
options,
|
|
4719
4742
|
placeholder,
|
|
4720
|
-
maxHeight
|
|
4743
|
+
maxHeight,
|
|
4744
|
+
size: "sm"
|
|
4721
4745
|
}
|
|
4722
4746
|
));
|
|
4723
4747
|
}
|
package/dist/index.js
CHANGED
|
@@ -4415,7 +4415,18 @@ import { Input as Input2, Stack as Stack2 } from "@mui/joy";
|
|
|
4415
4415
|
import SearchIcon from "@mui/icons-material/Search";
|
|
4416
4416
|
import { useVirtualizer as useVirtualizer3 } from "@tanstack/react-virtual";
|
|
4417
4417
|
function FilterableCheckboxGroup(props) {
|
|
4418
|
-
const {
|
|
4418
|
+
const {
|
|
4419
|
+
value,
|
|
4420
|
+
options,
|
|
4421
|
+
label,
|
|
4422
|
+
placeholder,
|
|
4423
|
+
helperText,
|
|
4424
|
+
size = "md",
|
|
4425
|
+
required,
|
|
4426
|
+
onChange,
|
|
4427
|
+
maxHeight = 300,
|
|
4428
|
+
disabled
|
|
4429
|
+
} = props;
|
|
4419
4430
|
const [searchTerm, setSearchTerm] = useState10("");
|
|
4420
4431
|
const [sortedOptions, setSortedOptions] = useState10(options);
|
|
4421
4432
|
const [internalValue, setInternalValue] = useControlledState(
|
|
@@ -4493,16 +4504,25 @@ function FilterableCheckboxGroup(props) {
|
|
|
4493
4504
|
const handleSelectAll = useCallback13(
|
|
4494
4505
|
(event) => {
|
|
4495
4506
|
const checked = event.target.checked;
|
|
4507
|
+
const enabledOptions = filteredOptions.filter((option) => !option.disabled);
|
|
4508
|
+
const disabledSelectedValues = internalValue.filter(
|
|
4509
|
+
(v) => filteredOptions.some((opt) => opt.value === v && opt.disabled)
|
|
4510
|
+
);
|
|
4496
4511
|
if (checked) {
|
|
4497
|
-
|
|
4512
|
+
const enabledValues = enabledOptions.map((option) => option.value);
|
|
4513
|
+
setInternalValue([...disabledSelectedValues, ...enabledValues]);
|
|
4498
4514
|
} else {
|
|
4499
|
-
setInternalValue(
|
|
4515
|
+
setInternalValue(disabledSelectedValues);
|
|
4500
4516
|
}
|
|
4501
4517
|
},
|
|
4502
|
-
[filteredOptions, setInternalValue]
|
|
4518
|
+
[filteredOptions, internalValue, setInternalValue]
|
|
4519
|
+
);
|
|
4520
|
+
const enabledFilteredOptions = useMemo12(
|
|
4521
|
+
() => filteredOptions.filter((option) => !option.disabled),
|
|
4522
|
+
[filteredOptions]
|
|
4503
4523
|
);
|
|
4504
|
-
const isAllSelected =
|
|
4505
|
-
const isIndeterminate = !isAllSelected &&
|
|
4524
|
+
const isAllSelected = enabledFilteredOptions.length > 0 && enabledFilteredOptions.every((option) => internalValue.includes(option.value));
|
|
4525
|
+
const isIndeterminate = !isAllSelected && enabledFilteredOptions.some((option) => internalValue.includes(option.value));
|
|
4506
4526
|
return /* @__PURE__ */ React30.createElement("div", { style: { width: "100%" } }, /* @__PURE__ */ React30.createElement(FormControl_default, { required, size }, label && /* @__PURE__ */ React30.createElement(FormLabel_default, null, label), /* @__PURE__ */ React30.createElement(
|
|
4507
4527
|
Input2,
|
|
4508
4528
|
{
|
|
@@ -4512,6 +4532,7 @@ function FilterableCheckboxGroup(props) {
|
|
|
4512
4532
|
value: searchTerm,
|
|
4513
4533
|
onChange: handleSearchChange,
|
|
4514
4534
|
size,
|
|
4535
|
+
disabled,
|
|
4515
4536
|
endDecorator: /* @__PURE__ */ React30.createElement(SearchIcon, null)
|
|
4516
4537
|
}
|
|
4517
4538
|
), helperText && /* @__PURE__ */ React30.createElement(FormHelperText_default, null, helperText)), filteredOptions.length === 0 ? /* @__PURE__ */ React30.createElement(
|
|
@@ -4545,6 +4566,7 @@ function FilterableCheckboxGroup(props) {
|
|
|
4545
4566
|
indeterminate: isIndeterminate,
|
|
4546
4567
|
onChange: handleSelectAll,
|
|
4547
4568
|
size,
|
|
4569
|
+
disabled,
|
|
4548
4570
|
slotProps: {
|
|
4549
4571
|
action: {
|
|
4550
4572
|
sx: { top: 0, left: 0, bottom: 0, right: 0 }
|
|
@@ -4571,6 +4593,7 @@ function FilterableCheckboxGroup(props) {
|
|
|
4571
4593
|
checked: internalValue.includes(option.value),
|
|
4572
4594
|
onChange: handleCheckboxChange(option.value),
|
|
4573
4595
|
size,
|
|
4596
|
+
disabled: disabled || option.disabled,
|
|
4574
4597
|
slotProps: {
|
|
4575
4598
|
action: {
|
|
4576
4599
|
sx: { top: 0, left: 0, bottom: 0, right: 0 }
|
|
@@ -4652,7 +4675,8 @@ function FilterableCheckboxGroup2(props) {
|
|
|
4652
4675
|
onChange: handleChange,
|
|
4653
4676
|
options,
|
|
4654
4677
|
placeholder,
|
|
4655
|
-
maxHeight
|
|
4678
|
+
maxHeight,
|
|
4679
|
+
size: "sm"
|
|
4656
4680
|
}
|
|
4657
4681
|
));
|
|
4658
4682
|
}
|