@mw-kit/mw-ui 1.7.116 → 1.7.118
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 +113 -86
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +113 -86
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'semantic-ui-css/semantic.min.css';
|
|
2
|
-
import React__default, { useState, useEffect, useCallback, useImperativeHandle, createElement } from 'react';
|
|
2
|
+
import React__default, { useState, useEffect, useCallback, useImperativeHandle, createElement, useRef, useMemo } from 'react';
|
|
3
3
|
import styled, { css, keyframes, createGlobalStyle, ThemeProvider as ThemeProvider$1 } from 'styled-components';
|
|
4
4
|
import { Icon as Icon$1, Popup } from 'semantic-ui-react';
|
|
5
5
|
export * from 'semantic-ui-react';
|
|
@@ -12256,29 +12256,26 @@ const Loader = styled.div(_t2$3 || (_t2$3 = _$3`
|
|
|
12256
12256
|
`), fill, zIndex || 1, size, size, size, size, borderSize, beforeColor, loader, afterColor);
|
|
12257
12257
|
});
|
|
12258
12258
|
|
|
12259
|
-
const isMaskFunction = value =>
|
|
12260
|
-
return typeof value === 'function';
|
|
12261
|
-
};
|
|
12259
|
+
const isMaskFunction = value => typeof value === 'function';
|
|
12262
12260
|
|
|
12263
|
-
const isMaskReplace = value =>
|
|
12264
|
-
return Array.isArray(value) && value[0] instanceof RegExp;
|
|
12265
|
-
};
|
|
12261
|
+
const isMaskReplace = value => Array.isArray(value) && value[0] instanceof RegExp;
|
|
12266
12262
|
|
|
12267
|
-
const isMaskReplaceArray = value =>
|
|
12268
|
-
return Array.isArray(value) && Array.isArray(value[0]);
|
|
12269
|
-
};
|
|
12263
|
+
const isMaskReplaceArray = value => Array.isArray(value) && Array.isArray(value[0]);
|
|
12270
12264
|
|
|
12271
12265
|
const getMask = mask => {
|
|
12272
12266
|
if (isMaskFunction(mask)) {
|
|
12273
12267
|
return mask;
|
|
12274
|
-
}
|
|
12268
|
+
}
|
|
12269
|
+
|
|
12270
|
+
if (isMaskReplace(mask)) {
|
|
12275
12271
|
const [find, replace] = mask;
|
|
12276
12272
|
return value => value.replace(find, replace);
|
|
12277
|
-
}
|
|
12273
|
+
}
|
|
12274
|
+
|
|
12275
|
+
if (isMaskReplaceArray(mask)) {
|
|
12278
12276
|
return value => {
|
|
12279
12277
|
let newValue = value;
|
|
12280
|
-
mask.forEach(
|
|
12281
|
-
const [find, replace] = e;
|
|
12278
|
+
mask.forEach(([find, replace]) => {
|
|
12282
12279
|
newValue = newValue.replace(find, replace);
|
|
12283
12280
|
});
|
|
12284
12281
|
return newValue;
|
|
@@ -12288,6 +12285,64 @@ const getMask = mask => {
|
|
|
12288
12285
|
return value => value;
|
|
12289
12286
|
};
|
|
12290
12287
|
|
|
12288
|
+
const defaultValue = {
|
|
12289
|
+
isRequired: () => false,
|
|
12290
|
+
isInvalid: () => false,
|
|
12291
|
+
isViewMode: () => false,
|
|
12292
|
+
isDisabled: () => false
|
|
12293
|
+
};
|
|
12294
|
+
const Context = React__default.createContext({ ...defaultValue
|
|
12295
|
+
});
|
|
12296
|
+
|
|
12297
|
+
const useContext = name => {
|
|
12298
|
+
const context = React__default.useContext(Context);
|
|
12299
|
+
return {
|
|
12300
|
+
isRequired: () => false,
|
|
12301
|
+
isInvalid: () => false,
|
|
12302
|
+
isViewMode: () => false,
|
|
12303
|
+
isDisabled: () => false,
|
|
12304
|
+
...(name ? {
|
|
12305
|
+
isRequired: () => context.isRequired(name),
|
|
12306
|
+
isInvalid: () => context.isInvalid(name),
|
|
12307
|
+
isViewMode: () => context.isViewMode(name),
|
|
12308
|
+
isDisabled: () => context.isDisabled(name)
|
|
12309
|
+
} : {})
|
|
12310
|
+
};
|
|
12311
|
+
};
|
|
12312
|
+
|
|
12313
|
+
const Provider = props => {
|
|
12314
|
+
return React__default.createElement(Context.Provider, Object.assign({}, props, {
|
|
12315
|
+
value: { ...defaultValue,
|
|
12316
|
+
...props.value
|
|
12317
|
+
}
|
|
12318
|
+
}));
|
|
12319
|
+
};
|
|
12320
|
+
|
|
12321
|
+
const Form = Object.assign(React__default.forwardRef(Object.assign((props, ref) => {
|
|
12322
|
+
const formProps = filterObject(props, ['isRequired', 'isInvalid', 'isViewMode', 'isDisabled']);
|
|
12323
|
+
return React__default.createElement(Provider, {
|
|
12324
|
+
value: { ...(props.isRequired ? {
|
|
12325
|
+
isRequired: props.isRequired
|
|
12326
|
+
} : {}),
|
|
12327
|
+
...(props.isInvalid ? {
|
|
12328
|
+
isInvalid: props.isInvalid
|
|
12329
|
+
} : {}),
|
|
12330
|
+
...(props.isViewMode ? {
|
|
12331
|
+
isViewMode: props.isViewMode
|
|
12332
|
+
} : {}),
|
|
12333
|
+
...(props.isDisabled ? {
|
|
12334
|
+
isDisabled: props.isDisabled
|
|
12335
|
+
} : {})
|
|
12336
|
+
}
|
|
12337
|
+
}, React__default.createElement("form", Object.assign({
|
|
12338
|
+
ref: ref
|
|
12339
|
+
}, formProps)));
|
|
12340
|
+
}, {
|
|
12341
|
+
displayName: 'Form'
|
|
12342
|
+
})), {
|
|
12343
|
+
useContext
|
|
12344
|
+
});
|
|
12345
|
+
|
|
12291
12346
|
const updateTitle = event => {
|
|
12292
12347
|
let target = event.target;
|
|
12293
12348
|
|
|
@@ -12673,64 +12728,20 @@ const ViewModeContainer = styled.div(_t21$1 || (_t21$1 = _$5`
|
|
|
12673
12728
|
`));
|
|
12674
12729
|
});
|
|
12675
12730
|
|
|
12676
|
-
const
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
isRequired: () => false,
|
|
12689
|
-
isInvalid: () => false,
|
|
12690
|
-
isViewMode: () => false,
|
|
12691
|
-
isDisabled: () => false,
|
|
12692
|
-
...(name ? {
|
|
12693
|
-
isRequired: () => context.isRequired(name),
|
|
12694
|
-
isInvalid: () => context.isInvalid(name),
|
|
12695
|
-
isViewMode: () => context.isViewMode(name),
|
|
12696
|
-
isDisabled: () => context.isDisabled(name)
|
|
12697
|
-
} : {})
|
|
12698
|
-
};
|
|
12699
|
-
};
|
|
12700
|
-
|
|
12701
|
-
const Provider = props => {
|
|
12702
|
-
return React__default.createElement(Context.Provider, Object.assign({}, props, {
|
|
12703
|
-
value: { ...defaultValue,
|
|
12704
|
-
...props.value
|
|
12705
|
-
}
|
|
12706
|
-
}));
|
|
12731
|
+
const setMask = (event, handler, setValue, maskFn) => {
|
|
12732
|
+
const target = event.target;
|
|
12733
|
+
const raw = target.value;
|
|
12734
|
+
const masked = maskFn(raw);
|
|
12735
|
+
const [start, end] = target.selectionStart === target.selectionEnd && target.selectionEnd === target.value.length ? [masked.length, masked.length] : [target.selectionStart, target.selectionEnd];
|
|
12736
|
+
target.value = masked;
|
|
12737
|
+
handler && handler(event);
|
|
12738
|
+
setValue(masked);
|
|
12739
|
+
|
|
12740
|
+
if (['text', 'search', 'url', 'password'].includes(target.type)) {
|
|
12741
|
+
target.setSelectionRange(start, end);
|
|
12742
|
+
}
|
|
12707
12743
|
};
|
|
12708
12744
|
|
|
12709
|
-
const Form = Object.assign(React__default.forwardRef(Object.assign((props, ref) => {
|
|
12710
|
-
const formProps = filterObject(props, ['isRequired', 'isInvalid', 'isViewMode', 'isDisabled']);
|
|
12711
|
-
return React__default.createElement(Provider, {
|
|
12712
|
-
value: { ...(props.isRequired ? {
|
|
12713
|
-
isRequired: props.isRequired
|
|
12714
|
-
} : {}),
|
|
12715
|
-
...(props.isInvalid ? {
|
|
12716
|
-
isInvalid: props.isInvalid
|
|
12717
|
-
} : {}),
|
|
12718
|
-
...(props.isViewMode ? {
|
|
12719
|
-
isViewMode: props.isViewMode
|
|
12720
|
-
} : {}),
|
|
12721
|
-
...(props.isDisabled ? {
|
|
12722
|
-
isDisabled: props.isDisabled
|
|
12723
|
-
} : {})
|
|
12724
|
-
}
|
|
12725
|
-
}, React__default.createElement("form", Object.assign({
|
|
12726
|
-
ref: ref
|
|
12727
|
-
}, formProps)));
|
|
12728
|
-
}, {
|
|
12729
|
-
displayName: 'Form'
|
|
12730
|
-
})), {
|
|
12731
|
-
useContext
|
|
12732
|
-
});
|
|
12733
|
-
|
|
12734
12745
|
const Input$1 = React__default.forwardRef((props, ref) => {
|
|
12735
12746
|
var _props$icon;
|
|
12736
12747
|
|
|
@@ -12746,18 +12757,23 @@ const Input$1 = React__default.forwardRef((props, ref) => {
|
|
|
12746
12757
|
width
|
|
12747
12758
|
} = { ...props
|
|
12748
12759
|
};
|
|
12760
|
+
|
|
12761
|
+
const setValue = props.setValue || (() => {});
|
|
12762
|
+
|
|
12749
12763
|
const {
|
|
12750
12764
|
isRequired,
|
|
12751
12765
|
isInvalid,
|
|
12752
12766
|
isViewMode,
|
|
12753
12767
|
isDisabled
|
|
12754
12768
|
} = Form.useContext(props.name);
|
|
12755
|
-
const
|
|
12769
|
+
const isComposing = useRef(false);
|
|
12770
|
+
const maskFn = useMemo(() => getMask(props.mask), [props.mask]);
|
|
12756
12771
|
useEffect(() => {
|
|
12772
|
+
if (isComposing.current) return;
|
|
12757
12773
|
if (!isString(props.value)) return;
|
|
12758
|
-
const masked =
|
|
12774
|
+
const masked = maskFn(props.value);
|
|
12759
12775
|
if (masked !== props.value) setValue(masked);
|
|
12760
|
-
}, [props.value]);
|
|
12776
|
+
}, [isComposing.current, props.value]);
|
|
12761
12777
|
const invalid = isInvalid() || props.invalid;
|
|
12762
12778
|
const required = isRequired() || props.required;
|
|
12763
12779
|
const disabled = isDisabled() || props.disabled;
|
|
@@ -12770,20 +12786,14 @@ const Input$1 = React__default.forwardRef((props, ref) => {
|
|
|
12770
12786
|
$paddingless: paddingless
|
|
12771
12787
|
});
|
|
12772
12788
|
|
|
12773
|
-
const onChange = inputProps.onChange || (() => {});
|
|
12774
|
-
|
|
12775
|
-
const setValue = props.setValue || (() => {});
|
|
12776
|
-
|
|
12777
12789
|
inputProps.onChange = event => {
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
setValue(event.target.value);
|
|
12783
|
-
|
|
12784
|
-
if (['text', 'search', 'url', 'password'].includes(event.target.type)) {
|
|
12785
|
-
event.target.setSelectionRange(start, end);
|
|
12790
|
+
if (isComposing.current) {
|
|
12791
|
+
props.onChange && props.onChange(event);
|
|
12792
|
+
setValue(event.target.value);
|
|
12793
|
+
return;
|
|
12786
12794
|
}
|
|
12795
|
+
|
|
12796
|
+
setMask(event, props.onChange, setValue, maskFn);
|
|
12787
12797
|
};
|
|
12788
12798
|
|
|
12789
12799
|
if (inputProps.onKeyDown || onPressEnter) {
|
|
@@ -12825,6 +12835,18 @@ const Input$1 = React__default.forwardRef((props, ref) => {
|
|
|
12825
12835
|
};
|
|
12826
12836
|
}
|
|
12827
12837
|
|
|
12838
|
+
inputProps.onCompositionStart = event => {
|
|
12839
|
+
var _props$onCompositionS;
|
|
12840
|
+
|
|
12841
|
+
isComposing.current = true;
|
|
12842
|
+
(_props$onCompositionS = props.onCompositionStart) === null || _props$onCompositionS === void 0 ? void 0 : _props$onCompositionS.call(props, event);
|
|
12843
|
+
};
|
|
12844
|
+
|
|
12845
|
+
inputProps.onCompositionEnd = event => {
|
|
12846
|
+
isComposing.current = false;
|
|
12847
|
+
setMask(event, props.onCompositionEnd, setValue, maskFn);
|
|
12848
|
+
};
|
|
12849
|
+
|
|
12828
12850
|
if (inputProps.onKeyUpCapture) {
|
|
12829
12851
|
const onKeyUpCapture = inputProps.onKeyUpCapture;
|
|
12830
12852
|
|
|
@@ -17568,10 +17590,12 @@ let _$E = t => t,
|
|
|
17568
17590
|
_t5$c,
|
|
17569
17591
|
_t6$a,
|
|
17570
17592
|
_t7$a;
|
|
17593
|
+
const size$1 = '17px';
|
|
17571
17594
|
const LabelContainer$5 = styled.div(_t$E || (_t$E = _$E`
|
|
17572
17595
|
${0}
|
|
17573
17596
|
display: flex;
|
|
17574
17597
|
align-items: center;
|
|
17598
|
+
overflow: hidden;
|
|
17575
17599
|
`), ({
|
|
17576
17600
|
theme
|
|
17577
17601
|
}) => theme.useTypography('p'));
|
|
@@ -17579,6 +17603,9 @@ const Label$6 = styled.label(_t2$t || (_t2$t = _$E`
|
|
|
17579
17603
|
display: flex;
|
|
17580
17604
|
gap: ${0};
|
|
17581
17605
|
|
|
17606
|
+
min-height: ${0};
|
|
17607
|
+
min-width: ${0};
|
|
17608
|
+
|
|
17582
17609
|
${0}
|
|
17583
17610
|
|
|
17584
17611
|
${0}
|
|
@@ -17641,7 +17668,7 @@ ${0}
|
|
|
17641
17668
|
}
|
|
17642
17669
|
`), ({
|
|
17643
17670
|
theme
|
|
17644
|
-
}) => theme.spacings.s1, ({
|
|
17671
|
+
}) => theme.spacings.s1, size$1, size$1, ({
|
|
17645
17672
|
disabled
|
|
17646
17673
|
}) => {
|
|
17647
17674
|
if (!disabled) {
|