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