90 lines
3.2 KiB
JavaScript
90 lines
3.2 KiB
JavaScript
'use client';
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
function _export(target, all) {
|
|
for(var name in all)Object.defineProperty(target, name, {
|
|
enumerable: true,
|
|
get: all[name]
|
|
});
|
|
}
|
|
_export(exports, {
|
|
useTextareaBase_unstable: function() {
|
|
return useTextareaBase_unstable;
|
|
},
|
|
useTextarea_unstable: function() {
|
|
return useTextarea_unstable;
|
|
}
|
|
});
|
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
const _reactfield = require("@fluentui/react-field");
|
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
const useTextarea_unstable = (props, ref)=>{
|
|
const overrides = (0, _reactsharedcontexts.useOverrides_unstable)();
|
|
var _overrides_inputDefaultAppearance;
|
|
const { size = 'medium', appearance = (_overrides_inputDefaultAppearance = overrides.inputDefaultAppearance) !== null && _overrides_inputDefaultAppearance !== void 0 ? _overrides_inputDefaultAppearance : 'outline', ...baseProps } = props;
|
|
if (process.env.NODE_ENV !== 'production' && (appearance === 'filled-darker-shadow' || appearance === 'filled-lighter-shadow')) {
|
|
// eslint-disable-next-line no-console
|
|
console.error("The 'filled-darker-shadow' and 'filled-lighter-shadow' appearances are deprecated and will be removed in the" + ' future.');
|
|
}
|
|
const baseState = useTextareaBase_unstable(baseProps, ref);
|
|
return {
|
|
...baseState,
|
|
size,
|
|
appearance
|
|
};
|
|
};
|
|
const useTextareaBase_unstable = (props, ref)=>{
|
|
// Merge props from surrounding <Field>, if any
|
|
props = (0, _reactfield.useFieldControlProps_unstable)(props, {
|
|
supportsLabelFor: true,
|
|
supportsRequired: true,
|
|
supportsSize: true
|
|
});
|
|
const { resize = 'none', onChange } = props;
|
|
const [value, setValue] = (0, _reactutilities.useControllableState)({
|
|
state: props.value,
|
|
defaultState: props.defaultValue,
|
|
initialState: undefined
|
|
});
|
|
const nativeProps = (0, _reactutilities.getPartitionedNativeProps)({
|
|
props,
|
|
primarySlotTagName: 'textarea',
|
|
excludedPropNames: [
|
|
'onChange',
|
|
'value',
|
|
'defaultValue'
|
|
]
|
|
});
|
|
const state = {
|
|
resize,
|
|
components: {
|
|
root: 'span',
|
|
textarea: 'textarea'
|
|
},
|
|
textarea: _reactutilities.slot.always(props.textarea, {
|
|
defaultProps: {
|
|
ref,
|
|
...nativeProps.primary
|
|
},
|
|
elementType: 'textarea'
|
|
}),
|
|
root: _reactutilities.slot.always(props.root, {
|
|
defaultProps: nativeProps.root,
|
|
elementType: 'span'
|
|
})
|
|
};
|
|
state.textarea.value = value;
|
|
state.textarea.onChange = (0, _reactutilities.useEventCallback)((ev)=>{
|
|
const newValue = ev.target.value;
|
|
onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
|
|
value: newValue
|
|
});
|
|
setValue(newValue);
|
|
});
|
|
return state;
|
|
};
|