seeder-st2110-components 1.6.4 → 1.6.5

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/index.esm.js CHANGED
@@ -3230,7 +3230,8 @@ const SystemOperations = _ref => {
3230
3230
  powerOffLabel = "Power Off",
3231
3231
  restartLabel = "Restart",
3232
3232
  iconClassName = "seeder-iconfont seeder-icon-guanji1 text-xl text-neutral-400",
3233
- confirmTitle = "Confirm",
3233
+ confirmMessage = "Are you sure you want to {action} the system? This action cannot be undone.",
3234
+ confirmTitle = "Confirmation Required",
3234
3235
  cancelText = "No",
3235
3236
  okText = "Yes",
3236
3237
  run
@@ -3252,9 +3253,16 @@ const SystemOperations = _ref => {
3252
3253
  }];
3253
3254
  const doAction = action => {
3254
3255
  try {
3256
+ // 根据action决定显示的确认信息
3257
+ const actionLabels = {
3258
+ poweroff: "power off",
3259
+ restart: "restart"
3260
+ };
3261
+ const actionText = actionLabels[action] || action;
3255
3262
  AntdModal.confirm({
3256
3263
  icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
3257
- title: "".concat(confirmTitle, " ").concat(action, "?"),
3264
+ title: confirmTitle,
3265
+ content: confirmMessage.replace('{action}', actionText),
3258
3266
  cancelText,
3259
3267
  okText,
3260
3268
  onOk: () => {
@@ -3469,544 +3477,10 @@ CommonHeader.propTypes = {
3469
3477
  };
3470
3478
  var CommonHeader$1 = CommonHeader;
3471
3479
 
3472
- var isCheckBoxInput = (element) => element.type === 'checkbox';
3473
-
3474
- var isDateObject = (value) => value instanceof Date;
3475
-
3476
- var isNullOrUndefined = (value) => value == null;
3477
-
3478
- const isObjectType = (value) => typeof value === 'object';
3479
- var isObject = (value) => !isNullOrUndefined(value) &&
3480
- !Array.isArray(value) &&
3481
- isObjectType(value) &&
3482
- !isDateObject(value);
3483
-
3484
- var getEventValue = (event) => isObject(event) && event.target
3485
- ? isCheckBoxInput(event.target)
3486
- ? event.target.checked
3487
- : event.target.value
3488
- : event;
3489
-
3490
- var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
3491
-
3492
- var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
3493
-
3494
- var isPlainObject = (tempObject) => {
3495
- const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
3496
- return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
3497
- };
3498
-
3499
- var isWeb = typeof window !== 'undefined' &&
3500
- typeof window.HTMLElement !== 'undefined' &&
3501
- typeof document !== 'undefined';
3502
-
3503
- function cloneObject(data) {
3504
- let copy;
3505
- const isArray = Array.isArray(data);
3506
- const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
3507
- if (data instanceof Date) {
3508
- copy = new Date(data);
3509
- }
3510
- else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
3511
- (isArray || isObject(data))) {
3512
- copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
3513
- if (!isArray && !isPlainObject(data)) {
3514
- copy = data;
3515
- }
3516
- else {
3517
- for (const key in data) {
3518
- if (data.hasOwnProperty(key)) {
3519
- copy[key] = cloneObject(data[key]);
3520
- }
3521
- }
3522
- }
3523
- }
3524
- else {
3525
- return data;
3526
- }
3527
- return copy;
3528
- }
3529
-
3530
- var isKey = (value) => /^\w*$/.test(value);
3531
-
3532
- var isUndefined = (val) => val === undefined;
3533
-
3534
- var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
3535
-
3536
- var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
3537
-
3538
- var get = (object, path, defaultValue) => {
3539
- if (!path || !isObject(object)) {
3540
- return defaultValue;
3541
- }
3542
- const result = (isKey(path) ? [path] : stringToPath(path)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
3543
- return isUndefined(result) || result === object
3544
- ? isUndefined(object[path])
3545
- ? defaultValue
3546
- : object[path]
3547
- : result;
3548
- };
3549
-
3550
- var isBoolean = (value) => typeof value === 'boolean';
3551
-
3552
- var set = (object, path, value) => {
3553
- let index = -1;
3554
- const tempPath = isKey(path) ? [path] : stringToPath(path);
3555
- const length = tempPath.length;
3556
- const lastIndex = length - 1;
3557
- while (++index < length) {
3558
- const key = tempPath[index];
3559
- let newValue = value;
3560
- if (index !== lastIndex) {
3561
- const objValue = object[key];
3562
- newValue =
3563
- isObject(objValue) || Array.isArray(objValue)
3564
- ? objValue
3565
- : !isNaN(+tempPath[index + 1])
3566
- ? []
3567
- : {};
3568
- }
3569
- if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
3570
- return;
3571
- }
3572
- object[key] = newValue;
3573
- object = object[key];
3574
- }
3575
- };
3576
-
3577
- const EVENTS = {
3578
- BLUR: 'blur',
3579
- FOCUS_OUT: 'focusout',
3580
- CHANGE: 'change',
3581
- };
3582
- const VALIDATION_MODE = {
3583
- onBlur: 'onBlur',
3584
- onChange: 'onChange',
3585
- onSubmit: 'onSubmit',
3586
- onTouched: 'onTouched',
3587
- all: 'all',
3588
- };
3589
-
3590
- const HookFormContext = React.createContext(null);
3591
- HookFormContext.displayName = 'HookFormContext';
3592
- /**
3593
- * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
3594
- *
3595
- * @remarks
3596
- * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
3597
- *
3598
- * @returns return all useForm methods
3599
- *
3600
- * @example
3601
- * ```tsx
3602
- * function App() {
3603
- * const methods = useForm();
3604
- * const onSubmit = data => console.log(data);
3605
- *
3606
- * return (
3607
- * <FormProvider {...methods} >
3608
- * <form onSubmit={methods.handleSubmit(onSubmit)}>
3609
- * <NestedInput />
3610
- * <input type="submit" />
3611
- * </form>
3612
- * </FormProvider>
3613
- * );
3614
- * }
3615
- *
3616
- * function NestedInput() {
3617
- * const { register } = useFormContext(); // retrieve all hook methods
3618
- * return <input {...register("test")} />;
3619
- * }
3620
- * ```
3621
- */
3622
- const useFormContext = () => React.useContext(HookFormContext);
3623
-
3624
- var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
3625
- const result = {
3626
- defaultValues: control._defaultValues,
3627
- };
3628
- for (const key in formState) {
3629
- Object.defineProperty(result, key, {
3630
- get: () => {
3631
- const _key = key;
3632
- if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
3633
- control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
3634
- }
3635
- localProxyFormState && (localProxyFormState[_key] = true);
3636
- return formState[_key];
3637
- },
3638
- });
3639
- }
3640
- return result;
3641
- };
3642
-
3643
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
3644
-
3645
- /**
3646
- * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
3647
- *
3648
- * @remarks
3649
- * [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
3650
- *
3651
- * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
3652
- *
3653
- * @example
3654
- * ```tsx
3655
- * function App() {
3656
- * const { register, handleSubmit, control } = useForm({
3657
- * defaultValues: {
3658
- * firstName: "firstName"
3659
- * }});
3660
- * const { dirtyFields } = useFormState({
3661
- * control
3662
- * });
3663
- * const onSubmit = (data) => console.log(data);
3664
- *
3665
- * return (
3666
- * <form onSubmit={handleSubmit(onSubmit)}>
3667
- * <input {...register("firstName")} placeholder="First Name" />
3668
- * {dirtyFields.firstName && <p>Field is dirty.</p>}
3669
- * <input type="submit" />
3670
- * </form>
3671
- * );
3672
- * }
3673
- * ```
3674
- */
3675
- function useFormState(props) {
3676
- const methods = useFormContext();
3677
- const { control = methods.control, disabled, name, exact } = props || {};
3678
- const [formState, updateFormState] = React.useState(control._formState);
3679
- const _localProxyFormState = React.useRef({
3680
- isDirty: false,
3681
- isLoading: false,
3682
- dirtyFields: false,
3683
- touchedFields: false,
3684
- validatingFields: false,
3685
- isValidating: false,
3686
- isValid: false,
3687
- errors: false,
3688
- });
3689
- useIsomorphicLayoutEffect(() => control._subscribe({
3690
- name,
3691
- formState: _localProxyFormState.current,
3692
- exact,
3693
- callback: (formState) => {
3694
- !disabled &&
3695
- updateFormState({
3696
- ...control._formState,
3697
- ...formState,
3698
- });
3699
- },
3700
- }), [name, disabled, exact]);
3701
- React.useEffect(() => {
3702
- _localProxyFormState.current.isValid && control._setValid(true);
3703
- }, [control]);
3704
- return React.useMemo(() => getProxyFormState(formState, control, _localProxyFormState.current, false), [formState, control]);
3705
- }
3706
-
3707
- var isString = (value) => typeof value === 'string';
3708
-
3709
- var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
3710
- if (isString(names)) {
3711
- isGlobal && _names.watch.add(names);
3712
- return get(formValues, names, defaultValue);
3713
- }
3714
- if (Array.isArray(names)) {
3715
- return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
3716
- get(formValues, fieldName)));
3717
- }
3718
- isGlobal && (_names.watchAll = true);
3719
- return formValues;
3720
- };
3721
-
3722
- var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
3723
-
3724
- function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
3725
- if (isPrimitive(object1) || isPrimitive(object2)) {
3726
- return object1 === object2;
3727
- }
3728
- if (isDateObject(object1) && isDateObject(object2)) {
3729
- return object1.getTime() === object2.getTime();
3730
- }
3731
- const keys1 = Object.keys(object1);
3732
- const keys2 = Object.keys(object2);
3733
- if (keys1.length !== keys2.length) {
3734
- return false;
3735
- }
3736
- if (_internal_visited.has(object1) || _internal_visited.has(object2)) {
3737
- return true;
3738
- }
3739
- _internal_visited.add(object1);
3740
- _internal_visited.add(object2);
3741
- for (const key of keys1) {
3742
- const val1 = object1[key];
3743
- if (!keys2.includes(key)) {
3744
- return false;
3745
- }
3746
- if (key !== 'ref') {
3747
- const val2 = object2[key];
3748
- if ((isDateObject(val1) && isDateObject(val2)) ||
3749
- (isObject(val1) && isObject(val2)) ||
3750
- (Array.isArray(val1) && Array.isArray(val2))
3751
- ? !deepEqual(val1, val2, _internal_visited)
3752
- : val1 !== val2) {
3753
- return false;
3754
- }
3755
- }
3756
- }
3757
- return true;
3758
- }
3759
-
3760
- /**
3761
- * Custom hook to subscribe to field change and isolate re-rendering at the component level.
3762
- *
3763
- * @remarks
3764
- *
3765
- * [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
3766
- *
3767
- * @example
3768
- * ```tsx
3769
- * const { control } = useForm();
3770
- * const values = useWatch({
3771
- * name: "fieldName"
3772
- * control,
3773
- * })
3774
- * ```
3775
- */
3776
- function useWatch(props) {
3777
- const methods = useFormContext();
3778
- const { control = methods.control, name, defaultValue, disabled, exact, compute, } = props || {};
3779
- const _defaultValue = React.useRef(defaultValue);
3780
- const _compute = React.useRef(compute);
3781
- const _computeFormValues = React.useRef(undefined);
3782
- _compute.current = compute;
3783
- const defaultValueMemo = React.useMemo(() => control._getWatch(name, _defaultValue.current), [control, name]);
3784
- const [value, updateValue] = React.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
3785
- useIsomorphicLayoutEffect(() => control._subscribe({
3786
- name,
3787
- formState: {
3788
- values: true,
3789
- },
3790
- exact,
3791
- callback: (formState) => {
3792
- if (!disabled) {
3793
- const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
3794
- if (_compute.current) {
3795
- const computedFormValues = _compute.current(formValues);
3796
- if (!deepEqual(computedFormValues, _computeFormValues.current)) {
3797
- updateValue(computedFormValues);
3798
- _computeFormValues.current = computedFormValues;
3799
- }
3800
- }
3801
- else {
3802
- updateValue(formValues);
3803
- }
3804
- }
3805
- },
3806
- }), [control, disabled, name, exact]);
3807
- React.useEffect(() => control._removeUnmounted());
3808
- return value;
3809
- }
3810
-
3811
- /**
3812
- * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
3813
- *
3814
- * @remarks
3815
- * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
3816
- *
3817
- * @param props - the path name to the form field value, and validation rules.
3818
- *
3819
- * @returns field properties, field and form state. {@link UseControllerReturn}
3820
- *
3821
- * @example
3822
- * ```tsx
3823
- * function Input(props) {
3824
- * const { field, fieldState, formState } = useController(props);
3825
- * return (
3826
- * <div>
3827
- * <input {...field} placeholder={props.name} />
3828
- * <p>{fieldState.isTouched && "Touched"}</p>
3829
- * <p>{formState.isSubmitted ? "submitted" : ""}</p>
3830
- * </div>
3831
- * );
3832
- * }
3833
- * ```
3834
- */
3835
- function useController(props) {
3836
- const methods = useFormContext();
3837
- const { name, disabled, control = methods.control, shouldUnregister, defaultValue, } = props;
3838
- const isArrayField = isNameInFieldArray(control._names.array, name);
3839
- const defaultValueMemo = React.useMemo(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
3840
- const value = useWatch({
3841
- control,
3842
- name,
3843
- defaultValue: defaultValueMemo,
3844
- exact: true,
3845
- });
3846
- const formState = useFormState({
3847
- control,
3848
- name,
3849
- exact: true,
3850
- });
3851
- const _props = React.useRef(props);
3852
- const _registerProps = React.useRef(control.register(name, {
3853
- ...props.rules,
3854
- value,
3855
- ...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),
3856
- }));
3857
- _props.current = props;
3858
- const fieldState = React.useMemo(() => Object.defineProperties({}, {
3859
- invalid: {
3860
- enumerable: true,
3861
- get: () => !!get(formState.errors, name),
3862
- },
3863
- isDirty: {
3864
- enumerable: true,
3865
- get: () => !!get(formState.dirtyFields, name),
3866
- },
3867
- isTouched: {
3868
- enumerable: true,
3869
- get: () => !!get(formState.touchedFields, name),
3870
- },
3871
- isValidating: {
3872
- enumerable: true,
3873
- get: () => !!get(formState.validatingFields, name),
3874
- },
3875
- error: {
3876
- enumerable: true,
3877
- get: () => get(formState.errors, name),
3878
- },
3879
- }), [formState, name]);
3880
- const onChange = React.useCallback((event) => _registerProps.current.onChange({
3881
- target: {
3882
- value: getEventValue(event),
3883
- name: name,
3884
- },
3885
- type: EVENTS.CHANGE,
3886
- }), [name]);
3887
- const onBlur = React.useCallback(() => _registerProps.current.onBlur({
3888
- target: {
3889
- value: get(control._formValues, name),
3890
- name: name,
3891
- },
3892
- type: EVENTS.BLUR,
3893
- }), [name, control._formValues]);
3894
- const ref = React.useCallback((elm) => {
3895
- const field = get(control._fields, name);
3896
- if (field && elm) {
3897
- field._f.ref = {
3898
- focus: () => elm.focus && elm.focus(),
3899
- select: () => elm.select && elm.select(),
3900
- setCustomValidity: (message) => elm.setCustomValidity(message),
3901
- reportValidity: () => elm.reportValidity(),
3902
- };
3903
- }
3904
- }, [control._fields, name]);
3905
- const field = React.useMemo(() => ({
3906
- name,
3907
- value,
3908
- ...(isBoolean(disabled) || formState.disabled
3909
- ? { disabled: formState.disabled || disabled }
3910
- : {}),
3911
- onChange,
3912
- onBlur,
3913
- ref,
3914
- }), [name, disabled, formState.disabled, onChange, onBlur, ref, value]);
3915
- React.useEffect(() => {
3916
- const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
3917
- control.register(name, {
3918
- ..._props.current.rules,
3919
- ...(isBoolean(_props.current.disabled)
3920
- ? { disabled: _props.current.disabled }
3921
- : {}),
3922
- });
3923
- const updateMounted = (name, value) => {
3924
- const field = get(control._fields, name);
3925
- if (field && field._f) {
3926
- field._f.mount = value;
3927
- }
3928
- };
3929
- updateMounted(name, true);
3930
- if (_shouldUnregisterField) {
3931
- const value = cloneObject(get(control._options.defaultValues, name));
3932
- set(control._defaultValues, name, value);
3933
- if (isUndefined(get(control._formValues, name))) {
3934
- set(control._formValues, name, value);
3935
- }
3936
- }
3937
- !isArrayField && control.register(name);
3938
- return () => {
3939
- (isArrayField
3940
- ? _shouldUnregisterField && !control._state.action
3941
- : _shouldUnregisterField)
3942
- ? control.unregister(name)
3943
- : updateMounted(name, false);
3944
- };
3945
- }, [name, control, isArrayField, shouldUnregister]);
3946
- React.useEffect(() => {
3947
- control._setDisabledField({
3948
- disabled,
3949
- name,
3950
- });
3951
- }, [disabled, name, control]);
3952
- return React.useMemo(() => ({
3953
- field,
3954
- formState,
3955
- fieldState,
3956
- }), [field, formState, fieldState]);
3957
- }
3958
-
3959
- /**
3960
- * Component based on `useController` hook to work with controlled component.
3961
- *
3962
- * @remarks
3963
- * [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
3964
- *
3965
- * @param props - the path name to the form field value, and validation rules.
3966
- *
3967
- * @returns provide field handler functions, field and form state.
3968
- *
3969
- * @example
3970
- * ```tsx
3971
- * function App() {
3972
- * const { control } = useForm<FormValues>({
3973
- * defaultValues: {
3974
- * test: ""
3975
- * }
3976
- * });
3977
- *
3978
- * return (
3979
- * <form>
3980
- * <Controller
3981
- * control={control}
3982
- * name="test"
3983
- * render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
3984
- * <>
3985
- * <input
3986
- * onChange={onChange} // send value to hook form
3987
- * onBlur={onBlur} // notify when input is touched
3988
- * value={value} // return updated value
3989
- * ref={ref} // set ref for focus management
3990
- * />
3991
- * <p>{formState.isSubmitted ? "submitted" : ""}</p>
3992
- * <p>{fieldState.isTouched ? "touched" : ""}</p>
3993
- * </>
3994
- * )}
3995
- * />
3996
- * </form>
3997
- * );
3998
- * }
3999
- * ```
4000
- */
4001
- const Controller = (props) => props.render(useController(props));
4002
-
4003
3480
  const LSMLabelField = props => {
4004
3481
  const [lsmList, setLsmList] = useState([]);
4005
3482
  const {
4006
- name,
4007
3483
  label = "Label",
4008
- control,
4009
- defaultValue,
4010
3484
  onLsmSelect,
4011
3485
  fetchLsmData,
4012
3486
  formItemProps = {},
@@ -4029,32 +3503,22 @@ const LSMLabelField = props => {
4029
3503
  };
4030
3504
  loadLsmData();
4031
3505
  }, [fetchLsmData]);
