@northlight/ui 2.23.0 → 2.24.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/dist/es/northlight.d.ts +54 -17
- package/dist/es/northlight.js +14 -5
- package/dist/es/northlight.js.map +1 -1
- package/dist/umd/northlight.cjs +14 -5
- package/dist/umd/northlight.cjs.map +1 -1
- package/dist/umd/northlight.min.cjs +3 -3
- package/dist/umd/northlight.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/es/northlight.d.ts
CHANGED
|
@@ -4178,6 +4178,10 @@ interface CreatableSelectDropdownProps {
|
|
|
4178
4178
|
*
|
|
4179
4179
|
*/
|
|
4180
4180
|
variant?: Variant;
|
|
4181
|
+
/**
|
|
4182
|
+
* Value of the initially selected option.
|
|
4183
|
+
*/
|
|
4184
|
+
initialValue?: string;
|
|
4181
4185
|
}
|
|
4182
4186
|
|
|
4183
4187
|
/**
|
|
@@ -4186,36 +4190,69 @@ interface CreatableSelectDropdownProps {
|
|
|
4186
4190
|
* @see {@link https://northlight.dev/reference/creatable-select-dropdown}
|
|
4187
4191
|
*
|
|
4188
4192
|
* @example (Example)
|
|
4189
|
-
* ##Select the best artist
|
|
4190
4193
|
* (?
|
|
4191
4194
|
* () => {
|
|
4192
4195
|
* const [artist, setArtist] = useState(null);
|
|
4193
|
-
* const
|
|
4196
|
+
* const [element, setElement] = useState({ label: 'Technique', value: 'technique' })
|
|
4197
|
+
* const someOptions = [
|
|
4194
4198
|
* { label: 'Scooter', value: 'scooter' },
|
|
4195
4199
|
* { label: 'Snoop Doggy Dogg', value: 'snoop-dogg' },
|
|
4196
4200
|
* ];
|
|
4197
4201
|
*
|
|
4198
|
-
|
|
4199
|
-
*
|
|
4200
|
-
*
|
|
4201
|
-
*
|
|
4202
|
+
* const someOtherOptions = [
|
|
4203
|
+
* { label: 'Vision', value: 'vision' },
|
|
4204
|
+
* { label: 'Technique', value: 'technique' },
|
|
4205
|
+
* { label: 'Expression', value: 'expression' }
|
|
4206
|
+
* ];
|
|
4202
4207
|
*
|
|
4203
4208
|
* return (
|
|
4204
|
-
* <
|
|
4205
|
-
* <
|
|
4206
|
-
*
|
|
4207
|
-
*
|
|
4208
|
-
*
|
|
4209
|
-
*
|
|
4210
|
-
*
|
|
4211
|
-
*
|
|
4212
|
-
*
|
|
4213
|
-
*
|
|
4209
|
+
* <VStack gap={10} alignItems={"flex-start"}>
|
|
4210
|
+
* <Box align="left">
|
|
4211
|
+
* <H1>Basic example</H1>
|
|
4212
|
+
* <H3>Select the best artist</H3>
|
|
4213
|
+
* <CreatableSelectDropdown
|
|
4214
|
+
* standardOptions={someOptions}
|
|
4215
|
+
* onOptionChange={setArtist}
|
|
4216
|
+
* width="300px"
|
|
4217
|
+
* />
|
|
4218
|
+
* {artist && artist.value !== 'Add option...' && (
|
|
4219
|
+
* <H3 py={8}>The best artist is: {artist.label}</H3>
|
|
4220
|
+
* )}
|
|
4221
|
+
* </Box>
|
|
4222
|
+
* <Box align="left">
|
|
4223
|
+
* <H1>Pre-selected option</H1>
|
|
4224
|
+
* <H3>What is the quintessential element of an exceptional artisan?</H3>
|
|
4225
|
+
* <CreatableSelectDropdown
|
|
4226
|
+
* standardOptions={someOtherOptions}
|
|
4227
|
+
* onOptionChange={setElement}
|
|
4228
|
+
* width="300px"
|
|
4229
|
+
* initialValue="technique"
|
|
4230
|
+
* />
|
|
4231
|
+
* {element && element.value !== 'Add option...' && (
|
|
4232
|
+
* <H3 py={8}>
|
|
4233
|
+
* {element.value === 'vision' && (
|
|
4234
|
+
* 'The artist\'s vision shapes their creative world.'
|
|
4235
|
+
* )}
|
|
4236
|
+
* {element.value === 'technique' && (
|
|
4237
|
+
* 'Technique is the legacy\'s bedrock.'
|
|
4238
|
+
* )}
|
|
4239
|
+
* {element.value === 'expression' && (
|
|
4240
|
+
* 'Expression communicates the artist\'s inner voice.'
|
|
4241
|
+
* )}
|
|
4242
|
+
* {element.value !== 'vision' &&
|
|
4243
|
+
* element.value !== 'technique' &&
|
|
4244
|
+
* element.value !== 'expression' && (
|
|
4245
|
+
* 'Absent the selection of legitimate alternatives.'
|
|
4246
|
+
* )}
|
|
4247
|
+
* </H3>
|
|
4248
|
+
* )}
|
|
4249
|
+
* </Box>
|
|
4250
|
+
* </VStack>
|
|
4214
4251
|
* );
|
|
4215
4252
|
* }
|
|
4216
4253
|
* ?)
|
|
4217
4254
|
*/
|
|
4218
|
-
declare const CreatableSelectDropdown: ({ standardOptions, initialPlaceholder, addOptionPlaceholder, creationOption, onOptionChange, width, variant, }: CreatableSelectDropdownProps) => JSX.Element;
|
|
4255
|
+
declare const CreatableSelectDropdown: ({ standardOptions, initialPlaceholder, addOptionPlaceholder, creationOption, onOptionChange, width, variant, initialValue, }: CreatableSelectDropdownProps) => JSX.Element;
|
|
4219
4256
|
|
|
4220
4257
|
declare const useDebounce: <T>(value: T, delay: number) => T;
|
|
4221
4258
|
|
package/dist/es/northlight.js
CHANGED
|
@@ -13845,9 +13845,16 @@ const CreatableSelectDropdown = ({
|
|
|
13845
13845
|
},
|
|
13846
13846
|
onOptionChange,
|
|
13847
13847
|
width = "100%",
|
|
13848
|
-
variant = "outline"
|
|
13848
|
+
variant = "outline",
|
|
13849
|
+
initialValue = ""
|
|
13849
13850
|
}) => {
|
|
13850
|
-
const
|
|
13851
|
+
const initialSelectedOption = useMemo(
|
|
13852
|
+
() => standardOptions.find(
|
|
13853
|
+
(option) => option.value === initialValue
|
|
13854
|
+
) || null,
|
|
13855
|
+
[]
|
|
13856
|
+
);
|
|
13857
|
+
const [selectedOption, setSelectedOption] = useState(initialSelectedOption);
|
|
13851
13858
|
const [newOptionText, setNewOptionText] = useState("");
|
|
13852
13859
|
const [newOptionPlaceholder, setNewOptionPlaceholder] = useState(initialPlaceholder);
|
|
13853
13860
|
const [createdOptions, setCreatedOptions] = useState([]);
|
|
@@ -13869,7 +13876,8 @@ const CreatableSelectDropdown = ({
|
|
|
13869
13876
|
function isCreationOption(option) {
|
|
13870
13877
|
return option && typeof option.isCreation === "string";
|
|
13871
13878
|
}
|
|
13872
|
-
const handleChange = (
|
|
13879
|
+
const handleChange = (newValue, _actionMeta) => {
|
|
13880
|
+
const option = newValue;
|
|
13873
13881
|
if (option === null) {
|
|
13874
13882
|
return;
|
|
13875
13883
|
}
|
|
@@ -13898,18 +13906,19 @@ const CreatableSelectDropdown = ({
|
|
|
13898
13906
|
return /* @__PURE__ */ React.createElement(
|
|
13899
13907
|
CreatableSelect,
|
|
13900
13908
|
{
|
|
13901
|
-
chakraStyles: {
|
|
13909
|
+
chakraStyles: __spreadProps(__spreadValues({}, customSelectStyles), {
|
|
13902
13910
|
container: (provided) => __spreadProps(__spreadValues({}, provided), {
|
|
13903
13911
|
width
|
|
13904
13912
|
}),
|
|
13905
13913
|
option: (provided, { isSelected }) => __spreadValues(__spreadValues({}, provided), isSelected && {
|
|
13906
13914
|
color: "black"
|
|
13907
13915
|
})
|
|
13908
|
-
},
|
|
13916
|
+
}),
|
|
13909
13917
|
components: customComponents,
|
|
13910
13918
|
options: customOptions,
|
|
13911
13919
|
value: selectedOption,
|
|
13912
13920
|
onChange: handleChange,
|
|
13921
|
+
isMulti: false,
|
|
13913
13922
|
onInputChange: handleInputChange,
|
|
13914
13923
|
onKeyDown: handleKeyDown,
|
|
13915
13924
|
onCreateOption: handleCreateOption,
|