@lmb-it/kitsconcerto-native 0.1.284 → 0.1.286
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/apps/mobile/src/Core/AutoComplete/index.cjs +12 -4
- package/apps/mobile/src/Core/AutoComplete/index.cjs.map +1 -1
- package/apps/mobile/src/Core/AutoComplete/index.js +12 -4
- package/apps/mobile/src/Core/AutoComplete/index.js.map +1 -1
- package/apps/mobile/src/Core/MultiSelect/index.cjs +7 -4
- package/apps/mobile/src/Core/MultiSelect/index.cjs.map +1 -1
- package/apps/mobile/src/Core/MultiSelect/index.js +7 -4
- package/apps/mobile/src/Core/MultiSelect/index.js.map +1 -1
- package/apps/mobile/src/ui/accordion/index.js +2 -2
- package/components/ImageCropper/compression.cjs +63 -0
- package/components/ImageCropper/compression.cjs.map +1 -0
- package/components/ImageCropper/compression.js +58 -0
- package/components/ImageCropper/compression.js.map +1 -0
- package/components/ImageCropper/constants.cjs +35 -0
- package/components/ImageCropper/constants.cjs.map +1 -0
- package/components/ImageCropper/constants.js +23 -0
- package/components/ImageCropper/constants.js.map +1 -0
- package/components/ImageCropper/cropperState.cjs +119 -0
- package/components/ImageCropper/cropperState.cjs.map +1 -0
- package/components/ImageCropper/cropperState.js +114 -0
- package/components/ImageCropper/cropperState.js.map +1 -0
- package/components/ImageCropper/encode.cjs +45 -0
- package/components/ImageCropper/encode.cjs.map +1 -0
- package/components/ImageCropper/encode.js +42 -0
- package/components/ImageCropper/encode.js.map +1 -0
- package/components/ImageCropper/encoderRegistry.cjs +13 -0
- package/components/ImageCropper/encoderRegistry.cjs.map +1 -0
- package/components/ImageCropper/encoderRegistry.js +9 -0
- package/components/ImageCropper/encoderRegistry.js.map +1 -0
- package/components/ImageCropper/encoders/rnImageEncoder.cjs +54 -0
- package/components/ImageCropper/encoders/rnImageEncoder.cjs.map +1 -0
- package/components/ImageCropper/encoders/rnImageEncoder.js +51 -0
- package/components/ImageCropper/encoders/rnImageEncoder.js.map +1 -0
- package/components/ImageCropper/geometry.cjs +208 -0
- package/components/ImageCropper/geometry.cjs.map +1 -0
- package/components/ImageCropper/geometry.js +186 -0
- package/components/ImageCropper/geometry.js.map +1 -0
- package/components/ImageCropper/index.cjs +436 -0
- package/components/ImageCropper/index.cjs.map +1 -0
- package/components/ImageCropper/index.js +434 -0
- package/components/ImageCropper/index.js.map +1 -0
- package/components/ImageCropper/pinchZoom.cjs +8 -0
- package/components/ImageCropper/pinchZoom.cjs.map +1 -0
- package/components/ImageCropper/pinchZoom.js +5 -0
- package/components/ImageCropper/pinchZoom.js.map +1 -0
- package/components/ImageCropper/useImageSource.cjs +87 -0
- package/components/ImageCropper/useImageSource.cjs.map +1 -0
- package/components/ImageCropper/useImageSource.js +84 -0
- package/components/ImageCropper/useImageSource.js.map +1 -0
- package/form/helpers/FormContainer/index.cjs +12 -2
- package/form/helpers/FormContainer/index.cjs.map +1 -1
- package/form/helpers/FormContainer/index.js +12 -2
- package/form/helpers/FormContainer/index.js.map +1 -1
- package/form/selects/AutoComplete/index.cjs +10 -1
- package/form/selects/AutoComplete/index.cjs.map +1 -1
- package/form/selects/AutoComplete/index.js +11 -2
- package/form/selects/AutoComplete/index.js.map +1 -1
- package/form/selects/MultiSelect/index.cjs +8 -1
- package/form/selects/MultiSelect/index.cjs.map +1 -1
- package/form/selects/MultiSelect/index.js +9 -2
- package/form/selects/MultiSelect/index.js.map +1 -1
- package/hooks/useComponentDefaults.cjs +62 -8
- package/hooks/useComponentDefaults.cjs.map +1 -1
- package/hooks/useComponentDefaults.js +62 -8
- package/hooks/useComponentDefaults.js.map +1 -1
- package/index.cjs +120 -115
- package/index.cjs.map +1 -1
- package/index.d.ts +494 -16
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +13 -1
- package/packages/types/src/Theme/defaultTheme.cjs +135 -4
- package/packages/types/src/Theme/defaultTheme.cjs.map +1 -1
- package/packages/types/src/Theme/defaultTheme.js +135 -4
- package/packages/types/src/Theme/defaultTheme.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/form/selects/AutoComplete/index.native.tsx"],"sourcesContent":["import React from \"react\";\nimport KitsContainer from \"../../helpers/FormContainer\";\nimport {AutoComplete, useSeparator} from \"@lmb-it/kitsconcertomobile\";\nimport type { IAutoCompleteElement } from \"@lmb-it/kitsconcerto-types\";\nimport { useAutoCompleteLogic } from \"../hooks/useAutoCompleteLogic\";\nimport { useComponentDefaults, useResolvedStyle } from \"../../../hooks\";\nimport { useKitsTheme } from \"../../../contexts/Theme\";\n\nconst KitsAutoComplete = ({ ref, ...rawProps }: IAutoCompleteElement) => {\n const { mergedProps: props, themeStyle, elementStyles } = useComponentDefaults('AutoComplete', rawProps, 'Select');\n const resolvedThemeStyle = useResolvedStyle(themeStyle);\n const resolvedRootStyle = useResolvedStyle(elementStyles?.root || {});\n const {\n id,\n rightAddon,\n leftAddon,\n errors,\n invalid,\n label,\n hideError,\n disabled,\n required,\n isFloatedLabel,\n inputSize = \"md\",\n forceSelection,\n completeMethod,\n helperText,\n withArrow,\n placeholder,\n isMultiple,\n localProps,\n delay,\n minLength,\n selectionLimit,\n showEmptyMessage,\n emptyMessage,\n attached,\n containerStyle,\n } = props;\n\n const { nativeProps } = useSeparator<HTMLSelectElement>(props);\n\n const { resolveToken } = useKitsTheme();\n const primaryColor = resolveToken('primary');\n const borderColor = resolveToken('border');\n\n const {\n inputValue,\n setInputValue,\n filteredList,\n search,\n handleOnChange,\n list,\n childrenKey,\n labelKey,\n } = useAutoCompleteLogic({ isMultiple, forceSelection, completeMethod, ref });\n\n const hasThemeStyle = Object.keys(themeStyle).length > 0;\n\n\n const Element = <AutoComplete\n disabled={disabled}\n placeholder={placeholder}\n value={inputValue}\n forceSelection={forceSelection}\n suggestions={Array.isArray(filteredList) ? filteredList : list}\n completeMethod={search}\n dropdown={withArrow}\n multiple={isMultiple}\n field={labelKey}\n invalid={!!invalid}\n emptyMessage={emptyMessage ?? \"No results found\"}\n {...(delay != null ? { delay } : {})}\n {...(minLength != null ? { minLength } : {})}\n {...(selectionLimit != null ? { selectionLimit } : {})}\n showEmptyMessage={showEmptyMessage ?? true}\n optionGroupChildren={childrenKey ?? undefined}\n optionGroupLabel={childrenKey ? labelKey : undefined}\n style={{ width: \"100%\", borderRadius: 0, border:'none', backgroundColor:'transparent' }}\n inputStyle={{ flexDirection: \"row\", borderRadius: 0, border:'none', width: \"100%\",backgroundColor:'transparent', ...(resolvedRootStyle || resolvedThemeStyle) }}\n onChange={(event) => {\n setInputValue(event.value);\n handleOnChange(event);\n }}\n {...(localProps ?? {})}\n />\n\n if (attached) {\n return Element;\n }\n\n // KitsContainer's `inputGroup` wrapper defaults to `overflow: 'hidden'`\n // (so rounded borders clip the input cleanly). For AutoComplete that\n // would clip the floating suggestions panel back to the input's bounds\n // — the panel renders but is invisible, which is the \"list never\n // appears\" symptom on mobile. Force `overflow: 'visible'` on the\n // container chain so the panel can escape.\n const overflowEscape = {\n ...elementStyles,\n container: {\n ...(elementStyles?.container || {}),\n overflow: 'visible' as const,\n },\n inputGroup: {\n ...(elementStyles?.inputGroup || {}),\n overflow: 'visible' as const,\n },\n };\n\n return (\n <KitsContainer\n id={id}\n inputSize={inputSize}\n isFloatedLabel={isFloatedLabel}\n hideError={hideError}\n rightAddon={rightAddon}\n leftAddon={leftAddon}\n required={required}\n helperText={helperText}\n errors={errors}\n invalid={invalid}\n label={label}\n containerStyle={containerStyle}\n elementStyles={overflowEscape}\n >\n {Element}\n </KitsContainer>\n );\n};\n\nexport default KitsAutoComplete;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/form/selects/AutoComplete/index.native.tsx"],"sourcesContent":["import React from \"react\";\nimport KitsContainer from \"../../helpers/FormContainer\";\nimport {AutoComplete, useSeparator} from \"@lmb-it/kitsconcertomobile\";\nimport type { IAutoCompleteElement } from \"@lmb-it/kitsconcerto-types\";\nimport { useAutoCompleteLogic } from \"../hooks/useAutoCompleteLogic\";\nimport { useComponentDefaults, useResolvedStyle } from \"../../../hooks\";\nimport { splitTextStyle } from \"../../../hooks/useResolvedStyle\";\nimport { useKitsTheme } from \"../../../contexts/Theme\";\n\nconst KitsAutoComplete = ({ ref, ...rawProps }: IAutoCompleteElement) => {\n const { mergedProps: props, themeStyle, elementStyles, elementProps } = useComponentDefaults('AutoComplete', rawProps, 'Select');\n const resolvedThemeStyle = useResolvedStyle(themeStyle);\n const resolvedRootStyle = useResolvedStyle(elementStyles?.root || {});\n /* ─── Chips field slots — the native half of the same contract ──────────\n `tokenContainer` is the field wrapper View that holds the chips and the\n TextInput (web: `ul.p-autocomplete-multiple-container`). `token` splits\n in two on native, because a React Native `View` cannot carry `color` or\n `fontSize` — the text half goes to the chip's `Text`, which is what the\n CSS cascade does for free on web. */\n const resolvedTokenContainer = useResolvedStyle(elementStyles?.tokenContainer || {});\n const resolvedToken = useResolvedStyle(elementStyles?.token || {});\n const resolvedTokenIcon = useResolvedStyle(elementStyles?.tokenIcon || {});\n const {wrapper: tokenBoxStyle, text: tokenLabelStyle} = splitTextStyle(resolvedToken);\n const {\n id,\n rightAddon,\n leftAddon,\n errors,\n invalid,\n label,\n hideError,\n disabled,\n required,\n isFloatedLabel,\n inputSize = \"md\",\n forceSelection,\n completeMethod,\n helperText,\n withArrow,\n placeholder,\n isMultiple,\n localProps,\n delay,\n minLength,\n selectionLimit,\n showEmptyMessage,\n emptyMessage,\n attached,\n containerStyle,\n } = props;\n\n const { nativeProps } = useSeparator<HTMLSelectElement>(props);\n\n const { resolveToken } = useKitsTheme();\n const primaryColor = resolveToken('primary');\n const borderColor = resolveToken('border');\n\n const {\n inputValue,\n setInputValue,\n filteredList,\n search,\n handleOnChange,\n list,\n childrenKey,\n labelKey,\n } = useAutoCompleteLogic({ isMultiple, forceSelection, completeMethod, ref });\n\n const hasThemeStyle = Object.keys(themeStyle).length > 0;\n\n\n const Element = <AutoComplete\n disabled={disabled}\n placeholder={placeholder}\n value={inputValue}\n forceSelection={forceSelection}\n suggestions={Array.isArray(filteredList) ? filteredList : list}\n completeMethod={search}\n dropdown={withArrow}\n multiple={isMultiple}\n field={labelKey}\n invalid={!!invalid}\n emptyMessage={emptyMessage ?? \"No results found\"}\n {...(delay != null ? { delay } : {})}\n {...(minLength != null ? { minLength } : {})}\n {...(selectionLimit != null ? { selectionLimit } : {})}\n showEmptyMessage={showEmptyMessage ?? true}\n optionGroupChildren={childrenKey ?? undefined}\n optionGroupLabel={childrenKey ? labelKey : undefined}\n style={{ width: \"100%\", borderRadius: 0, border:'none', backgroundColor:'transparent' }}\n inputStyle={{ flexDirection: \"row\", borderRadius: 0, border:'none', width: \"100%\",backgroundColor:'transparent', ...(resolvedRootStyle || resolvedThemeStyle) }}\n tokenContainerStyle={resolvedTokenContainer}\n tokenStyle={tokenBoxStyle}\n tokenLabelStyle={tokenLabelStyle}\n tokenIconStyle={resolvedTokenIcon}\n onChange={(event) => {\n setInputValue(event.value);\n handleOnChange(event);\n }}\n {...(localProps ?? {})}\n />\n\n if (attached) {\n return Element;\n }\n\n // KitsContainer's `inputGroup` wrapper defaults to `overflow: 'hidden'`\n // (so rounded borders clip the input cleanly). For AutoComplete that\n // would clip the floating suggestions panel back to the input's bounds\n // — the panel renders but is invisible, which is the \"list never\n // appears\" symptom on mobile. Force `overflow: 'visible'` on the\n // container chain so the panel can escape.\n const overflowEscape = {\n ...elementStyles,\n container: {\n ...(elementStyles?.container || {}),\n overflow: 'visible' as const,\n },\n inputGroup: {\n ...(elementStyles?.inputGroup || {}),\n overflow: 'visible' as const,\n },\n };\n\n return (\n <KitsContainer\n id={id}\n inputSize={inputSize}\n isFloatedLabel={isFloatedLabel}\n hideError={hideError}\n rightAddon={rightAddon}\n leftAddon={leftAddon}\n required={required}\n helperText={helperText}\n errors={errors}\n invalid={invalid}\n label={label}\n containerStyle={containerStyle}\n elementStyles={overflowEscape}\n elementProps={elementProps}\n >\n {Element}\n </KitsContainer>\n );\n};\n\nexport default KitsAutoComplete;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,mBAAmB,CAAC,EAAE,GAAA,EAAK,GAAG,UAAS,KAA4B;AACrE,EAAA,MAAM,EAAE,WAAA,EAAa,KAAA,EAAO,UAAA,EAAY,aAAA,EAAe,cAAa,GAAI,oBAAA,CAAqB,cAAA,EAAgB,QAAA,EAAU,QAAQ,CAAA;AAC/H,EAAA,MAAM,kBAAA,GAAqB,iBAAiB,UAAU,CAAA;AACtD,EAAA,MAAM,iBAAA,GAAoB,gBAAA,CAAiB,aAAA,EAAe,IAAA,IAAQ,EAAE,CAAA;AAOpE,EAAA,MAAM,sBAAA,GAAyB,gBAAA,CAAiB,aAAA,EAAe,cAAA,IAAkB,EAAE,CAAA;AACnF,EAAA,MAAM,aAAA,GAAgB,gBAAA,CAAiB,aAAA,EAAe,KAAA,IAAS,EAAE,CAAA;AACjE,EAAA,MAAM,iBAAA,GAAoB,gBAAA,CAAiB,aAAA,EAAe,SAAA,IAAa,EAAE,CAAA;AACzE,EAAA,MAAM,EAAC,OAAA,EAAS,aAAA,EAAe,MAAM,eAAA,EAAe,GAAI,eAAe,aAAa,CAAA;AACpF,EAAA,MAAM;AAAA,IACF,EAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAA;AAAA,IACA,SAAA,GAAY,IAAA;AAAA,IACZ,cAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,IACA,WA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A,MACA,UAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAA;AAAA,MACA,KAAA;AAAA,MACA,cAAA;AAAA,MACA,aAAA,EAAe,cAAA;AAAA,MACf,YAAA;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,GACL;AAER;;;;"}
|
|
@@ -98,9 +98,12 @@ var useThemedFont = require('../../../hooks/useThemedFont.cjs');
|
|
|
98
98
|
var SelectPopupOverlay_native = require('../helpers/SelectPopupOverlay.cjs');
|
|
99
99
|
|
|
100
100
|
const KitsMultiSelect = ({ className, ref, ...rawProps }) => {
|
|
101
|
-
const { mergedProps: props, themeStyle, elementStyles } = useComponentDefaults.default("MultiSelect", rawProps, "Select");
|
|
101
|
+
const { mergedProps: props, themeStyle, elementStyles, elementProps } = useComponentDefaults.default("MultiSelect", rawProps, "Select");
|
|
102
102
|
const resolvedThemeStyle = useResolvedStyle.default(themeStyle);
|
|
103
103
|
const resolvedRootStyle = useResolvedStyle.default(elementStyles?.root || {});
|
|
104
|
+
const resolvedToken = useResolvedStyle.default(elementStyles?.token || {});
|
|
105
|
+
const resolvedTokenIcon = useResolvedStyle.default(elementStyles?.tokenIcon || {});
|
|
106
|
+
const { wrapper: tokenBoxStyle, text: tokenLabelStyle } = useResolvedStyle.splitTextStyle(resolvedToken);
|
|
104
107
|
const {
|
|
105
108
|
id,
|
|
106
109
|
disabled,
|
|
@@ -167,6 +170,9 @@ const KitsMultiSelect = ({ className, ref, ...rawProps }) => {
|
|
|
167
170
|
maxSelectedLabels: selectionLimit ?? localProps?.maxSelectedLabels ?? 10,
|
|
168
171
|
className: `w-full ${ClState}`,
|
|
169
172
|
style: { borderRadius: 0, ...resolvedRootStyle && Object.keys(resolvedRootStyle).length > 0 ? resolvedRootStyle : resolvedThemeStyle },
|
|
173
|
+
tokenStyle: tokenBoxStyle,
|
|
174
|
+
tokenLabelStyle,
|
|
175
|
+
tokenIconStyle: resolvedTokenIcon,
|
|
170
176
|
...localProps ? localProps : {}
|
|
171
177
|
}
|
|
172
178
|
);
|
|
@@ -185,6 +191,7 @@ const KitsMultiSelect = ({ className, ref, ...rawProps }) => {
|
|
|
185
191
|
invalid,
|
|
186
192
|
label,
|
|
187
193
|
elementStyles,
|
|
194
|
+
elementProps,
|
|
188
195
|
children: Element
|
|
189
196
|
}
|
|
190
197
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../../src/form/selects/MultiSelect/index.native.tsx"],"sourcesContent":["import React, {useCallback, useEffect} from \"react\";\nimport {MultiSelect} from \"@lmb-it/kitsconcertomobile\";\nimport KitsContainer from \"../../helpers/FormContainer\";\nimport type {IMultiSelect} from \"@lmb-it/kitsconcerto-types\";\nimport {ClHelper} from \"../../helpers/Functions\";\nimport {checkKeys} from \"../helper\";\nimport {useSelectBase} from \"../hooks/useSelectBase\";\nimport {useComponentDefaults, useLanguage, useResolvedStyle} from \"@lmb-it/kitsconcerto/hooks\";\nimport SelectPopupOverlay from \"../helpers/SelectPopupOverlay\";\nimport useThemedFont from \"@lmb-it/kitsconcerto/hooks/useThemedFont\";\n\nconst KitsMultiSelect = ({ className, ref, ...rawProps }: IMultiSelect) => {\n const {mergedProps: props, themeStyle, elementStyles} = useComponentDefaults('MultiSelect', rawProps, 'Select');\n const resolvedThemeStyle = useResolvedStyle(themeStyle);\n const resolvedRootStyle = useResolvedStyle(elementStyles?.root || {});\n const {\n id,\n disabled,\n isFloatedLabel,\n rightAddon,\n leftAddon,\n required,\n errors,\n invalid,\n placeholder,\n virtualScroll,\n label,\n inputSize,\n helperText,\n emptyFilterMessage,\n selectionLimit,\n localProps,\n hideError,\n withFilter,\n loading,\n showClear,\n valueMode,\n popup,\n } = props;\n\n const { list, keys, onChange, selectedValue, childrenKey, labelKey, valueKey } = useSelectBase();\n\n /* Same rule as the Dropdown's panel — see that file. The sentence and the\n edge are resolved here, where LocaleContext is, and passed down. */\n const { t, isRTL } = useLanguage();\n const bodyFont = useThemedFont('body');\n\n useEffect(() => {\n checkKeys(list, labelKey, !childrenKey ? valueKey : undefined);\n }, [list]);\n\n const ClState = ClHelper({\n inputSize: inputSize ?? \"\",\n isChecked: false,\n isInvalid: !!invalid,\n isDisabled: !!disabled,\n });\n\n const handleChange = useCallback((e: any, items: any) => {\n if (selectionLimit && Array.isArray(e?.target?.value) && e.target.value.length > selectionLimit) {\n return;\n }\n onChange && onChange(e, items);\n }, [selectionLimit, onChange]);\n\n const Element = <MultiSelect\n emptyFilterMessage={emptyFilterMessage ?? t('emptyFilterMessage')}\n filterPlaceholder={t('searchPlaceholder')}\n isRTL={isRTL}\n fontFamily={bodyFont}\n popup={popup}\n popupTitle={label ?? placeholder}\n renderPopup={({visible, onClose, title, children}: {\n visible: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n children: React.ReactNode;\n }) => (\n <SelectPopupOverlay visible={visible} onClose={onClose} title={title}>\n {children}\n </SelectPopupOverlay>\n )}\n value={selectedValue}\n onChange={handleChange}\n disabled={disabled}\n loading={loading}\n showClear={showClear}\n options={typeof list !== \"function\" ? list : []}\n placeholder={placeholder}\n {...keys}\n filter={withFilter !== false}\n selectionLimit={selectionLimit}\n display={valueMode === \"comma\" ? \"comma\" : (localProps?.maxSelectedLabels ? undefined : \"chip\")}\n maxSelectedLabels={selectionLimit ?? localProps?.maxSelectedLabels ?? 10}\n className={`w-full ${ClState}`}\n style={{ borderRadius: 0, ...(resolvedRootStyle && Object.keys(resolvedRootStyle).length > 0 ? resolvedRootStyle : resolvedThemeStyle) }}\n {...(localProps ? localProps : {})}\n />\n\n return (\n <KitsContainer\n id={id}\n inputSize={inputSize}\n isFloatedLabel={isFloatedLabel}\n rightAddon={rightAddon}\n leftAddon={leftAddon}\n required={required}\n hideError={hideError}\n errors={errors}\n helperText={helperText}\n invalid={invalid}\n label={label}\n elementStyles={elementStyles}\n >\n {Element}\n </KitsContainer>\n );\n}\n\nKitsMultiSelect.displayName = \"MultiSelect\";\nexport default KitsMultiSelect;\n"],"names":["useComponentDefaults","useResolvedStyle","useSelectBase","useLanguage","useThemedFont","useEffect","checkKeys","ClHelper","useCallback","jsx","MultiSelect","SelectPopupOverlay","KitsContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/form/selects/MultiSelect/index.native.tsx"],"sourcesContent":["import React, {useCallback, useEffect} from \"react\";\nimport {MultiSelect} from \"@lmb-it/kitsconcertomobile\";\nimport KitsContainer from \"../../helpers/FormContainer\";\nimport type {IMultiSelect} from \"@lmb-it/kitsconcerto-types\";\nimport {ClHelper} from \"../../helpers/Functions\";\nimport {checkKeys} from \"../helper\";\nimport {useSelectBase} from \"../hooks/useSelectBase\";\nimport {useComponentDefaults, useLanguage, useResolvedStyle} from \"@lmb-it/kitsconcerto/hooks\";\nimport {splitTextStyle} from \"@lmb-it/kitsconcerto/hooks/useResolvedStyle\";\nimport SelectPopupOverlay from \"../helpers/SelectPopupOverlay\";\nimport useThemedFont from \"@lmb-it/kitsconcerto/hooks/useThemedFont\";\n\nconst KitsMultiSelect = ({ className, ref, ...rawProps }: IMultiSelect) => {\n const {mergedProps: props, themeStyle, elementStyles, elementProps} = useComponentDefaults('MultiSelect', rawProps, 'Select');\n const resolvedThemeStyle = useResolvedStyle(themeStyle);\n const resolvedRootStyle = useResolvedStyle(elementStyles?.root || {});\n /* Chip slots — the same `Select.token` / `Select.tokenIcon` the web build\n reads and the same the native Tags field reads. Split because a React\n Native `View` cannot carry `color` / `fontSize`. */\n const resolvedToken = useResolvedStyle(elementStyles?.token || {});\n const resolvedTokenIcon = useResolvedStyle(elementStyles?.tokenIcon || {});\n const {wrapper: tokenBoxStyle, text: tokenLabelStyle} = splitTextStyle(resolvedToken);\n const {\n id,\n disabled,\n isFloatedLabel,\n rightAddon,\n leftAddon,\n required,\n errors,\n invalid,\n placeholder,\n virtualScroll,\n label,\n inputSize,\n helperText,\n emptyFilterMessage,\n selectionLimit,\n localProps,\n hideError,\n withFilter,\n loading,\n showClear,\n valueMode,\n popup,\n } = props;\n\n const { list, keys, onChange, selectedValue, childrenKey, labelKey, valueKey } = useSelectBase();\n\n /* Same rule as the Dropdown's panel — see that file. The sentence and the\n edge are resolved here, where LocaleContext is, and passed down. */\n const { t, isRTL } = useLanguage();\n const bodyFont = useThemedFont('body');\n\n useEffect(() => {\n checkKeys(list, labelKey, !childrenKey ? valueKey : undefined);\n }, [list]);\n\n const ClState = ClHelper({\n inputSize: inputSize ?? \"\",\n isChecked: false,\n isInvalid: !!invalid,\n isDisabled: !!disabled,\n });\n\n const handleChange = useCallback((e: any, items: any) => {\n if (selectionLimit && Array.isArray(e?.target?.value) && e.target.value.length > selectionLimit) {\n return;\n }\n onChange && onChange(e, items);\n }, [selectionLimit, onChange]);\n\n const Element = <MultiSelect\n emptyFilterMessage={emptyFilterMessage ?? t('emptyFilterMessage')}\n filterPlaceholder={t('searchPlaceholder')}\n isRTL={isRTL}\n fontFamily={bodyFont}\n popup={popup}\n popupTitle={label ?? placeholder}\n renderPopup={({visible, onClose, title, children}: {\n visible: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n children: React.ReactNode;\n }) => (\n <SelectPopupOverlay visible={visible} onClose={onClose} title={title}>\n {children}\n </SelectPopupOverlay>\n )}\n value={selectedValue}\n onChange={handleChange}\n disabled={disabled}\n loading={loading}\n showClear={showClear}\n options={typeof list !== \"function\" ? list : []}\n placeholder={placeholder}\n {...keys}\n filter={withFilter !== false}\n selectionLimit={selectionLimit}\n display={valueMode === \"comma\" ? \"comma\" : (localProps?.maxSelectedLabels ? undefined : \"chip\")}\n maxSelectedLabels={selectionLimit ?? localProps?.maxSelectedLabels ?? 10}\n className={`w-full ${ClState}`}\n style={{ borderRadius: 0, ...(resolvedRootStyle && Object.keys(resolvedRootStyle).length > 0 ? resolvedRootStyle : resolvedThemeStyle) }}\n tokenStyle={tokenBoxStyle}\n tokenLabelStyle={tokenLabelStyle}\n tokenIconStyle={resolvedTokenIcon}\n {...(localProps ? localProps : {})}\n />\n\n return (\n <KitsContainer\n id={id}\n inputSize={inputSize}\n isFloatedLabel={isFloatedLabel}\n rightAddon={rightAddon}\n leftAddon={leftAddon}\n required={required}\n hideError={hideError}\n errors={errors}\n helperText={helperText}\n invalid={invalid}\n label={label}\n elementStyles={elementStyles}\n elementProps={elementProps}\n >\n {Element}\n </KitsContainer>\n );\n}\n\nKitsMultiSelect.displayName = \"MultiSelect\";\nexport default KitsMultiSelect;\n"],"names":["useComponentDefaults","useResolvedStyle","splitTextStyle","useSelectBase","useLanguage","useThemedFont","useEffect","checkKeys","ClHelper","useCallback","jsx","MultiSelect","SelectPopupOverlay","KitsContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,kBAAkB,CAAC,EAAE,WAAW,GAAA,EAAK,GAAG,UAAS,KAAoB;AACvE,EAAA,MAAM,EAAC,WAAA,EAAa,KAAA,EAAO,UAAA,EAAY,aAAA,EAAe,cAAY,GAAIA,4BAAA,CAAqB,aAAA,EAAe,QAAA,EAAU,QAAQ,CAAA;AAC5H,EAAA,MAAM,kBAAA,GAAqBC,yBAAiB,UAAU,CAAA;AACtD,EAAA,MAAM,iBAAA,GAAoBA,wBAAA,CAAiB,aAAA,EAAe,IAAA,IAAQ,EAAE,CAAA;AAIpE,EAAA,MAAM,aAAA,GAAgBA,wBAAA,CAAiB,aAAA,EAAe,KAAA,IAAS,EAAE,CAAA;AACjE,EAAA,MAAM,iBAAA,GAAoBA,wBAAA,CAAiB,aAAA,EAAe,SAAA,IAAa,EAAE,CAAA;AACzE,EAAA,MAAM,EAAC,OAAA,EAAS,aAAA,EAAe,MAAM,eAAA,EAAe,GAAIC,gCAAe,aAAa,CAAA;AACpF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GAAI,oBAAoB,kBAAA,EAAoB;AAAA,MACvI,UAAA,EAAY,aAAA;AAAA,MACZ,eAAA;AAAA,MACA,cAAA,EAAgB,iBAAA;AAAA,MACf,GAAI,UAAA,GAAa,UAAA,GAAa;AAAC;AAAA,GACpC;AAEA,EAAA,uBACIF,cAAA;AAAA,IAACG,oBAAA;AAAA,IAAA;AAAA,MACG,EAAA;AAAA,MACA,SAAA;AAAA,MACA,cAAA;AAAA,MACA,UAAA;AAAA,MACA,SAAA;AAAA,MACA,QAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,MACA,OAAA;AAAA,MACA,KAAA;AAAA,MACA,aAAA;AAAA,MACA,YAAA;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,GACL;AAER;AAEA,eAAA,CAAgB,WAAA,GAAc,aAAA;;;;"}
|
|
@@ -89,14 +89,17 @@ import '../../../contexts/DialogContext.js';
|
|
|
89
89
|
import '../../../contexts/PermissionsContext.js';
|
|
90
90
|
import '../../../contexts/BreadcrumbContext.js';
|
|
91
91
|
import useComponentDefaults from '../../../hooks/useComponentDefaults.js';
|
|
92
|
-
import useResolvedStyle from '../../../hooks/useResolvedStyle.js';
|
|
92
|
+
import useResolvedStyle, { splitTextStyle } from '../../../hooks/useResolvedStyle.js';
|
|
93
93
|
import useThemedFont from '../../../hooks/useThemedFont.js';
|
|
94
94
|
import SelectPopupOverlay from '../helpers/SelectPopupOverlay.js';
|
|
95
95
|
|
|
96
96
|
const KitsMultiSelect = ({ className, ref, ...rawProps }) => {
|
|
97
|
-
const { mergedProps: props, themeStyle, elementStyles } = useComponentDefaults("MultiSelect", rawProps, "Select");
|
|
97
|
+
const { mergedProps: props, themeStyle, elementStyles, elementProps } = useComponentDefaults("MultiSelect", rawProps, "Select");
|
|
98
98
|
const resolvedThemeStyle = useResolvedStyle(themeStyle);
|
|
99
99
|
const resolvedRootStyle = useResolvedStyle(elementStyles?.root || {});
|
|
100
|
+
const resolvedToken = useResolvedStyle(elementStyles?.token || {});
|
|
101
|
+
const resolvedTokenIcon = useResolvedStyle(elementStyles?.tokenIcon || {});
|
|
102
|
+
const { wrapper: tokenBoxStyle, text: tokenLabelStyle } = splitTextStyle(resolvedToken);
|
|
100
103
|
const {
|
|
101
104
|
id,
|
|
102
105
|
disabled,
|
|
@@ -163,6 +166,9 @@ const KitsMultiSelect = ({ className, ref, ...rawProps }) => {
|
|
|
163
166
|
maxSelectedLabels: selectionLimit ?? localProps?.maxSelectedLabels ?? 10,
|
|
164
167
|
className: `w-full ${ClState}`,
|
|
165
168
|
style: { borderRadius: 0, ...resolvedRootStyle && Object.keys(resolvedRootStyle).length > 0 ? resolvedRootStyle : resolvedThemeStyle },
|
|
169
|
+
tokenStyle: tokenBoxStyle,
|
|
170
|
+
tokenLabelStyle,
|
|
171
|
+
tokenIconStyle: resolvedTokenIcon,
|
|
166
172
|
...localProps ? localProps : {}
|
|
167
173
|
}
|
|
168
174
|
);
|
|
@@ -181,6 +187,7 @@ const KitsMultiSelect = ({ className, ref, ...rawProps }) => {
|
|
|
181
187
|
invalid,
|
|
182
188
|
label,
|
|
183
189
|
elementStyles,
|
|
190
|
+
elementProps,
|
|
184
191
|
children: Element
|
|
185
192
|
}
|
|
186
193
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/form/selects/MultiSelect/index.native.tsx"],"sourcesContent":["import React, {useCallback, useEffect} from \"react\";\nimport {MultiSelect} from \"@lmb-it/kitsconcertomobile\";\nimport KitsContainer from \"../../helpers/FormContainer\";\nimport type {IMultiSelect} from \"@lmb-it/kitsconcerto-types\";\nimport {ClHelper} from \"../../helpers/Functions\";\nimport {checkKeys} from \"../helper\";\nimport {useSelectBase} from \"../hooks/useSelectBase\";\nimport {useComponentDefaults, useLanguage, useResolvedStyle} from \"@lmb-it/kitsconcerto/hooks\";\nimport SelectPopupOverlay from \"../helpers/SelectPopupOverlay\";\nimport useThemedFont from \"@lmb-it/kitsconcerto/hooks/useThemedFont\";\n\nconst KitsMultiSelect = ({ className, ref, ...rawProps }: IMultiSelect) => {\n const {mergedProps: props, themeStyle, elementStyles} = useComponentDefaults('MultiSelect', rawProps, 'Select');\n const resolvedThemeStyle = useResolvedStyle(themeStyle);\n const resolvedRootStyle = useResolvedStyle(elementStyles?.root || {});\n const {\n id,\n disabled,\n isFloatedLabel,\n rightAddon,\n leftAddon,\n required,\n errors,\n invalid,\n placeholder,\n virtualScroll,\n label,\n inputSize,\n helperText,\n emptyFilterMessage,\n selectionLimit,\n localProps,\n hideError,\n withFilter,\n loading,\n showClear,\n valueMode,\n popup,\n } = props;\n\n const { list, keys, onChange, selectedValue, childrenKey, labelKey, valueKey } = useSelectBase();\n\n /* Same rule as the Dropdown's panel — see that file. The sentence and the\n edge are resolved here, where LocaleContext is, and passed down. */\n const { t, isRTL } = useLanguage();\n const bodyFont = useThemedFont('body');\n\n useEffect(() => {\n checkKeys(list, labelKey, !childrenKey ? valueKey : undefined);\n }, [list]);\n\n const ClState = ClHelper({\n inputSize: inputSize ?? \"\",\n isChecked: false,\n isInvalid: !!invalid,\n isDisabled: !!disabled,\n });\n\n const handleChange = useCallback((e: any, items: any) => {\n if (selectionLimit && Array.isArray(e?.target?.value) && e.target.value.length > selectionLimit) {\n return;\n }\n onChange && onChange(e, items);\n }, [selectionLimit, onChange]);\n\n const Element = <MultiSelect\n emptyFilterMessage={emptyFilterMessage ?? t('emptyFilterMessage')}\n filterPlaceholder={t('searchPlaceholder')}\n isRTL={isRTL}\n fontFamily={bodyFont}\n popup={popup}\n popupTitle={label ?? placeholder}\n renderPopup={({visible, onClose, title, children}: {\n visible: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n children: React.ReactNode;\n }) => (\n <SelectPopupOverlay visible={visible} onClose={onClose} title={title}>\n {children}\n </SelectPopupOverlay>\n )}\n value={selectedValue}\n onChange={handleChange}\n disabled={disabled}\n loading={loading}\n showClear={showClear}\n options={typeof list !== \"function\" ? list : []}\n placeholder={placeholder}\n {...keys}\n filter={withFilter !== false}\n selectionLimit={selectionLimit}\n display={valueMode === \"comma\" ? \"comma\" : (localProps?.maxSelectedLabels ? undefined : \"chip\")}\n maxSelectedLabels={selectionLimit ?? localProps?.maxSelectedLabels ?? 10}\n className={`w-full ${ClState}`}\n style={{ borderRadius: 0, ...(resolvedRootStyle && Object.keys(resolvedRootStyle).length > 0 ? resolvedRootStyle : resolvedThemeStyle) }}\n {...(localProps ? localProps : {})}\n />\n\n return (\n <KitsContainer\n id={id}\n inputSize={inputSize}\n isFloatedLabel={isFloatedLabel}\n rightAddon={rightAddon}\n leftAddon={leftAddon}\n required={required}\n hideError={hideError}\n errors={errors}\n helperText={helperText}\n invalid={invalid}\n label={label}\n elementStyles={elementStyles}\n >\n {Element}\n </KitsContainer>\n );\n}\n\nKitsMultiSelect.displayName = \"MultiSelect\";\nexport default KitsMultiSelect;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/form/selects/MultiSelect/index.native.tsx"],"sourcesContent":["import React, {useCallback, useEffect} from \"react\";\nimport {MultiSelect} from \"@lmb-it/kitsconcertomobile\";\nimport KitsContainer from \"../../helpers/FormContainer\";\nimport type {IMultiSelect} from \"@lmb-it/kitsconcerto-types\";\nimport {ClHelper} from \"../../helpers/Functions\";\nimport {checkKeys} from \"../helper\";\nimport {useSelectBase} from \"../hooks/useSelectBase\";\nimport {useComponentDefaults, useLanguage, useResolvedStyle} from \"@lmb-it/kitsconcerto/hooks\";\nimport {splitTextStyle} from \"@lmb-it/kitsconcerto/hooks/useResolvedStyle\";\nimport SelectPopupOverlay from \"../helpers/SelectPopupOverlay\";\nimport useThemedFont from \"@lmb-it/kitsconcerto/hooks/useThemedFont\";\n\nconst KitsMultiSelect = ({ className, ref, ...rawProps }: IMultiSelect) => {\n const {mergedProps: props, themeStyle, elementStyles, elementProps} = useComponentDefaults('MultiSelect', rawProps, 'Select');\n const resolvedThemeStyle = useResolvedStyle(themeStyle);\n const resolvedRootStyle = useResolvedStyle(elementStyles?.root || {});\n /* Chip slots — the same `Select.token` / `Select.tokenIcon` the web build\n reads and the same the native Tags field reads. Split because a React\n Native `View` cannot carry `color` / `fontSize`. */\n const resolvedToken = useResolvedStyle(elementStyles?.token || {});\n const resolvedTokenIcon = useResolvedStyle(elementStyles?.tokenIcon || {});\n const {wrapper: tokenBoxStyle, text: tokenLabelStyle} = splitTextStyle(resolvedToken);\n const {\n id,\n disabled,\n isFloatedLabel,\n rightAddon,\n leftAddon,\n required,\n errors,\n invalid,\n placeholder,\n virtualScroll,\n label,\n inputSize,\n helperText,\n emptyFilterMessage,\n selectionLimit,\n localProps,\n hideError,\n withFilter,\n loading,\n showClear,\n valueMode,\n popup,\n } = props;\n\n const { list, keys, onChange, selectedValue, childrenKey, labelKey, valueKey } = useSelectBase();\n\n /* Same rule as the Dropdown's panel — see that file. The sentence and the\n edge are resolved here, where LocaleContext is, and passed down. */\n const { t, isRTL } = useLanguage();\n const bodyFont = useThemedFont('body');\n\n useEffect(() => {\n checkKeys(list, labelKey, !childrenKey ? valueKey : undefined);\n }, [list]);\n\n const ClState = ClHelper({\n inputSize: inputSize ?? \"\",\n isChecked: false,\n isInvalid: !!invalid,\n isDisabled: !!disabled,\n });\n\n const handleChange = useCallback((e: any, items: any) => {\n if (selectionLimit && Array.isArray(e?.target?.value) && e.target.value.length > selectionLimit) {\n return;\n }\n onChange && onChange(e, items);\n }, [selectionLimit, onChange]);\n\n const Element = <MultiSelect\n emptyFilterMessage={emptyFilterMessage ?? t('emptyFilterMessage')}\n filterPlaceholder={t('searchPlaceholder')}\n isRTL={isRTL}\n fontFamily={bodyFont}\n popup={popup}\n popupTitle={label ?? placeholder}\n renderPopup={({visible, onClose, title, children}: {\n visible: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n children: React.ReactNode;\n }) => (\n <SelectPopupOverlay visible={visible} onClose={onClose} title={title}>\n {children}\n </SelectPopupOverlay>\n )}\n value={selectedValue}\n onChange={handleChange}\n disabled={disabled}\n loading={loading}\n showClear={showClear}\n options={typeof list !== \"function\" ? list : []}\n placeholder={placeholder}\n {...keys}\n filter={withFilter !== false}\n selectionLimit={selectionLimit}\n display={valueMode === \"comma\" ? \"comma\" : (localProps?.maxSelectedLabels ? undefined : \"chip\")}\n maxSelectedLabels={selectionLimit ?? localProps?.maxSelectedLabels ?? 10}\n className={`w-full ${ClState}`}\n style={{ borderRadius: 0, ...(resolvedRootStyle && Object.keys(resolvedRootStyle).length > 0 ? resolvedRootStyle : resolvedThemeStyle) }}\n tokenStyle={tokenBoxStyle}\n tokenLabelStyle={tokenLabelStyle}\n tokenIconStyle={resolvedTokenIcon}\n {...(localProps ? localProps : {})}\n />\n\n return (\n <KitsContainer\n id={id}\n inputSize={inputSize}\n isFloatedLabel={isFloatedLabel}\n rightAddon={rightAddon}\n leftAddon={leftAddon}\n required={required}\n hideError={hideError}\n errors={errors}\n helperText={helperText}\n invalid={invalid}\n label={label}\n elementStyles={elementStyles}\n elementProps={elementProps}\n >\n {Element}\n </KitsContainer>\n );\n}\n\nKitsMultiSelect.displayName = \"MultiSelect\";\nexport default KitsMultiSelect;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,kBAAkB,CAAC,EAAE,WAAW,GAAA,EAAK,GAAG,UAAS,KAAoB;AACvE,EAAA,MAAM,EAAC,WAAA,EAAa,KAAA,EAAO,UAAA,EAAY,aAAA,EAAe,cAAY,GAAI,oBAAA,CAAqB,aAAA,EAAe,QAAA,EAAU,QAAQ,CAAA;AAC5H,EAAA,MAAM,kBAAA,GAAqB,iBAAiB,UAAU,CAAA;AACtD,EA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AA,GAAU,OAAA,GAAW,UAAA,EAAY,oBAAoB,MAAA,GAAY,MAAA;AAAA,MACxF,iBAAA,EAAmB,cAAA,IAAkB,UAAA,EAAY,iBAAA,IAAqB,EAAA;AAAA,MACtE,SAAA,EAAW,UAAU,OAAO,CAAA,CAAA;AAAA,MAC5B,KAAA,EAAO,EAAE,YAAA,EAAc,CAAA,EAAG,GAAI,iBAAA,IAAqB,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,CAAE,MAAA,GAAS,CAAA,GAAI,oBAAoB,kBAAA,EAAoB;AAAA,MACvI,UAAA,EAAY,aAAA;AAAA,MACZ,eAAA;AAAA,MACA,cAAA,EAAgB,iBAAA;AAAA,MACf,GAAI,UAAA,GAAa,UAAA,GAAa;AAAC;AAAA,GACpC;AAEA,EAAA,uBACI,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACG,EAAA;AAAA,MACA,SAAA;AAAA,MACA,cAAA;AAAA,MACA,UAAA;AAAA,MACA,SAAA;AAAA,MACA,QAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,UAAA;AAAA,MACA,OAAA;AAAA,MACA,KAAA;AAAA,MACA,aAAA;AAAA,MACA,YAAA;AAAA,MAEC,QAAA,EAAA;AAAA;AAAA,GACL;AAER;AAEA,eAAA,CAAgB,WAAA,GAAc,aAAA;;;;"}
|
|
@@ -27,9 +27,14 @@ const ELEMENT_SLOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
27
27
|
"itemHover",
|
|
28
28
|
"itemDisabled",
|
|
29
29
|
"itemInvalid",
|
|
30
|
-
//
|
|
30
|
+
// Chip-bearing selects (IChipInputSlots — MultiSelect display="chip"
|
|
31
|
+
// AND AutoComplete/Tags with isMultiple). `tokenContainer` is the
|
|
32
|
+
// bordered box that holds the chips and the caret — see the docblock
|
|
33
|
+
// on IChipInputSlots for why it is neither `root` nor `container`.
|
|
34
|
+
"tokenContainer",
|
|
31
35
|
"token",
|
|
32
36
|
"tokenIcon",
|
|
37
|
+
// MultiSelect specific (IMultiSelectSlots — per-item checkbox)
|
|
33
38
|
"checkboxBox",
|
|
34
39
|
"checkboxBoxChecked",
|
|
35
40
|
"checkboxIcon",
|
|
@@ -131,6 +136,18 @@ const ELEMENT_SLOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
131
136
|
"topBar",
|
|
132
137
|
"bulkBar",
|
|
133
138
|
"bulkBarText",
|
|
139
|
+
// ImageCropper (IImageCropperSlots). The other slots it uses — root,
|
|
140
|
+
// container, header, title, content, footer, icon, text, mask, track,
|
|
141
|
+
// thumb — are already in this set under the components that named them
|
|
142
|
+
// first, which is the point of reusing those names.
|
|
143
|
+
"cropWindow",
|
|
144
|
+
"shade",
|
|
145
|
+
"gridLine",
|
|
146
|
+
"handle",
|
|
147
|
+
"zoomChip",
|
|
148
|
+
"previewFrame",
|
|
149
|
+
"dropZone",
|
|
150
|
+
"progressFill",
|
|
134
151
|
// Accordion
|
|
135
152
|
"headerActive",
|
|
136
153
|
"headerHover",
|
|
@@ -147,6 +164,25 @@ const ELEMENT_SLOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
147
164
|
"avatarButton",
|
|
148
165
|
"breadcrumb"
|
|
149
166
|
]);
|
|
167
|
+
function mergeSlotProps(layers) {
|
|
168
|
+
const out = {};
|
|
169
|
+
const classes = [];
|
|
170
|
+
for (const layer of layers) {
|
|
171
|
+
if (!layer) continue;
|
|
172
|
+
for (const [key, value] of Object.entries(layer)) {
|
|
173
|
+
if (value === void 0) continue;
|
|
174
|
+
if (key === "className") {
|
|
175
|
+
if (value) classes.push(String(value));
|
|
176
|
+
} else {
|
|
177
|
+
out[key] = value;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (classes.length) {
|
|
182
|
+
out.className = Array.from(new Set(classes.join(" ").split(/\s+/).filter(Boolean))).join(" ");
|
|
183
|
+
}
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
150
186
|
function useComponentDefaults(componentName, props, baseGroup) {
|
|
151
187
|
const { theme } = KitsThemeProvider_native.useKitsTheme();
|
|
152
188
|
const formElementConfig = theme.components.FormElement;
|
|
@@ -155,23 +191,31 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
155
191
|
return React.useMemo(() => {
|
|
156
192
|
const instanceSlots = props.slots;
|
|
157
193
|
if (!config && !baseConfig && !instanceSlots && !formElementConfig) {
|
|
158
|
-
return { mergedProps: props, themeStyle: {}, elementStyles: {}, elementConfigs: {} };
|
|
194
|
+
return { mergedProps: props, themeStyle: {}, elementStyles: {}, elementProps: {}, elementConfigs: {} };
|
|
159
195
|
}
|
|
160
196
|
const formBase = formElementConfig || {};
|
|
161
197
|
const base = baseConfig || {};
|
|
162
198
|
const comp = config || {};
|
|
163
|
-
const merged =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
199
|
+
const merged = mergeSlotProps([
|
|
200
|
+
formBase.root?.props,
|
|
201
|
+
base.root?.props,
|
|
202
|
+
comp.root?.props,
|
|
203
|
+
instanceSlots?.root?.props
|
|
204
|
+
]);
|
|
205
|
+
const userClassName = typeof props.className === "string" ? props.className : void 0;
|
|
169
206
|
for (const key of Object.keys(props)) {
|
|
170
207
|
if (key === "slots") continue;
|
|
208
|
+
if (key === "className") continue;
|
|
171
209
|
if (props[key] !== void 0) {
|
|
172
210
|
merged[key] = props[key];
|
|
173
211
|
}
|
|
174
212
|
}
|
|
213
|
+
if (userClassName || merged.className) {
|
|
214
|
+
merged.className = mergeSlotProps([
|
|
215
|
+
{ className: merged.className },
|
|
216
|
+
{ className: userClassName }
|
|
217
|
+
]).className;
|
|
218
|
+
}
|
|
175
219
|
const allSlotKeys = /* @__PURE__ */ new Set();
|
|
176
220
|
for (const key of Object.keys(formBase)) {
|
|
177
221
|
if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);
|
|
@@ -188,6 +232,7 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
188
232
|
}
|
|
189
233
|
}
|
|
190
234
|
const elementStyles = {};
|
|
235
|
+
const elementProps = {};
|
|
191
236
|
const elementConfigs = {};
|
|
192
237
|
for (const slotKey of allSlotKeys) {
|
|
193
238
|
const style = {
|
|
@@ -197,6 +242,13 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
197
242
|
...instanceSlots?.[slotKey]?.style || {}
|
|
198
243
|
};
|
|
199
244
|
elementStyles[slotKey] = style;
|
|
245
|
+
const slotProps = mergeSlotProps([
|
|
246
|
+
formBase[slotKey]?.props,
|
|
247
|
+
base[slotKey]?.props,
|
|
248
|
+
comp[slotKey]?.props,
|
|
249
|
+
instanceSlots?.[slotKey]?.props
|
|
250
|
+
]);
|
|
251
|
+
elementProps[slotKey] = slotProps;
|
|
200
252
|
const pseudoMerged = {
|
|
201
253
|
...formBase[slotKey]?.pseudo || {},
|
|
202
254
|
...base[slotKey]?.pseudo || {},
|
|
@@ -205,6 +257,7 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
205
257
|
};
|
|
206
258
|
elementConfigs[slotKey] = {
|
|
207
259
|
style,
|
|
260
|
+
props: slotProps,
|
|
208
261
|
important: instanceSlots?.[slotKey]?.important ?? comp[slotKey]?.important ?? base[slotKey]?.important ?? formBase[slotKey]?.important,
|
|
209
262
|
pseudo: Object.keys(pseudoMerged).length > 0 ? pseudoMerged : void 0
|
|
210
263
|
};
|
|
@@ -214,6 +267,7 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
214
267
|
mergedProps: merged,
|
|
215
268
|
themeStyle,
|
|
216
269
|
elementStyles,
|
|
270
|
+
elementProps,
|
|
217
271
|
elementConfigs
|
|
218
272
|
};
|
|
219
273
|
}, [formElementConfig, baseConfig, config, props]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponentDefaults.cjs","sources":["../../../src/hooks/useComponentDefaults.ts"],"sourcesContent":["import {useMemo} from 'react';\nimport {useKitsTheme} from '../contexts/Theme';\n\n/**\n * Known element slot keys. When a config key matches one of these\n * AND the value has `props` or `style`, it is treated as an element slot.\n *\n * To add a new slot: add the key here AND to the relevant slot interface\n * in packages/types/src/Theme/types.ts (and to the `AllSlotKeys` union).\n *\n * The order below mirrors the typed slot hierarchy in\n * `packages/types/src/Theme/types.ts`.\n */\nconst ELEMENT_SLOT_KEYS = new Set([\n // ── Form-element slots ──────────────────────────────────\n // Base (all form elements — IFormElementBaseSlots)\n 'label', 'helperText', 'error',\n // Text input specific (ITextInputSlots — also shared by ISelectSlots)\n 'root', 'container', 'inputGroup', 'leftAddon', 'rightAddon',\n // Select specific (ISelectSlots — option-list popover)\n // Radio / Checkbox also use `item` / `itemSelected` / `itemDisabled` /\n // `itemHover` for the per-list-item wrapper, plus `itemInvalid`.\n 'panel', 'item', 'itemSelected', 'itemFocused', 'itemHover', 'itemDisabled', 'itemInvalid',\n // MultiSelect specific (IMultiSelectSlots — chips + per-item checkbox)\n 'token', 'tokenIcon',\n 'checkboxBox', 'checkboxBoxChecked', 'checkboxIcon',\n // Datepicker specific (IDatepickerSlots — calendar popup; `panel` shared with Select)\n 'calendarHeader', 'calendarNavButton', 'weekDay',\n 'dayCell', 'daySelected', 'dayToday', 'dayDisabled',\n // Switch specific (ISwitchSlots) — RENAMED from slider/sliderChecked/thumbChecked\n 'track', 'trackOn', 'thumb', 'thumbOn',\n // Checkbox specific (ICheckboxSlots)\n 'box', 'boxChecked', 'checkIcon',\n // Radio specific (IRadioSlots)\n 'circle', 'circleInner',\n // Radio + Checkbox: wrapper Flex around all list items\n 'itemsContainer',\n\n // ── Non-form component slots (untouched by the form-element refactor) ──\n // Card / Button / generic\n 'icon', 'header', 'title', 'subTitle', 'content', 'footer',\n // Button variants — `text` applies only to buttons with a label,\n // `iconOnly` applies only to icon-only buttons (so styling one never\n // affects the other).\n 'text', 'iconOnly',\n // Table\n 'th', 'headerRow', 'headerCell', 'body', 'bodyRow', 'bodyCell',\n 'wrapper', 'table', 'tbody',\n 'filterRow', 'filterCell', 'filterClearButton',\n 'columnFilter', 'columnFilterInput',\n 'tfoot', 'footerRow', 'footerCell', 'footer', 'paginator', 'emptyMessage',\n 'loadingOverlay', 'loadingIcon',\n 'rowGroupHeader', 'rowGroupHeaderName', 'rowExpansion', 'rowGroupFooter',\n 'rowGroupToggler', 'rowGroupTogglerIcon',\n 'resizeHelper',\n 'reorderIndicatorUp', 'reorderIndicatorUpIcon',\n 'reorderIndicatorDown', 'reorderIndicatorDownIcon',\n 'tableHeader', 'searchInput',\n 'paginatorPageButton', 'paginatorPageLink', 'paginatorActivePageButton',\n 'paginatorPageReport', 'paginatorRowsPerPage', 'paginatorRowsPerPageDropdown',\n 'paginatorPages',\n 'sortedColumn', 'stripedRow', 'selectedRow', 'selectedRowAccent',\n 'filterBar', 'filterInput', 'filterLabel',\n 'toolbarRight', 'toolbarButton', 'clearFilterButton', 'columnPicker',\n // Toolbar sizing + placeholder, and the chrome the table renders itself.\n // NOTE: a slot missing from this allowlist is silently dropped — theming\n // it has no effect at all — so every new slot must be listed here as\n // well as in its component's ITableElementSlots.\n 'toolbarControl', 'filterPlaceholder',\n 'topBar', 'bulkBar', 'bulkBarText',\n // Accordion\n 'headerActive', 'headerHover',\n // Sidebar/Drawer\n 'headerTitle', 'closeButton', 'mask',\n // Group (repeatable field array)\n 'row', 'addButton', 'removeButton',\n // Header (app-shell top bar)\n 'toggleModeButton', 'avatarButton', 'breadcrumb',\n]);\n\nexport interface IElementConfig {\n style: Record<string, any>;\n important?: boolean | string[];\n pseudo?: Record<string, Record<string, any>>;\n}\n\nexport interface UseComponentDefaultsResult<T> {\n /** Props with theme defaults merged in (user props always win) */\n mergedProps: T;\n /**\n * CSS style from root slot — backwards compat for components\n * that read themeStyle instead of elementStyles.root\n */\n themeStyle: Record<string, any>;\n /**\n * Per-element style maps. Each key is a slot name, value is the\n * merged IStyleClasses (not yet resolved to CSSProperties).\n * Use `useResolvedElementStyles(elementStyles)` to resolve.\n */\n elementStyles: Record<string, Record<string, any>>;\n /**\n * Full slot configs including `important` and `pseudo` fields.\n * Use this instead of `elementStyles` when you need those fields.\n */\n elementConfigs: Record<string, IElementConfig>;\n}\n\n/**\n * Merges theme-level component defaults with user-supplied props.\n *\n * Resolution chain (lowest → highest priority):\n * FormElement[slot] < baseGroup[slot] < component[slot] < instanceSlots[slot] < user props\n *\n * `FormElement` is the global base group for every form element\n * (label / helperText / error live there by default). It is applied\n * to every component regardless of whether a `baseGroup` is provided\n * — for non-form components like Button or Card, FormElement slots\n * are no-ops in practice because those components don't read\n * `elementStyles.label` / `helperText` / `error`.\n *\n * Element slots (`root`, `label`, `container`, etc.) are direct keys\n * on the component config. Each slot accepts `{ props?, style? }`.\n *\n * The `root` slot's `props` are merged into `mergedProps` alongside\n * user props (user always wins). The `root` slot's `style` is returned\n * as both `themeStyle` (backwards compat) and `elementStyles.root`.\n *\n * Supports base-group inheritance: e.g. `useComponentDefaults('InputText', rawProps, 'Input')`\n * merges FormElement first, then Input base, then InputText overrides,\n * then per-instance slots, then user props.\n *\n * @example\n * const { mergedProps, themeStyle, elementStyles } = useComponentDefaults('InputText', rawProps, 'Input');\n * // mergedProps → FormElement.root.props < Input.root.props < InputText.root.props < instanceSlots < user props\n * // elementStyles.label → FormElement.label.style < Input.label.style < InputText.label.style < instance label\n * // elementStyles.root → root element style (FormElement → Input → InputText → instance)\n * // elementStyles.container → container element style\n */\nexport default function useComponentDefaults<T extends Record<string, any>>(\n componentName: string,\n props: T,\n baseGroup?: string,\n): UseComponentDefaultsResult<T> {\n const {theme} = useKitsTheme();\n // Global base for every form element. Always looked up — if not\n // configured it is `undefined` and the merge contributes nothing.\n const formElementConfig = theme.components.FormElement;\n const baseConfig = baseGroup ? theme.components[baseGroup] : undefined;\n const config = theme.components[componentName];\n\n return useMemo(() => {\n // Extract per-instance slot overrides from props (IFormElement.slots passed through)\n const instanceSlots = (props as any).slots as Record<string, { props?: any; style?: any; important?: boolean | string[]; pseudo?: Record<string, Record<string, any>> }> | undefined;\n\n if (!config && !baseConfig && !instanceSlots && !formElementConfig) {\n return {mergedProps: props, themeStyle: {}, elementStyles: {}, elementConfigs: {}};\n }\n\n const formBase = (formElementConfig || {}) as Record<string, any>;\n const base = (baseConfig || {}) as Record<string, any>;\n const comp = (config || {}) as Record<string, any>;\n\n // --- Props merge: FormElement.root.props < base.root.props < config.root.props < instanceSlots.root.props < user props ---\n const merged = {\n ...(formBase.root?.props || {}),\n ...(base.root?.props || {}),\n ...(comp.root?.props || {}),\n ...(instanceSlots?.root?.props || {}),\n } as Record<string, any>;\n\n for (const key of Object.keys(props)) {\n // Skip 'slots' — it is consumed here, not forwarded\n if (key === 'slots') continue;\n if (props[key] !== undefined) {\n merged[key] = props[key];\n }\n }\n\n // --- Element styles merge: FormElement[slot] < base[slot] < config[slot] < instanceSlots[slot] ---\n const allSlotKeys = new Set<string>();\n for (const key of Object.keys(formBase)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n for (const key of Object.keys(base)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n for (const key of Object.keys(comp)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n if (instanceSlots) {\n for (const key of Object.keys(instanceSlots)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n }\n\n const elementStyles: Record<string, Record<string, any>> = {};\n const elementConfigs: Record<string, IElementConfig> = {};\n for (const slotKey of allSlotKeys) {\n const style = {\n ...(formBase[slotKey]?.style || {}),\n ...(base[slotKey]?.style || {}),\n ...(comp[slotKey]?.style || {}),\n ...(instanceSlots?.[slotKey]?.style || {}),\n };\n elementStyles[slotKey] = style;\n\n const pseudoMerged = {\n ...(formBase[slotKey]?.pseudo || {}),\n ...(base[slotKey]?.pseudo || {}),\n ...(comp[slotKey]?.pseudo || {}),\n ...(instanceSlots?.[slotKey]?.pseudo || {}),\n };\n elementConfigs[slotKey] = {\n style,\n important:\n instanceSlots?.[slotKey]?.important ??\n comp[slotKey]?.important ??\n base[slotKey]?.important ??\n formBase[slotKey]?.important,\n pseudo: Object.keys(pseudoMerged).length > 0 ? pseudoMerged : undefined,\n };\n }\n\n // themeStyle = root element style (backwards compat)\n const themeStyle = elementStyles.root || {};\n\n return {\n mergedProps: merged as T,\n themeStyle,\n elementStyles,\n elementConfigs,\n };\n }, [formElementConfig, baseConfig, config, props]);\n}\n"],"names":["useKitsTheme","useMemo"],"mappings":";;;;;;;AAaA,MAAM,iBAAA,uBAAwB,GAAA,CAAI;AAAA;AAAA;AAAA,EAG9B,OAAA;AAAA,EAAS,YAAA;AAAA,EAAc,OAAA;AAAA;AAAA,EAEvB,MAAA;AAAA,EAAQ,WAAA;AAAA,EAAa,YAAA;AAAA,EAAc,WAAA;AAAA,EAAa,YAAA;AAAA;AAAA;AAAA;AAAA,EAIhD,OAAA;AAAA,EAAS,MAAA;AAAA,EAAQ,cAAA;AAAA,EAAgB,aAAA;AAAA,EAAe,WAAA;AAAA,EAAa,cAAA;AAAA,EAAgB,aAAA;AAAA;AAAA,EAE7E,OAAA;AAAA,EAAS,WAAA;AAAA,EACT,aAAA;AAAA,EAAe,oBAAA;AAAA,EAAsB,cAAA;AAAA;AAAA,EAErC,gBAAA;AAAA,EAAkB,mBAAA;AAAA,EAAqB,SAAA;AAAA,EACvC,SAAA;AAAA,EAAW,aAAA;AAAA,EAAe,UAAA;AAAA,EAAY,aAAA;AAAA;AAAA,EAEtC,OAAA;AAAA,EAAS,SAAA;AAAA,EAAW,OAAA;AAAA,EAAS,SAAA;AAAA;AAAA,EAE7B,KAAA;AAAA,EAAO,YAAA;AAAA,EAAc,WAAA;AAAA;AAAA,EAErB,QAAA;AAAA,EAAU,aAAA;AAAA;AAAA,EAEV,gBAAA;AAAA;AAAA;AAAA,EAIA,MAAA;AAAA,EAAQ,QAAA;AAAA,EAAU,OAAA;AAAA,EAAS,UAAA;AAAA,EAAY,SAAA;AAAA,EAAW,QAAA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efaults.ts"],"sourcesContent":["import {useMemo} from 'react';\nimport {useKitsTheme} from '../contexts/Theme';\n\n/**\n * Known element slot keys. When a config key matches one of these\n * AND the value has `props` or `style`, it is treated as an element slot.\n *\n * To add a new slot: add the key here AND to the relevant slot interface\n * in packages/types/src/Theme/types.ts (and to the `AllSlotKeys` union).\n *\n * The order below mirrors the typed slot hierarchy in\n * `packages/types/src/Theme/types.ts`.\n */\nconst ELEMENT_SLOT_KEYS = new Set([\n // ── Form-element slots ──────────────────────────────────\n // Base (all form elements — IFormElementBaseSlots)\n 'label', 'helperText', 'error',\n // Text input specific (ITextInputSlots — also shared by ISelectSlots)\n 'root', 'container', 'inputGroup', 'leftAddon', 'rightAddon',\n // Select specific (ISelectSlots — option-list popover)\n // Radio / Checkbox also use `item` / `itemSelected` / `itemDisabled` /\n // `itemHover` for the per-list-item wrapper, plus `itemInvalid`.\n 'panel', 'item', 'itemSelected', 'itemFocused', 'itemHover', 'itemDisabled', 'itemInvalid',\n // Chip-bearing selects (IChipInputSlots — MultiSelect display=\"chip\"\n // AND AutoComplete/Tags with isMultiple). `tokenContainer` is the\n // bordered box that holds the chips and the caret — see the docblock\n // on IChipInputSlots for why it is neither `root` nor `container`.\n 'tokenContainer', 'token', 'tokenIcon',\n // MultiSelect specific (IMultiSelectSlots — per-item checkbox)\n 'checkboxBox', 'checkboxBoxChecked', 'checkboxIcon',\n // Datepicker specific (IDatepickerSlots — calendar popup; `panel` shared with Select)\n 'calendarHeader', 'calendarNavButton', 'weekDay',\n 'dayCell', 'daySelected', 'dayToday', 'dayDisabled',\n // Switch specific (ISwitchSlots) — RENAMED from slider/sliderChecked/thumbChecked\n 'track', 'trackOn', 'thumb', 'thumbOn',\n // Checkbox specific (ICheckboxSlots)\n 'box', 'boxChecked', 'checkIcon',\n // Radio specific (IRadioSlots)\n 'circle', 'circleInner',\n // Radio + Checkbox: wrapper Flex around all list items\n 'itemsContainer',\n\n // ── Non-form component slots (untouched by the form-element refactor) ──\n // Card / Button / generic\n 'icon', 'header', 'title', 'subTitle', 'content', 'footer',\n // Button variants — `text` applies only to buttons with a label,\n // `iconOnly` applies only to icon-only buttons (so styling one never\n // affects the other).\n 'text', 'iconOnly',\n // Table\n 'th', 'headerRow', 'headerCell', 'body', 'bodyRow', 'bodyCell',\n 'wrapper', 'table', 'tbody',\n 'filterRow', 'filterCell', 'filterClearButton',\n 'columnFilter', 'columnFilterInput',\n 'tfoot', 'footerRow', 'footerCell', 'footer', 'paginator', 'emptyMessage',\n 'loadingOverlay', 'loadingIcon',\n 'rowGroupHeader', 'rowGroupHeaderName', 'rowExpansion', 'rowGroupFooter',\n 'rowGroupToggler', 'rowGroupTogglerIcon',\n 'resizeHelper',\n 'reorderIndicatorUp', 'reorderIndicatorUpIcon',\n 'reorderIndicatorDown', 'reorderIndicatorDownIcon',\n 'tableHeader', 'searchInput',\n 'paginatorPageButton', 'paginatorPageLink', 'paginatorActivePageButton',\n 'paginatorPageReport', 'paginatorRowsPerPage', 'paginatorRowsPerPageDropdown',\n 'paginatorPages',\n 'sortedColumn', 'stripedRow', 'selectedRow', 'selectedRowAccent',\n 'filterBar', 'filterInput', 'filterLabel',\n 'toolbarRight', 'toolbarButton', 'clearFilterButton', 'columnPicker',\n // Toolbar sizing + placeholder, and the chrome the table renders itself.\n // NOTE: a slot missing from this allowlist is silently dropped — theming\n // it has no effect at all — so every new slot must be listed here as\n // well as in its component's ITableElementSlots.\n 'toolbarControl', 'filterPlaceholder',\n 'topBar', 'bulkBar', 'bulkBarText',\n // ImageCropper (IImageCropperSlots). The other slots it uses — root,\n // container, header, title, content, footer, icon, text, mask, track,\n // thumb — are already in this set under the components that named them\n // first, which is the point of reusing those names.\n 'cropWindow', 'shade', 'gridLine', 'handle',\n 'zoomChip', 'previewFrame', 'dropZone', 'progressFill',\n // Accordion\n 'headerActive', 'headerHover',\n // Sidebar/Drawer\n 'headerTitle', 'closeButton', 'mask',\n // Group (repeatable field array)\n 'row', 'addButton', 'removeButton',\n // Header (app-shell top bar)\n 'toggleModeButton', 'avatarButton', 'breadcrumb',\n]);\n\nexport interface IElementConfig {\n style: Record<string, any>;\n /**\n * Extra attributes for this slot's element — `className`, `data-*`,\n * `aria-*`, anything the platform element accepts. Merged across the\n * whole chain (FormElement < baseGroup < component < instance slots),\n * with `className` CONCATENATED rather than replaced.\n */\n props: Record<string, any>;\n important?: boolean | string[];\n pseudo?: Record<string, Record<string, any>>;\n}\n\nexport interface UseComponentDefaultsResult<T> {\n /** Props with theme defaults merged in (user props always win) */\n mergedProps: T;\n /**\n * CSS style from root slot — backwards compat for components\n * that read themeStyle instead of elementStyles.root\n */\n themeStyle: Record<string, any>;\n /**\n * Per-element style maps. Each key is a slot name, value is the\n * merged IStyleClasses (not yet resolved to CSSProperties).\n * Use `useResolvedElementStyles(elementStyles)` to resolve.\n */\n elementStyles: Record<string, Record<string, any>>;\n /**\n * Per-element extra attributes. Each key is a slot name, value is the\n * merged `props` for that slot (`className`, `data-*`, `aria-*`, …).\n *\n * ⛔ EVERY SLOT, NOT JUST `root` — THAT WAS THE BUG. `IElementSlotConfig`\n * has advertised `props` on every slot since the slot system landed, but\n * only `root.props` was ever read (it is folded into `mergedProps`).\n * Anything a consumer put on another slot — the class a portal needs on a\n * tags field's outer box to make it match a text input — was parsed,\n * merged, and then thrown away with no warning and no type error.\n * Components apply `elementProps[slot]` to the matching element.\n */\n elementProps: Record<string, Record<string, any>>;\n /**\n * Full slot configs including `props`, `important` and `pseudo` fields.\n * Use this instead of `elementStyles` when you need those fields.\n */\n elementConfigs: Record<string, IElementConfig>;\n}\n\n/**\n * Merges slot `props` layers. Everything is last-wins EXCEPT `className`,\n * which is concatenated — a theme-level class and a consumer's class are\n * additive by nature, and dropping one of them is exactly the fault this\n * whole plumbing exists to fix.\n */\nfunction mergeSlotProps(layers: Array<Record<string, any> | undefined>): Record<string, any> {\n const out: Record<string, any> = {};\n const classes: string[] = [];\n for (const layer of layers) {\n if (!layer) continue;\n for (const [key, value] of Object.entries(layer)) {\n if (value === undefined) continue;\n if (key === 'className') {\n if (value) classes.push(String(value));\n } else {\n out[key] = value;\n }\n }\n }\n if (classes.length) {\n // De-duplicated, so a class repeated down the chain lands once.\n out.className = Array.from(new Set(classes.join(' ').split(/\\s+/).filter(Boolean))).join(' ');\n }\n return out;\n}\n\n/**\n * Merges theme-level component defaults with user-supplied props.\n *\n * Resolution chain (lowest → highest priority):\n * FormElement[slot] < baseGroup[slot] < component[slot] < instanceSlots[slot] < user props\n *\n * `FormElement` is the global base group for every form element\n * (label / helperText / error live there by default). It is applied\n * to every component regardless of whether a `baseGroup` is provided\n * — for non-form components like Button or Card, FormElement slots\n * are no-ops in practice because those components don't read\n * `elementStyles.label` / `helperText` / `error`.\n *\n * Element slots (`root`, `label`, `container`, etc.) are direct keys\n * on the component config. Each slot accepts `{ props?, style? }`.\n *\n * The `root` slot's `props` are merged into `mergedProps` alongside\n * user props (user always wins, except `className`, which concatenates).\n * The `root` slot's `style` is returned as both `themeStyle` (backwards\n * compat) and `elementStyles.root`.\n *\n * EVERY OTHER slot's `props` come back on `elementProps[slot]` — the\n * component is responsible for spreading them onto the element that slot\n * names. Before that existed, `props` on a non-root slot was silently\n * discarded, which is how a consumer's class on a tags field's outer box\n * disappeared without a single error.\n *\n * Supports base-group inheritance: e.g. `useComponentDefaults('InputText', rawProps, 'Input')`\n * merges FormElement first, then Input base, then InputText overrides,\n * then per-instance slots, then user props.\n *\n * @example\n * const { mergedProps, themeStyle, elementStyles } = useComponentDefaults('InputText', rawProps, 'Input');\n * // mergedProps → FormElement.root.props < Input.root.props < InputText.root.props < instanceSlots < user props\n * // elementStyles.label → FormElement.label.style < Input.label.style < InputText.label.style < instance label\n * // elementStyles.root → root element style (FormElement → Input → InputText → instance)\n * // elementStyles.container → container element style\n */\nexport default function useComponentDefaults<T extends Record<string, any>>(\n componentName: string,\n props: T,\n baseGroup?: string,\n): UseComponentDefaultsResult<T> {\n const {theme} = useKitsTheme();\n // Global base for every form element. Always looked up — if not\n // configured it is `undefined` and the merge contributes nothing.\n const formElementConfig = theme.components.FormElement;\n const baseConfig = baseGroup ? theme.components[baseGroup] : undefined;\n const config = theme.components[componentName];\n\n return useMemo(() => {\n // Extract per-instance slot overrides from props (IFormElement.slots passed through)\n const instanceSlots = (props as any).slots as Record<string, { props?: any; style?: any; important?: boolean | string[]; pseudo?: Record<string, Record<string, any>> }> | undefined;\n\n if (!config && !baseConfig && !instanceSlots && !formElementConfig) {\n return {mergedProps: props, themeStyle: {}, elementStyles: {}, elementProps: {}, elementConfigs: {}};\n }\n\n const formBase = (formElementConfig || {}) as Record<string, any>;\n const base = (baseConfig || {}) as Record<string, any>;\n const comp = (config || {}) as Record<string, any>;\n\n // --- Props merge: FormElement.root.props < base.root.props < config.root.props < instanceSlots.root.props < user props ---\n const merged = mergeSlotProps([\n formBase.root?.props,\n base.root?.props,\n comp.root?.props,\n instanceSlots?.root?.props,\n ]);\n\n const userClassName = typeof (props as any).className === 'string' ? (props as any).className : undefined;\n for (const key of Object.keys(props)) {\n // Skip 'slots' — it is consumed here, not forwarded\n if (key === 'slots') continue;\n // className is additive, not a replacement: a theme-level class on\n // `root.props` and the consumer's own class both have to survive.\n if (key === 'className') continue;\n if (props[key] !== undefined) {\n merged[key] = props[key];\n }\n }\n if (userClassName || merged.className) {\n merged.className = mergeSlotProps([\n {className: merged.className},\n {className: userClassName},\n ]).className;\n }\n\n // --- Element styles merge: FormElement[slot] < base[slot] < config[slot] < instanceSlots[slot] ---\n const allSlotKeys = new Set<string>();\n for (const key of Object.keys(formBase)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n for (const key of Object.keys(base)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n for (const key of Object.keys(comp)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n if (instanceSlots) {\n for (const key of Object.keys(instanceSlots)) {\n if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);\n }\n }\n\n const elementStyles: Record<string, Record<string, any>> = {};\n const elementProps: Record<string, Record<string, any>> = {};\n const elementConfigs: Record<string, IElementConfig> = {};\n for (const slotKey of allSlotKeys) {\n const style = {\n ...(formBase[slotKey]?.style || {}),\n ...(base[slotKey]?.style || {}),\n ...(comp[slotKey]?.style || {}),\n ...(instanceSlots?.[slotKey]?.style || {}),\n };\n elementStyles[slotKey] = style;\n\n const slotProps = mergeSlotProps([\n formBase[slotKey]?.props,\n base[slotKey]?.props,\n comp[slotKey]?.props,\n instanceSlots?.[slotKey]?.props,\n ]);\n elementProps[slotKey] = slotProps;\n\n const pseudoMerged = {\n ...(formBase[slotKey]?.pseudo || {}),\n ...(base[slotKey]?.pseudo || {}),\n ...(comp[slotKey]?.pseudo || {}),\n ...(instanceSlots?.[slotKey]?.pseudo || {}),\n };\n elementConfigs[slotKey] = {\n style,\n props: slotProps,\n important:\n instanceSlots?.[slotKey]?.important ??\n comp[slotKey]?.important ??\n base[slotKey]?.important ??\n formBase[slotKey]?.important,\n pseudo: Object.keys(pseudoMerged).length > 0 ? pseudoMerged : undefined,\n };\n }\n\n // themeStyle = root element style (backwards compat)\n const themeStyle = elementStyles.root || {};\n\n return {\n mergedProps: merged as T,\n themeStyle,\n elementStyles,\n elementProps,\n elementConfigs,\n };\n }, [formElementConfig, baseConfig, config, props]);\n}\n"],"names":["useKitsTheme","useMemo"],"mappings":";;;;;;;AAaA,MAAM,iBAAA,uBAAwB,GAAA,CAAI;AAAA;AAAA;AAAA,EAG9B,OAAA;AAAA,EAAS,YAAA;AAAA,EAAc,OAAA;AAAA;AAAA,EAEvB,MAAA;AAAA,EAAQ,WAAA;AAAA,EAAa,YAAA;AAAA,EAAc,WAAA;AAAA,EAAa,YAAA;AAAA;AAAA;AAAA;AAAA,EAIhD,OAAA;AAAA,EAAS,MAAA;AAAA,EAAQ,cAAA;AAAA,EAAgB,aAAA;AAAA,EAAe,WAAA;AAAA,EAAa,cAAA;AAAA,EAAgB,aAA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AO,CAAA,GAAI,SAAA;AAExB,MAAA,MAAM,YAAA,GAAe;AAAA,QACjB,GAAI,QAAA,CAAS,OAAO,CAAA,EAAG,UAAU,EAAC;AAAA,QAClC,GAAI,IAAA,CAAK,OAAO,CAAA,EAAG,UAAU,EAAC;AAAA,QAC9B,GAAI,IAAA,CAAK,OAAO,CAAA,EAAG,UAAU,EAAC;AAAA,QAC9B,GAAI,aAAA,GAAgB,OAAO,CAAA,EAAG,UAAU;AAAC,OAC7C;AACA,MAAA,cAAA,CAAe,OAAO,CAAA,GAAI;AAAA,QACtB,KAAA;AAAA,QACA,KAAA,EAAO,SAAA;AAAA,QACP,SAAA,EACI,aAAA,GAAgB,OAAO,CAAA,EAAG,aAC1B,IAAA,CAAK,OAAO,CAAA,EAAG,SAAA,IACf,KAAK,OAAO,CAAA,EAAG,SAAA,IACf,QAAA,CAAS,OAAO,CAAA,EAAG,SAAA;AAAA,QACvB,QAAQ,MAAA,CAAO,IAAA,CAAK,YAAY,CAAA,CAAE,MAAA,GAAS,IAAI,YAAA,GAAe;AAAA,OAClE;AAAA,IACJ;AAGA,IAAA,MAAM,UAAA,GAAa,aAAA,CAAc,IAAA,IAAQ,EAAC;AAE1C,IAAA,OAAO;AAAA,MACH,WAAA,EAAa,MAAA;AAAA,MACb,UAAA;AAAA,MACA,aAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACJ;AAAA,EACJ,GAAG,CAAC,iBAAA,EAAmB,UAAA,EAAY,MAAA,EAAQ,KAAK,CAAC,CAAA;AACrD;;;;"}
|
|
@@ -23,9 +23,14 @@ const ELEMENT_SLOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
23
23
|
"itemHover",
|
|
24
24
|
"itemDisabled",
|
|
25
25
|
"itemInvalid",
|
|
26
|
-
//
|
|
26
|
+
// Chip-bearing selects (IChipInputSlots — MultiSelect display="chip"
|
|
27
|
+
// AND AutoComplete/Tags with isMultiple). `tokenContainer` is the
|
|
28
|
+
// bordered box that holds the chips and the caret — see the docblock
|
|
29
|
+
// on IChipInputSlots for why it is neither `root` nor `container`.
|
|
30
|
+
"tokenContainer",
|
|
27
31
|
"token",
|
|
28
32
|
"tokenIcon",
|
|
33
|
+
// MultiSelect specific (IMultiSelectSlots — per-item checkbox)
|
|
29
34
|
"checkboxBox",
|
|
30
35
|
"checkboxBoxChecked",
|
|
31
36
|
"checkboxIcon",
|
|
@@ -127,6 +132,18 @@ const ELEMENT_SLOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
127
132
|
"topBar",
|
|
128
133
|
"bulkBar",
|
|
129
134
|
"bulkBarText",
|
|
135
|
+
// ImageCropper (IImageCropperSlots). The other slots it uses — root,
|
|
136
|
+
// container, header, title, content, footer, icon, text, mask, track,
|
|
137
|
+
// thumb — are already in this set under the components that named them
|
|
138
|
+
// first, which is the point of reusing those names.
|
|
139
|
+
"cropWindow",
|
|
140
|
+
"shade",
|
|
141
|
+
"gridLine",
|
|
142
|
+
"handle",
|
|
143
|
+
"zoomChip",
|
|
144
|
+
"previewFrame",
|
|
145
|
+
"dropZone",
|
|
146
|
+
"progressFill",
|
|
130
147
|
// Accordion
|
|
131
148
|
"headerActive",
|
|
132
149
|
"headerHover",
|
|
@@ -143,6 +160,25 @@ const ELEMENT_SLOT_KEYS = /* @__PURE__ */ new Set([
|
|
|
143
160
|
"avatarButton",
|
|
144
161
|
"breadcrumb"
|
|
145
162
|
]);
|
|
163
|
+
function mergeSlotProps(layers) {
|
|
164
|
+
const out = {};
|
|
165
|
+
const classes = [];
|
|
166
|
+
for (const layer of layers) {
|
|
167
|
+
if (!layer) continue;
|
|
168
|
+
for (const [key, value] of Object.entries(layer)) {
|
|
169
|
+
if (value === void 0) continue;
|
|
170
|
+
if (key === "className") {
|
|
171
|
+
if (value) classes.push(String(value));
|
|
172
|
+
} else {
|
|
173
|
+
out[key] = value;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (classes.length) {
|
|
178
|
+
out.className = Array.from(new Set(classes.join(" ").split(/\s+/).filter(Boolean))).join(" ");
|
|
179
|
+
}
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
146
182
|
function useComponentDefaults(componentName, props, baseGroup) {
|
|
147
183
|
const { theme } = useKitsTheme();
|
|
148
184
|
const formElementConfig = theme.components.FormElement;
|
|
@@ -151,23 +187,31 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
151
187
|
return useMemo(() => {
|
|
152
188
|
const instanceSlots = props.slots;
|
|
153
189
|
if (!config && !baseConfig && !instanceSlots && !formElementConfig) {
|
|
154
|
-
return { mergedProps: props, themeStyle: {}, elementStyles: {}, elementConfigs: {} };
|
|
190
|
+
return { mergedProps: props, themeStyle: {}, elementStyles: {}, elementProps: {}, elementConfigs: {} };
|
|
155
191
|
}
|
|
156
192
|
const formBase = formElementConfig || {};
|
|
157
193
|
const base = baseConfig || {};
|
|
158
194
|
const comp = config || {};
|
|
159
|
-
const merged =
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
195
|
+
const merged = mergeSlotProps([
|
|
196
|
+
formBase.root?.props,
|
|
197
|
+
base.root?.props,
|
|
198
|
+
comp.root?.props,
|
|
199
|
+
instanceSlots?.root?.props
|
|
200
|
+
]);
|
|
201
|
+
const userClassName = typeof props.className === "string" ? props.className : void 0;
|
|
165
202
|
for (const key of Object.keys(props)) {
|
|
166
203
|
if (key === "slots") continue;
|
|
204
|
+
if (key === "className") continue;
|
|
167
205
|
if (props[key] !== void 0) {
|
|
168
206
|
merged[key] = props[key];
|
|
169
207
|
}
|
|
170
208
|
}
|
|
209
|
+
if (userClassName || merged.className) {
|
|
210
|
+
merged.className = mergeSlotProps([
|
|
211
|
+
{ className: merged.className },
|
|
212
|
+
{ className: userClassName }
|
|
213
|
+
]).className;
|
|
214
|
+
}
|
|
171
215
|
const allSlotKeys = /* @__PURE__ */ new Set();
|
|
172
216
|
for (const key of Object.keys(formBase)) {
|
|
173
217
|
if (ELEMENT_SLOT_KEYS.has(key)) allSlotKeys.add(key);
|
|
@@ -184,6 +228,7 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
184
228
|
}
|
|
185
229
|
}
|
|
186
230
|
const elementStyles = {};
|
|
231
|
+
const elementProps = {};
|
|
187
232
|
const elementConfigs = {};
|
|
188
233
|
for (const slotKey of allSlotKeys) {
|
|
189
234
|
const style = {
|
|
@@ -193,6 +238,13 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
193
238
|
...instanceSlots?.[slotKey]?.style || {}
|
|
194
239
|
};
|
|
195
240
|
elementStyles[slotKey] = style;
|
|
241
|
+
const slotProps = mergeSlotProps([
|
|
242
|
+
formBase[slotKey]?.props,
|
|
243
|
+
base[slotKey]?.props,
|
|
244
|
+
comp[slotKey]?.props,
|
|
245
|
+
instanceSlots?.[slotKey]?.props
|
|
246
|
+
]);
|
|
247
|
+
elementProps[slotKey] = slotProps;
|
|
196
248
|
const pseudoMerged = {
|
|
197
249
|
...formBase[slotKey]?.pseudo || {},
|
|
198
250
|
...base[slotKey]?.pseudo || {},
|
|
@@ -201,6 +253,7 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
201
253
|
};
|
|
202
254
|
elementConfigs[slotKey] = {
|
|
203
255
|
style,
|
|
256
|
+
props: slotProps,
|
|
204
257
|
important: instanceSlots?.[slotKey]?.important ?? comp[slotKey]?.important ?? base[slotKey]?.important ?? formBase[slotKey]?.important,
|
|
205
258
|
pseudo: Object.keys(pseudoMerged).length > 0 ? pseudoMerged : void 0
|
|
206
259
|
};
|
|
@@ -210,6 +263,7 @@ function useComponentDefaults(componentName, props, baseGroup) {
|
|
|
210
263
|
mergedProps: merged,
|
|
211
264
|
themeStyle,
|
|
212
265
|
elementStyles,
|
|
266
|
+
elementProps,
|
|
213
267
|
elementConfigs
|
|
214
268
|
};
|
|
215
269
|
}, [formElementConfig, baseConfig, config, props]);
|