import snippets from './snippets'; export default { snippets, componentName: 'Slider', title: 'Sliding input bar', category: 'Form', props: [ { name: 'defaultValue', title: { label: 'default value', tip: 'Set initial value. When `range` is false, use number, otherwise use \\[number, number]', }, propType: { type: 'oneOfType', value: ['number', { type: 'arrayOf', value: 'number' }], }, }, { name: 'range', title: { label: 'Dual slider mode', tip: 'dual slider mode' }, propType: 'bool', defaultValue: false, setter: 'BoolSetter', setValue(target, range) { let defaultValue = target.node.getPropValue('defaultValue'); if (range) { defaultValue = Array.isArray(defaultValue) ? defaultValue : [0, defaultValue]; } else { defaultValue = Array.isArray(defaultValue) ? defaultValue[1] || defaultValue[0] : defaultValue; } target.node.setPropValue('defaultValue', defaultValue); }, }, // { // name: 'value', // title: { // label: 'current value', // tip: // 'Set the current value. When `range` is false, use number, otherwise use \\[number, number]', // }, // propType: { // type: 'oneOfType', // value: ['number', { type: 'arrayOf', value: 'number' }], // }, // }, { name: 'allowClear', title: { label: 'allow clear', tip: 'allow clearing' }, condition(target) { return target.getProps().getPropValue('range') === true; }, propType: 'bool', defaultValue: false, setter: 'BoolSetter' }, { name: 'disabled', title: { label: 'disabled', tip: 'disabled', }, propType: 'bool', defaultValue: false, setter: 'BoolSetter' }, { name: 'dots', title: { label: 'alignment scale', tip: 'it can only be dragged to the scale' }, propType: 'bool', defaultValue: false, setter: 'BoolSetter' }, // { // name: 'included', // title: { // label: // '`marks` is valid when it is not an empty object. When the value is true, it means that the value is an inclusion relationship. If it is false, it means parallelism.', // tip: // '`marks` is valid when it is not an empty object. When the value is true, it means that the value is an inclusion relationship. If it is false, it means parallelism.', // }, // propType: 'bool', // defaultValue: true, // }, // { // name: 'marks', // title: { // label: // 'Tick mark, the type of key must be `number` and the value must be in the closed interval \\[min, max]. Each label can be styled independently.', // tip: // 'Tick mark, the type of key must be `number` and the value must be in the closed interval \\[min, max]. Each label can be styled independently.', // }, // propType: 'object', // }, { name: 'max', title: { label: 'maximum value', tip: 'maximum value' }, propType: 'number', setter: 'NumberSetter' }, { name: 'min', title: { label: 'minimum value', tip: 'minimum value' }, propType: 'number', setter: 'NumberSetter' }, { name: 'reverse', title: { label: 'reverse axis', tip: 'reverse axis' }, propType: 'bool', defaultValue: false, setter: 'BoolSetter' }, { name: 'step', title: { label: 'step size', tip: 'Step size, the value must be greater than 0 and divisible by (max - min). When `marks` is not an empty object, you can set `step` to null. At this time, the optional value of Slider is only the part marked by marks.', }, propType: 'number', setter: 'NumberSetter' }, // { // name: 'tipFormatter', // title: { // label: // 'Slider will pass the current value to `tipFormatter` and display the return value of `tipFormatter` in the Tooltip. If it is null, the Tooltip will be hidden.', // tip: // 'Slider will pass the current value to `tipFormatter` and display the return value of `tipFormatter` in the Tooltip. If it is null, the Tooltip will be hidden.', // }, // propType: 'func', // }, { name: 'vertical', title: { label: 'vertical direction', tip: 'When the value is true, the Slider is vertically oriented', }, propType: 'bool', defaultValue: false, setter: 'BoolSetter' }, { name: 'onAfterChange', title: { label: 'on after change', tip: 'Consistent with `onmouseup` triggering time, the current value is passed in as a parameter', }, propType: 'func', }, { name: 'onChange', title: { label: 'on Change', tip: 'When the value of Slider changes, the onChange event will be triggered and the changed value will be passed in as a parameter.', }, propType: 'func', }, // { // name: 'tooltipPlacement', // title: { // label: 'Set up tooltip placement.', // tip: 'Set up tooltip placement. Reference [Tooltip](/components/tooltip/)', // }, // propType: 'string', // }, // { // name: 'tooltipVisible', // title: { // label: // 'When the value is true, the Tooltip will always be displayed; otherwise it will not be displayed, even when dragging and moving in', // tip: // 'When the value is true, the Tooltip will always be displayed; otherwise it will not be displayed, even when dragging and moving in', // }, // propType: 'bool', // }, // { // name: 'getTooltipPopupContainer', // title: { // label: 'Tooltip renders the parent node, which is rendered to the body by default.', // tip: 'Tooltip renders the parent node, which is rendered to the body by default.', // }, // propType: 'func', // }, ], configure: { supports: { style: true, events: [ { name: 'onAfterChange', template: "onAfterChange(value,${extParams}){\n// 与 onmouseup 触发时机一致\nconsole.log('onAfterChange',value);}", }, { name: 'onChange', template: "onChange(value,${extParams}){\n// 当 Slider 的值发生改变时触发回调\nconsole.log('onChange',value);}", }, ], }, }, };