Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const optionDef = {
key: optionName,
isSoldered,
isSubOption,
disableCloudSyncing,
type: do {
if (isSoldered || typeof defaultValue === 'boolean') {
'checkbox' // eslint-disable-line no-unused-expressions
} else if (typeof defaultValue === 'number') {
'number' // eslint-disable-line no-unused-expressions
} else {
// eslint-disable-next-line unicorn/prefer-type-error
throw new Error('无法判断选项的类型,因为没有指定 `isSoldered` 或 `defaultValue`')
}
},
...pick(rawOptionDef, [ 'label', 'comment', 'controlOptions' ]),
}
if (isSubOption) {
optionDef.parentKey = featureName
}
return optionDef
}
value: undefined,
type: PropTypes.Boolean,
description:
'When set to true a close button is displayed and the notification can be dismissed by a user.',
},
children: {
value: '{() => "This is a notification."}',
type: PropTypes.Function,
description: `Toast notification content. The children-as-function
receives a dismiss method that can be called to
dismiss the notification and can be used as a
handler for an action inside the toast content.
React.ChildrenArray type is also accepted.`,
placeholder: '({dismiss}) => {}',
},
...pick(changeHandlers, ['onBlur', 'onFocus']),
onClose: {
value: undefined,
type: PropTypes.Function,
description: `A callback function called when a notification is dismissed.`,
placeholder: '() => {}',
},
autoHideDuration: {
value: undefined,
type: PropTypes.Number,
description: `The number of milliseconds to wait before automatically dismissing a
notification. This behavior is disabled when the value is set to 0.`,
placeholder: '10000',
},
...pick(changeHandlers, ['onMouseEnter', 'onMouseLeave']),
overrides: {
value: undefined,
description: 'Name attribute.',
hidden: true,
},
min: {
value: undefined,
type: PropTypes.String,
description: 'min value when used as input type=number',
hidden: true,
},
max: {
value: undefined,
type: PropTypes.String,
description: 'max value when used as input type=number',
hidden: true,
},
...pick(changeHandlers, [
'onBlur',
'onKeyDown',
'onKeyPress',
'onKeyUp',
'onFocus',
]),
required: {
value: false,
type: PropTypes.Boolean,
description: 'Renders component in required state.',
hidden: true,
},
};
const InputConfig: TConfig = {
imports: {
constructor({ featureName, subfeatureName, script, parent }) {
this.featureName = featureName
this.subfeatureName = subfeatureName
this.parent = parent
this.initContext()
const featureScriptObj = script(this.context)
this.migrations = featureScriptObj.migrations
this.script = pick(featureScriptObj, [
'onLoad',
'onSettingsChange',
'onUnload',
])
}
if (style) {
this.style = {
element: null,
code: style,
}
}
if (script) {
const featureScriptObj = script(this.context) || {}
if (featureScriptObj.waitReady) {
this.waitReadyFns.push(featureScriptObj.waitReady)
}
this.migrations = featureScriptObj.migrations
this.script = pick(featureScriptObj, [
'applyWhen',
'onLoad',
'onSettingsChange',
'onUnload',
])
}
this.isApplicable = simpleMemoize(
this.script?.applyWhen ||
(() => Promise.resolve(true)),
)
}
description: 'Set to be focused (active) on selectedchecked radio.',
hidden: true,
},
'aria-label': {
value: undefined,
type: PropTypes.String,
description: `Sets aria-label attribute.`,
hidden: true,
},
'aria-labelledby': {
value: undefined,
type: PropTypes.String,
description: `Sets aria-labelledby attribute.`,
hidden: true,
},
...pick(changeHandlers, [
'onBlur',
'onFocus',
'onMouseLeave',
'onMouseEnter',
]),
overrides: {
value: undefined,
type: PropTypes.Custom,
description: 'Lets you customize all aspects of the component.',
custom: {
names: [
'Root',
'Input',
'Label',
'RadioGroupRoot',
'RadioMarkInner',
async loadOptionValues() {
const optionValues = await settings.readAll()
this.optionValuesCache = pick(optionValues, this.metadata.optionNames)
}
description:
'Change handler of the select to be called when a value is changed.',
propHook: {
what: 'JSON.stringify(params.value)',
into: 'value',
},
placeholder: '({value, option, type}) => value',
},
filterOptions: {
value: undefined,
type: PropTypes.Function,
description:
'A custom method to filter options to be displayed in the dropdown.',
placeholder: '(options) => options',
},
...pick(changeHandlers, ['onBlur', 'onFocus']),
onInputChange: {
value: undefined,
type: PropTypes.Function,
description: 'Change handler of the search input.',
placeholder: '(event) => {}',
},
onOpen: {
value: undefined,
type: PropTypes.Function,
description: 'A function that is called when the dropdown opens.',
placeholder: '() => {}',
},
onClose: {
value: undefined,
type: PropTypes.Function,
description: 'A function that is called when the dropdown closes.',
initContext() {
this.waitReadyFns = []
this.context = pick(this, [
'requireModules',
'readOptionValue',
])
}