4032
- return /*#__PURE__*/jsx(Controller, {
4033
- name: name,
4034
- control: control,
4035
- defaultValue: defaultValue,
4036
- render: _ref => {
4037
- let {
4038
- field
4039
- } = _ref;
4040
- return /*#__PURE__*/jsx(Form.Item, _objectSpread2(_objectSpread2({
4041
- label: label
4042
- }, formItemProps), {}, {
4043
- children: /*#__PURE__*/jsx(Select, _objectSpread2(_objectSpread2(_objectSpread2({}, field), selectProps), {}, {
4044
- options: lsmList,
4045
- fieldNames: fieldNames,
4046
- allowClear: true,
4047
- showSearch: true,
4048
- optionFilterProp: "label",
4049
- onChange: (value, option) => {
4050
- field.onChange(value);
4051
- onLsmSelect === null || onLsmSelect === void 0 || onLsmSelect(value === undefined ? undefined : option);
4052
- },
4053
- placeholder: selectProps.placeholder || 'Please select label'
4054
- }))
4055
- }));
4056
- }
4057
- });
3506
+ return /*#__PURE__*/jsx(Form.Item, _objectSpread2(_objectSpread2({
3507
+ label: label
3508
+ }, formItemProps), {}, {
3509
+ children: /*#__PURE__*/jsx(Select, _objectSpread2(_objectSpread2(_objectSpread2({}, field), selectProps), {}, {
3510
+ options: lsmList,
3511
+ fieldNames: fieldNames,
3512
+ allowClear: true,
3513
+ showSearch: true,
3514
+ optionFilterProp: "label",
3515
+ onChange: (value, option) => {
3516
+ field.onChange(value);
3517
+ onLsmSelect === null || onLsmSelect === void 0 || onLsmSelect(value === undefined ? undefined : option);
3518
+ },
3519
+ placeholder: selectProps.placeholder || 'Please select label'
3520
+ }))
3521
+ }));
4058
3522
  };
4059
3523
  var LSMLabelField$1 = /*#__PURE__*/memo(LSMLabelField);
4060
3524