@platforma-sdk/ui-vue 1.42.1 → 1.42.3
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/.turbo/turbo-build.log +16 -15
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/components/PlMultiSequenceAlignment/Toolbar.vue2.js +15 -15
- package/dist/internal/createAppV2.d.ts.map +1 -1
- package/dist/internal/createAppV2.js +64 -55
- package/dist/internal/createAppV2.js.map +1 -1
- package/dist/lib/ui/uikit/dist/components/DataTable/TableComponent.vue.js +1 -1
- package/dist/lib/ui/uikit/dist/components/PlAccordion/{ExpandTransition.vue.js → ExpandTransition.vue2.js} +1 -1
- package/dist/lib/ui/uikit/dist/components/PlAccordion/ExpandTransition.vue2.js.map +1 -0
- package/dist/lib/ui/uikit/dist/components/PlAccordion/PlAccordionSection.vue2.js +1 -1
- package/dist/lib/ui/uikit/dist/components/PlNumberField/PlNumberField.vue.js +91 -103
- package/dist/lib/ui/uikit/dist/components/PlNumberField/PlNumberField.vue.js.map +1 -1
- package/dist/lib/ui/uikit/dist/components/PlNumberField/parseNumber.js +77 -0
- package/dist/lib/ui/uikit/dist/components/PlNumberField/parseNumber.js.map +1 -0
- package/dist/lib/ui/uikit/dist/components/PlSlideModal/PlPureSlideModal.vue.js +4 -4
- package/dist/node_modules/.pnpm/@vueuse_core@13.3.0_vue@3.5.13_typescript@5.6.3_/node_modules/@vueuse/core/index.js +44 -41
- package/dist/node_modules/.pnpm/@vueuse_shared@13.3.0_vue@3.5.13_typescript@5.6.3_/node_modules/@vueuse/shared/index.js +122 -67
- package/dist/node_modules/.pnpm/@vueuse_shared@13.3.0_vue@3.5.13_typescript@5.6.3_/node_modules/@vueuse/shared/index.js.map +1 -1
- package/package.json +5 -5
- package/src/internal/createAppV2.ts +22 -13
- package/dist/lib/ui/uikit/dist/components/PlAccordion/ExpandTransition.vue.js.map +0 -1
|
@@ -56,7 +56,7 @@ import "../../colors/gradient.js";
|
|
|
56
56
|
.resizable-input{position:relative;box-sizing:border-box;padding:0 8px;display:inline-block;max-width:100%;text-overflow:ellipsis;overflow:hidden}.resizable-input__size-span{font-family:inherit;white-space:pre;display:inline-block;font-size:inherit;line-height:inherit;box-sizing:border-box;position:relative;left:0;opacity:0;min-width:2px;-webkit-user-select:none;user-select:none;vertical-align:top}.resizable-input input{border:none;outline:none;height:100%;text-overflow:ellipsis;font-family:inherit;background:none;color:inherit;top:0;left:0;right:0;font-size:inherit;line-height:inherit;position:absolute;box-sizing:border-box}
|
|
57
57
|
.pl-dropdown-multi{--contour-color: var(--txt-01);--contour-border-width: 1px;--options-bg: #fff;--option-hover-bg: var(--btn-sec-hover-grey);--label-offset-left-x: 8px;--label-offset-right-x: 8px;--label-color: var(--txt-01);position:relative;outline:none;min-height:var(--control-height);border-radius:6px;font-family:var(--font-family-base);font-size:var(--font-size-base);font-weight:var(--font-weigh-base)}[data-theme=dark] .pl-dropdown-multi{--options-bg: #1B1B1F}.pl-dropdown-multi__envelope{font-family:var(--control-font-family);min-width:160px}.pl-dropdown-multi label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-dropdown-multi label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-dropdown-multi__container{position:absolute;top:0;left:0;right:0;border-radius:6px;min-height:var(--control-height);padding:1px;color:var(--txt-01)}.pl-dropdown-multi__contour{border-radius:var(--border-radius-control);border:var(--contour-border-width) solid var(--contour-color);box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-dropdown-multi__options{position:absolute;top:0;z-index:var(--z-dropdown-options);border:1px solid var(--border-color-div-grey);background-color:var(--pl-dropdown-options-bg);border-radius:6px;max-height:244px;box-shadow:0 4px 12px -2px #0f244d14,0 6px 24px -2px #0f244d14;--thumb-color: var(--ic-02);overflow-y:auto}.pl-dropdown-multi__options::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-dropdown-multi__options::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-dropdown-multi__options::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-dropdown-multi__options .nothing-found{padding:0 10px;height:var(--control-height);line-height:20px;background-color:#fff;opacity:.5;font-style:italic}.pl-dropdown-multi__options .option{position:relative;padding:0 10px;height:var(--control-height);line-height:20px;cursor:pointer;-webkit-user-select:none;user-select:none;display:flex;align-items:center;gap:12px;--base-icon: url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.5%204.5H4.5L4.5%2019.5H19.5V4.5ZM4.5%203C3.67157%203%203%203.67157%203%204.5V19.5C3%2020.3284%203.67157%2021%204.5%2021H19.5C20.3284%2021%2021%2020.3284%2021%2019.5V4.5C21%203.67157%2020.3284%203%2019.5%203H4.5Z'%20fill='%23110529'/%3e%3c/svg%3e");--checked-icon: url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='3'%20y='3'%20width='18'%20height='18'%20rx='2'%20fill='%23110529'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M17.5431%208.51739L10.3333%2016.0877L6.45691%2012.0174L7.54312%2010.9829L10.3333%2013.9127L16.4569%207.48291L17.5431%208.51739Z'%20fill='white'/%3e%3c/svg%3e")}.pl-dropdown-multi__options .option .pl-dropdown-multi__checkmark{cursor:pointer;outline:none;border-radius:4px;background:var(--base-icon) no-repeat center;width:24px;height:24px}[data-theme=dark] .pl-dropdown-multi__options .option .pl-dropdown-multi__checkmark{--base-icon: url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.5%204.5H4.5L4.5%2019.5H19.5V4.5ZM4.5%203C3.67157%203%203%203.67157%203%204.5V19.5C3%2020.3284%203.67157%2021%204.5%2021H19.5C20.3284%2021%2021%2020.3284%2021%2019.5V4.5C21%203.67157%2020.3284%203%2019.5%203H4.5Z'%20fill='white'/%3e%3c/svg%3e");--checked-icon: url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='3'%20y='3'%20width='18'%20height='18'%20rx='2'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M17.5431%208.51739L10.3333%2016.0877L6.45691%2012.0174L7.54312%2010.9829L10.3333%2013.9127L16.4569%207.48291L17.5431%208.51739Z'%20fill='%23110529'/%3e%3c/svg%3e")}.pl-dropdown-multi__options .option>span{display:block;overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis}.pl-dropdown-multi__options .option.selected{background-color:var(--color-active-select)}.pl-dropdown-multi__options .option.selected .pl-dropdown-multi__checkmark{background:var(--checked-icon) no-repeat center;width:24px;height:24px}.pl-dropdown-multi__options .option.active:not(.selected){background-color:var(--option-hover-bg)}.pl-dropdown-multi__options .option:hover{background-color:var(--option-hover-bg)}.pl-dropdown-multi__field{position:relative;border-radius:6px;overflow:hidden;background:transparent;padding-left:11px;min-height:var(--control-height);line-height:20px;cursor:pointer;display:flex;flex-direction:row;align-items:center}.pl-dropdown-multi__field .chips-container{position:absolute;top:0;left:0;bottom:0;right:30px;overflow:hidden;padding:0 60px 0 11px;line-height:20px;color:var(--contour-color);display:flex;gap:8px;align-items:center}.pl-dropdown-multi__field input{min-height:calc(var(--control-height) - 2px);line-height:20px;font-family:inherit;font-size:inherit;background-color:transparent;border:none;padding:0;width:calc(100% - 20px);color:var(--txt-01);caret-color:var(--border-color-focus)}.pl-dropdown-multi__field input:focus{outline:none}.pl-dropdown-multi__field input:placeholder-shown{text-overflow:ellipsis}.pl-dropdown-multi__field input::placeholder{color:var(--color-placeholder)}.pl-dropdown-multi__field:hover .clear{display:block}.pl-dropdown-multi__controls{display:flex;flex-direction:row;align-items:center;gap:6px;margin-left:auto}.pl-dropdown-multi__controls .mask-16,.pl-dropdown-multi__controls .mask-24{--icon-color: var(--control-mask-fill);cursor:pointer}.pl-dropdown-multi__controls .mask-loading{--icon-color: var(--ic-accent);animation:spin 2.5s linear infinite}.pl-dropdown-multi__arrow-wrapper{display:flex;align-items:center;min-height:var(--control-height);padding-right:11px}.pl-dropdown-multi .arrow-icon{cursor:pointer}.pl-dropdown-multi .arrow-icon.arrow-icon-default{transition:transform .2s;background-color:var(--control-mask-fill);mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.46967%206.53033L3.53033%205.46967L8%209.93934L12.4697%205.46967L13.5303%206.53033L8%2012.0607L2.46967%206.53033Z'%20fill='%23110529'/%3e%3c/svg%3e");-webkit-mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.46967%206.53033L3.53033%205.46967L8%209.93934L12.4697%205.46967L13.5303%206.53033L8%2012.0607L2.46967%206.53033Z'%20fill='%23110529'/%3e%3c/svg%3e");mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;mask-position:center;-webkit-mask-position:center;mask-size:16px;-webkit-mask-size:16px;width:16px;height:16px}.pl-dropdown-multi__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-dropdown-multi__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-dropdown-multi.open .arrow-icon.arrow-icon-default{background-color:var(--control-mask-fill);transform:rotate(-180deg)}.pl-dropdown-multi .clear{display:none;position:absolute;top:50%;transform:translateY(-50%);right:36px;z-index:1;background:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_586_7851)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8%2016C12.4183%2016%2016%2012.4183%2016%208C16%203.58172%2012.4183%200%208%200C3.58172%200%200%203.58172%200%208C0%2012.4183%203.58172%2016%208%2016ZM4.46967%205.53033L6.93934%208L4.46967%2010.4697L5.53033%2011.5303L8%209.06066L10.4697%2011.5303L11.5303%2010.4697L9.06066%208L11.5303%205.53033L10.4697%204.46967L8%206.93934L5.53033%204.46967L4.46967%205.53033Z'%20fill='%23CFD1DB'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_586_7851'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e") no-repeat center;width:16px;height:16px;cursor:pointer}.pl-dropdown-multi.open,.pl-dropdown-multi:focus-within{z-index:1}.pl-dropdown-multi.open .pl-dropdown-multi__container .label,.pl-dropdown-multi:focus-within .pl-dropdown-multi__container .label{color:var(--txt-focus)}.pl-dropdown-multi.open .pl-dropdown-multi__container{z-index:1000}.pl-dropdown-multi.open .pl-dropdown-multi__field{border-radius:6px 6px 0 0}.pl-dropdown-multi.open .arrow{background-color:var(--control-mask-fill);mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8%204.93933L13.5303%2010.4697L12.4697%2011.5303L8%207.06065L3.53033%2011.5303L2.46967%2010.4697L8%204.93933Z'%20fill='%23110529'/%3e%3c/svg%3e");-webkit-mask-image:url("data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8%204.93933L13.5303%2010.4697L12.4697%2011.5303L8%207.06065L3.53033%2011.5303L2.46967%2010.4697L8%204.93933Z'%20fill='%23110529'/%3e%3c/svg%3e");mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;mask-position:center;-webkit-mask-position:center;mask-size:16px;-webkit-mask-size:16px;width:16px;height:16px}.pl-dropdown-multi:hover{--contour-color: var(--control-hover-color)}.pl-dropdown-multi:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-dropdown-multi:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-dropdown-multi.error{--contour-color: var(--txt-error);--label-color: var(--txt-error)}.pl-dropdown-multi.disabled{--contour-color: var(--color-dis-01);--control-mask-fill: var(--color-dis-01);--label-color: var(--color-dis-01);cursor:not-allowed;pointer-events:none}.pl-dropdown-multi.disabled .mask-loading{animation:spin 2.5s linear infinite;--icon-color: var(--ic-accent)}.pl-dropdown-multi__open-chips-container{padding:12px}.pl-dropdown-multi__open-chips-container .pl-chip{margin-right:4px;margin-bottom:4px}
|
|
58
58
|
.pl-log-view{--log-background: var(--bg-base-light);--contour-color: var(--txt-01);--contour-border-width: 1px;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--border-color-log-view: var(--border-color-div-grey);height:100%;max-height:calc(100% - var(--contour-offset));max-width:calc(100% - var(--contour-offset));border-radius:6px;background:var(--log-background);display:flex;position:relative;min-height:44px;padding-right:40px}.pl-log-view__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--border-color-log-view);border-style:solid;box-shadow:none;z-index:0;pointer-events:none}.pl-log-view label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-log-view label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-log-view.has-error{--log-background: linear-gradient(90deg, #FFEBEB 0%, #FFFFFF 100%);--border-color-log-view: var(--border-color-error)}.pl-log-view__copy{position:absolute;top:12px;right:12px;cursor:pointer}.pl-log-view__copy .mask-24{--icon-color: var(--ic-02)}.pl-log-view__copy:hover .mask-24{--icon-color: var(--txt-01)}.pl-log-view__content{margin:12px;max-height:100%;max-width:100%;flex:1;color:var(--txt-01);font-feature-settings:"ss11" on,"ss15" on,"ss17" on;font-family:var(--font-family-monospace);white-space:pre;font-size:14px;font-weight:400;line-height:20px;--thumb-color: var(--ic-02);overflow-y:auto;overflow-x:auto}.pl-log-view__content::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-log-view__content::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-log-view__content::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-log-view__error{margin:12px;max-height:100%;max-width:100%;flex:1;color:var(--txt-01);font-feature-settings:"ss11" on,"ss15" on,"ss17" on;font-family:var(--font-family-monospace);white-space:pre;font-size:14px;font-weight:400;line-height:20px;--thumb-color: var(--ic-02);overflow-y:auto;overflow-x:auto}.pl-log-view__error::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-log-view__error::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-log-view__error::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}
|
|
59
|
-
.
|
|
59
|
+
.pl-number-field{--contour-color: var(--txt-01);--contour-border-width: 1px;--options-bg: #fff;--option-hover-bg: var(--btn-sec-hover-grey);--label-offset-left-x: 8px;--label-offset-right-x: 8px;--label-color: var(--txt-01);--color-hint: #9d9eae}.pl-number-field ::placeholder{color:#cfd1db;opacity:1}.pl-number-field__main-wrapper{height:40px;position:relative}.pl-number-field__wrapper{padding-left:12px;border-radius:6px}.pl-number-field__wrapper.withoutArrows{padding-right:12px}.pl-number-field__icons{width:40px;border-radius:0 6px 6px 0;border-left:1px solid var(--contour-color)}.pl-number-field__icon{line-height:0}.pl-number-field__icon.disabled{cursor:not-allowed;position:relative;z-index:1}.pl-number-field__icon.disabled svg path{fill:#cfd1db}.pl-number-field__icon:hover{background-color:#9babcc29}.pl-number-field__icon:first-child{border-bottom:1px solid var(--contour-color)}.pl-number-field__hint{margin-top:3px;color:var(--color-hint)}.pl-number-field__error{margin-top:3px;color:var(--txt-error);font-size:12px;font-weight:500;line-height:16px}.pl-number-field input{outline:none;border:none;width:100%;background:unset;text-overflow:ellipsis}.pl-number-field__contour{border-radius:var(--border-radius-control);border:var(--contour-border-width) solid var(--contour-color);box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none;transition:all .3s}.pl-number-field:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-number-field:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-number-field.error{--contour-color: var(--txt-error);--label-color: var(--txt-error);--color-hint: var(--txt-error)}.pl-number-field.disabled{--contour-color: var(--color-dis-01);--control-mask-fill: var(--color-dis-01);cursor:not-allowed}.pl-number-field.disabled label,.pl-number-field.disabled .mi-number-field__hint,.pl-number-field.disabled input{color:var(--contour-color)}.pl-number-field.disabled svg path{fill:var(--contour-color)}.pl-number-field.disabled .mi-number-field__icons{pointer-events:none}.pl-number-field label{position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);display:flex;align-items:center;padding:0 4px;overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);transition:color .3s}.pl-number-field label .required{display:inline-block;font-weight:500;font-size:12px;line-height:16px;color:var(--txt-error);margin-right:4px}
|
|
60
60
|
.progress-cell{background-color:transparent;height:100%;position:relative;width:100%;overflow:hidden;border-radius:2px}.progress-cell .mask-error{--icon-color: var(--txt-error)}.progress-cell.not-started *{color:var(--txt-03)!important}.progress-cell.error *{color:var(--txt-error)!important}.progress-cell__white-bg{background-color:#fff}.progress-cell__indicator{position:absolute;height:100%;transition:width .4s ease-in-out;background:linear-gradient(90deg,#fff,#d8fac8);transition:width .2s ease-in-out}.progress-cell__body{padding:0 15px;display:flex;gap:12px;align-items:center;height:100%;width:100%;position:absolute;z-index:1}.progress-cell__stage{overflow:hidden;text-overflow:ellipsis;flex-shrink:1;text-wrap:nowrap}.progress-cell__percentage{flex-grow:1;flex-shrink:0;text-align:right}.progress-cell__stage--queued{color:var(--txt-03)}.progress-cell__infinity-loader{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;animation:move-gradient 2s linear infinite}.progress-cell__infinity-gradient{width:50%;height:100%;background:linear-gradient(90deg,#fff,#d8fac8,#fff)}@keyframes move-gradient{0%{transform:translate(-50%)}to{transform:translate(100%)}}
|
|
61
61
|
.pl-slide-modal{--padding-top: 0;--padding-bottom: 0;position:absolute;top:var(--title-bar-height);right:0;bottom:0;z-index:var(--z-slide-dialog);display:flex;flex-direction:column;padding-top:var(--padding-top);padding-bottom:var(--padding-bottom);min-width:368px;width:368px;max-width:100%;will-change:transform;background-color:#fff;border-left:1px solid var(--div-grey);box-shadow:0 8px 16px -4px #0f244d29,0 12px 32px -4px #0f244d29}.pl-slide-modal .close-dialog-btn{position:absolute;z-index:1;top:12px;right:12px;cursor:pointer;background-color:#d3d7e0;mask-image:url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.99954%2018L11.9995%2012M11.9995%2012L17.9995%206M11.9995%2012L5.99954%206M11.9995%2012L17.9995%2018'%20stroke='%23110529'%20stroke-width='1.5'/%3e%3c/svg%3e");-webkit-mask-image:url("data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.99954%2018L11.9995%2012M11.9995%2012L17.9995%206M11.9995%2012L5.99954%206M11.9995%2012L17.9995%2018'%20stroke='%23110529'%20stroke-width='1.5'/%3e%3c/svg%3e");mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;mask-position:center;-webkit-mask-position:center;mask-size:24px;-webkit-mask-size:24px;width:24px;height:24px}.pl-slide-modal .close-dialog-btn:hover{background-color:var(--main-dark-color)}.pl-slide-modal.has-title{--padding-top: 0}.pl-slide-modal.has-actions{--padding-bottom: 0}.pl-slide-modal__title{display:flex;align-items:center;font-family:var(--font-family-base);font-size:28px;font-style:normal;font-weight:500;line-height:40px;letter-spacing:-.56px;padding:24px;width:100%;overflow:hidden}.pl-slide-modal__title-content{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;word-break:break-word}.pl-slide-modal__actions{display:flex;align-items:center;gap:6px;min-height:88px;padding:0 24px}.pl-slide-modal__actions button{min-width:160px}.pl-slide-modal__content{flex:1;display:flex;flex-direction:column;gap:24px;padding:16px calc(24px - var(--scrollbar-width)) 16px 24px;margin:0;--thumb-color: var(--ic-02);overflow-y:auto;scrollbar-gutter:stable}.pl-slide-modal__content::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.pl-slide-modal__content::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.pl-slide-modal__content::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.pl-slide-modal__shadow{position:absolute;z-index:var(--z-slide-shadow);top:var(--title-bar-height);left:0;right:0;bottom:0;background-color:#000000a3}
|
|
62
62
|
.pl-status-tag{border-radius:4px;border:1px solid var(--txt-01);padding:2px 8px;width:fit-content;height:24px}.pl-status-tag.ok{background:var(--notification-success)}.pl-status-tag.warn{background:var(--notification-warning)}.pl-status-tag.alert{background:var(--notification-error)}.pl-status-tag.hold{background:var(--notification-neutral)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandTransition.vue2.js","sources":["../../../../../../../../../lib/ui/uikit/src/components/PlAccordion/ExpandTransition.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nconst onStart = (el: Element) => {\n el.classList.add('expand-collapse-fix');\n (el as HTMLElement).style.setProperty('--component-height', el.scrollHeight + 'px');\n};\n\nconst onAfter = (el: Element) => {\n (el as HTMLElement).style.removeProperty('--component-height');\n el.classList.remove('expand-collapse-fix');\n};\n</script>\n\n<template>\n <Transition name=\"expand-collapse\" @enter=\"onStart\" @leave=\"onStart\" @after-enter=\"onAfter\" @after-leave=\"onAfter\">\n <slot/>\n </Transition>\n</template>\n\n<style>\n.expand-collapse-fix {\n overflow: hidden;\n}\n\n.expand-collapse-enter-active,\n.expand-collapse-leave-active {\n transition:\n height 0.2s ease-in-out,\n opacity 0.2s ease-in-out;\n height: var(--component-height);\n}\n\n.expand-collapse-enter-from,\n.expand-collapse-leave-to {\n opacity: 0.5;\n height: 0;\n}\n</style>\n"],"names":["onStart","el","onAfter"],"mappings":";;;;AACMA,UAAAA,IAAU,CAACC,MAAgB;AAC5BA,QAAA,UAAU,IAAI,qBAAqB,GACrCA,EAAmB,MAAM,YAAY,sBAAsBA,EAAG,eAAe,IAAI;AAAA,IAAA,GAG9EC,IAAU,CAACD,MAAgB;AAC9BA,QAAmB,MAAM,eAAe,oBAAoB,GAC1DA,EAAA,UAAU,OAAO,qBAAqB;AAAA,IAC3C;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { defineComponent as x, mergeModels as g, inject as d, toRef as u, useMod
|
|
|
2
2
|
import { uniqueId as w } from "../../lib/util/helpers/dist/index.js";
|
|
3
3
|
import B from "../PlIcon16/PlIcon16.vue.js";
|
|
4
4
|
import N from "../PlSectionSeparator/PlSectionSeparator.vue.js";
|
|
5
|
-
import _ from "./ExpandTransition.
|
|
5
|
+
import _ from "./ExpandTransition.vue2.js";
|
|
6
6
|
(function() {
|
|
7
7
|
try {
|
|
8
8
|
if (typeof document < "u") {
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import { defineComponent as A, mergeModels as
|
|
2
|
-
import
|
|
3
|
-
import { useLabelNotch as
|
|
4
|
-
import
|
|
1
|
+
import { defineComponent as A, mergeModels as S, useModel as j, useSlots as z, ref as v, computed as u, watch as F, createElementBlock as f, openBlock as c, normalizeClass as m, createElementVNode as t, createCommentVNode as b, createVNode as T, withDirectives as U, createTextVNode as $, createBlock as q, toDisplayString as L, unref as M, withCtx as R, renderSlot as Y, vModelText as Z } from "vue";
|
|
2
|
+
import J from "../../utils/DoubleContour.vue.js";
|
|
3
|
+
import { useLabelNotch as K } from "../../utils/useLabelNotch.js";
|
|
4
|
+
import P from "../PlTooltip/PlTooltip.vue.js";
|
|
5
|
+
import { parseNumber as C } from "./parseNumber.js";
|
|
5
6
|
(function() {
|
|
6
7
|
try {
|
|
7
8
|
if (typeof document < "u") {
|
|
8
|
-
var
|
|
9
|
-
|
|
9
|
+
var d = document.createElement("style");
|
|
10
|
+
d.appendChild(document.createTextNode(".pl-number-field{--contour-color: var(--txt-01);--contour-border-width: 1px;--options-bg: #fff;--option-hover-bg: var(--btn-sec-hover-grey);--label-offset-left-x: 8px;--label-offset-right-x: 8px;--label-color: var(--txt-01);--color-hint: #9d9eae}.pl-number-field ::placeholder{color:#cfd1db;opacity:1}.pl-number-field__main-wrapper{height:40px;position:relative}.pl-number-field__wrapper{padding-left:12px;border-radius:6px}.pl-number-field__wrapper.withoutArrows{padding-right:12px}.pl-number-field__icons{width:40px;border-radius:0 6px 6px 0;border-left:1px solid var(--contour-color)}.pl-number-field__icon{line-height:0}.pl-number-field__icon.disabled{cursor:not-allowed;position:relative;z-index:1}.pl-number-field__icon.disabled svg path{fill:#cfd1db}.pl-number-field__icon:hover{background-color:#9babcc29}.pl-number-field__icon:first-child{border-bottom:1px solid var(--contour-color)}.pl-number-field__hint{margin-top:3px;color:var(--color-hint)}.pl-number-field__error{margin-top:3px;color:var(--txt-error);font-size:12px;font-weight:500;line-height:16px}.pl-number-field input{outline:none;border:none;width:100%;background:unset;text-overflow:ellipsis}.pl-number-field__contour{border-radius:var(--border-radius-control);border:var(--contour-border-width) solid var(--contour-color);box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none;transition:all .3s}.pl-number-field:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-number-field:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-number-field.error{--contour-color: var(--txt-error);--label-color: var(--txt-error);--color-hint: var(--txt-error)}.pl-number-field.disabled{--contour-color: var(--color-dis-01);--control-mask-fill: var(--color-dis-01);cursor:not-allowed}.pl-number-field.disabled label,.pl-number-field.disabled .mi-number-field__hint,.pl-number-field.disabled input{color:var(--contour-color)}.pl-number-field.disabled svg path{fill:var(--contour-color)}.pl-number-field.disabled .mi-number-field__icons{pointer-events:none}.pl-number-field label{position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);display:flex;align-items:center;padding:0 4px;overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);transition:color .3s}.pl-number-field label .required{display:inline-block;font-weight:500;font-size:12px;line-height:16px;color:var(--txt-error);margin-right:4px}")), document.head.appendChild(d);
|
|
10
11
|
}
|
|
11
|
-
} catch (
|
|
12
|
-
console.error("vite-plugin-css-injected-by-js",
|
|
12
|
+
} catch (o) {
|
|
13
|
+
console.error("vite-plugin-css-injected-by-js", o);
|
|
13
14
|
}
|
|
14
15
|
})();
|
|
15
|
-
const
|
|
16
|
+
const Q = { class: "pl-number-field__main-wrapper d-flex" }, W = {
|
|
16
17
|
key: 0,
|
|
17
18
|
class: "text-description"
|
|
18
|
-
},
|
|
19
|
+
}, X = ["disabled", "placeholder"], G = {
|
|
19
20
|
key: 0,
|
|
20
|
-
class: "
|
|
21
|
+
class: "pl-number-field__error"
|
|
22
|
+
}, H = {
|
|
23
|
+
name: "PlNumberField"
|
|
21
24
|
}, ie = /* @__PURE__ */ A({
|
|
22
|
-
|
|
23
|
-
props: /* @__PURE__ */
|
|
25
|
+
...H,
|
|
26
|
+
props: /* @__PURE__ */ S({
|
|
24
27
|
disabled: { type: Boolean },
|
|
25
28
|
label: { default: void 0 },
|
|
26
29
|
placeholder: { default: void 0 },
|
|
@@ -36,136 +39,121 @@ const G = { class: "mi-number-field__main-wrapper d-flex" }, H = {
|
|
|
36
39
|
modelModifiers: {}
|
|
37
40
|
}),
|
|
38
41
|
emits: ["update:modelValue"],
|
|
39
|
-
setup(
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
function h(e) {
|
|
43
|
-
return e === void 0 ? "" : String(+e);
|
|
44
|
-
}
|
|
42
|
+
setup(d) {
|
|
43
|
+
const o = d, i = j(d, "modelValue"), E = z(), w = v(), p = v();
|
|
44
|
+
K(w);
|
|
45
45
|
function g(e) {
|
|
46
|
-
return e ===
|
|
47
|
-
}
|
|
48
|
-
function _(e) {
|
|
49
|
-
if (e === "")
|
|
50
|
-
return;
|
|
51
|
-
if (g(e))
|
|
52
|
-
return 0;
|
|
53
|
-
let o = e;
|
|
54
|
-
return o = o.replace(",", "."), o = o.replace("−", "-"), o = o.replace("–", "-"), o = o.replace("+", ""), parseFloat(o);
|
|
46
|
+
return e === void 0 ? "" : String(+e);
|
|
55
47
|
}
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
const n = u(() => C(o, s.value)), x = v(void 0), N = () => x.value = void 0;
|
|
49
|
+
F(i, (e) => {
|
|
50
|
+
const l = n.value;
|
|
51
|
+
(l.error || e !== l.value) && N();
|
|
59
52
|
});
|
|
60
|
-
const
|
|
53
|
+
const s = u({
|
|
61
54
|
get() {
|
|
62
|
-
return i.value;
|
|
55
|
+
return x.value ?? g(i.value);
|
|
63
56
|
},
|
|
64
57
|
set(e) {
|
|
65
|
-
const
|
|
66
|
-
|
|
58
|
+
const l = C(o, e);
|
|
59
|
+
x.value = l.cleanInput, l.error || o.updateOnEnterOrClickOutside ? p.value.value = l.cleanInput : i.value = l.value;
|
|
67
60
|
}
|
|
68
|
-
}),
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
n.value = void 0;
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
n.value = a.value;
|
|
61
|
+
}), _ = v(!1);
|
|
62
|
+
function O() {
|
|
63
|
+
n.value.error === void 0 && (i.value = n.value.value);
|
|
75
64
|
}
|
|
76
|
-
const
|
|
65
|
+
const h = u(() => {
|
|
77
66
|
let e = [];
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
e.push(
|
|
82
|
-
else if (
|
|
83
|
-
const r =
|
|
67
|
+
o.errorMessage && e.push(o.errorMessage);
|
|
68
|
+
const l = n.value;
|
|
69
|
+
if (l.error)
|
|
70
|
+
e.push(l.error.message);
|
|
71
|
+
else if (o.validate && l.value !== void 0) {
|
|
72
|
+
const r = o.validate(l.value);
|
|
84
73
|
r && e.push(r);
|
|
85
|
-
}
|
|
86
|
-
l.minValue !== void 0 && o !== void 0 && o < l.minValue && e.push(`Value must be higher than ${l.minValue}`), l.maxValue !== void 0 && o !== void 0 && o > l.maxValue && e.push(`Value must be less than ${l.maxValue}`);
|
|
74
|
+
}
|
|
87
75
|
return e = [...e], e.join(" ");
|
|
88
|
-
}),
|
|
89
|
-
const e =
|
|
90
|
-
return
|
|
91
|
-
}),
|
|
92
|
-
const e =
|
|
93
|
-
return
|
|
94
|
-
}),
|
|
76
|
+
}), y = u(() => {
|
|
77
|
+
const e = n.value;
|
|
78
|
+
return o.maxValue !== void 0 && e.value !== void 0 ? e.value >= o.maxValue : !1;
|
|
79
|
+
}), V = u(() => {
|
|
80
|
+
const e = n.value;
|
|
81
|
+
return o.minValue !== void 0 && e.value !== void 0 ? e.value <= o.minValue : !1;
|
|
82
|
+
}), a = u(
|
|
95
83
|
() => {
|
|
96
84
|
var e;
|
|
97
|
-
return 10 ** (((e =
|
|
85
|
+
return 10 ** (((e = o.step.toString().split(".").at(1)) == null ? void 0 : e.length) ?? 0);
|
|
98
86
|
}
|
|
99
87
|
);
|
|
100
|
-
function
|
|
101
|
-
const e =
|
|
102
|
-
if (!
|
|
103
|
-
let
|
|
104
|
-
e === void 0 ?
|
|
88
|
+
function k() {
|
|
89
|
+
const e = n.value.value;
|
|
90
|
+
if (!y.value) {
|
|
91
|
+
let l;
|
|
92
|
+
e === void 0 ? l = o.minValue ? o.minValue : 0 : l = ((e || 0) * a.value + o.step * a.value) / a.value, i.value = o.maxValue !== void 0 ? Math.min(o.maxValue, l) : l;
|
|
105
93
|
}
|
|
106
94
|
}
|
|
107
|
-
function
|
|
108
|
-
const e =
|
|
109
|
-
if (!
|
|
110
|
-
let
|
|
111
|
-
e === void 0 ?
|
|
95
|
+
function B() {
|
|
96
|
+
const e = n.value.value;
|
|
97
|
+
if (!V.value) {
|
|
98
|
+
let l;
|
|
99
|
+
e === void 0 ? l = 0 : l = ((e || 0) * a.value - o.step * a.value) / a.value, i.value = o.minValue !== void 0 ? Math.max(o.minValue, l) : l;
|
|
112
100
|
}
|
|
113
101
|
}
|
|
114
|
-
function
|
|
115
|
-
var
|
|
116
|
-
|
|
102
|
+
function I(e) {
|
|
103
|
+
var l, r;
|
|
104
|
+
o.updateOnEnterOrClickOutside && (e.code === "Escape" && (s.value = g(i.value), (l = p.value) == null || l.blur()), e.code === "Enter" && ((r = p.value) == null || r.blur())), e.code === "Enter" && (s.value = String(i.value)), ["ArrowDown", "ArrowUp"].includes(e.code) && e.preventDefault(), o.useIncrementButtons && e.code === "ArrowUp" && k(), o.useIncrementButtons && e.code === "ArrowDown" && B();
|
|
117
105
|
}
|
|
118
|
-
const
|
|
106
|
+
const D = (e) => {
|
|
119
107
|
e.detail > 1 && e.preventDefault();
|
|
120
108
|
};
|
|
121
|
-
return (e,
|
|
122
|
-
ref_key: "
|
|
109
|
+
return (e, l) => (c(), f("div", {
|
|
110
|
+
ref_key: "rootRef",
|
|
123
111
|
ref: w,
|
|
124
|
-
class:
|
|
125
|
-
onKeydown:
|
|
112
|
+
class: m([{ error: !!h.value.trim(), disabled: e.disabled }, "pl-number-field d-flex-column"]),
|
|
113
|
+
onKeydown: l[3] || (l[3] = (r) => I(r))
|
|
126
114
|
}, [
|
|
127
|
-
t("div",
|
|
128
|
-
T(
|
|
115
|
+
t("div", Q, [
|
|
116
|
+
T(J, { class: "pl-number-field__contour" }),
|
|
129
117
|
t("div", {
|
|
130
|
-
class:
|
|
118
|
+
class: m(["pl-number-field__wrapper flex-grow d-flex flex-align-center", { withoutArrows: !e.useIncrementButtons }])
|
|
131
119
|
}, [
|
|
132
|
-
e.label ? (
|
|
133
|
-
|
|
134
|
-
|
|
120
|
+
e.label ? (c(), f("label", W, [
|
|
121
|
+
$(L(e.label) + " ", 1),
|
|
122
|
+
M(E).tooltip ? (c(), q(M(P), {
|
|
135
123
|
key: 0,
|
|
136
124
|
class: "info",
|
|
137
125
|
position: "top"
|
|
138
126
|
}, {
|
|
139
|
-
tooltip:
|
|
140
|
-
|
|
127
|
+
tooltip: R(() => [
|
|
128
|
+
Y(e.$slots, "tooltip")
|
|
141
129
|
]),
|
|
142
130
|
_: 3
|
|
143
131
|
})) : b("", !0)
|
|
144
132
|
])) : b("", !0),
|
|
145
133
|
U(t("input", {
|
|
146
|
-
ref_key: "
|
|
147
|
-
ref:
|
|
148
|
-
"onUpdate:modelValue":
|
|
134
|
+
ref_key: "inputRef",
|
|
135
|
+
ref: p,
|
|
136
|
+
"onUpdate:modelValue": l[0] || (l[0] = (r) => s.value = r),
|
|
149
137
|
disabled: e.disabled,
|
|
150
138
|
placeholder: e.placeholder,
|
|
151
139
|
class: "text-s flex-grow",
|
|
152
|
-
onFocusin:
|
|
153
|
-
onFocusout:
|
|
154
|
-
|
|
140
|
+
onFocusin: l[1] || (l[1] = (r) => _.value = !0),
|
|
141
|
+
onFocusout: l[2] || (l[2] = (r) => {
|
|
142
|
+
_.value = !1, O();
|
|
155
143
|
})
|
|
156
|
-
}, null, 40,
|
|
157
|
-
[
|
|
144
|
+
}, null, 40, X), [
|
|
145
|
+
[Z, s.value]
|
|
158
146
|
])
|
|
159
147
|
], 2),
|
|
160
|
-
e.useIncrementButtons ? (
|
|
148
|
+
e.useIncrementButtons ? (c(), f("div", {
|
|
161
149
|
key: 0,
|
|
162
|
-
class: "
|
|
163
|
-
onMousedown:
|
|
150
|
+
class: "pl-number-field__icons d-flex-column",
|
|
151
|
+
onMousedown: D
|
|
164
152
|
}, [
|
|
165
153
|
t("div", {
|
|
166
|
-
class:
|
|
167
|
-
onClick:
|
|
168
|
-
},
|
|
154
|
+
class: m([{ disabled: y.value }, "pl-number-field__icon d-flex flex-justify-center uc-pointer flex-grow flex-align-center"]),
|
|
155
|
+
onClick: k
|
|
156
|
+
}, l[4] || (l[4] = [
|
|
169
157
|
t("svg", {
|
|
170
158
|
xmlns: "http://www.w3.org/2000/svg",
|
|
171
159
|
width: "16",
|
|
@@ -182,9 +170,9 @@ const G = { class: "mi-number-field__main-wrapper d-flex" }, H = {
|
|
|
182
170
|
], -1)
|
|
183
171
|
]), 2),
|
|
184
172
|
t("div", {
|
|
185
|
-
class:
|
|
186
|
-
onClick:
|
|
187
|
-
},
|
|
173
|
+
class: m([{ disabled: V.value }, "pl-number-field__icon d-flex flex-justify-center uc-pointer flex-grow flex-align-center"]),
|
|
174
|
+
onClick: B
|
|
175
|
+
}, l[5] || (l[5] = [
|
|
188
176
|
t("svg", {
|
|
189
177
|
xmlns: "http://www.w3.org/2000/svg",
|
|
190
178
|
width: "16",
|
|
@@ -202,7 +190,7 @@ const G = { class: "mi-number-field__main-wrapper d-flex" }, H = {
|
|
|
202
190
|
]), 2)
|
|
203
191
|
], 32)) : b("", !0)
|
|
204
192
|
]),
|
|
205
|
-
|
|
193
|
+
h.value.trim() ? (c(), f("div", G, L(h.value), 1)) : b("", !0)
|
|
206
194
|
], 34));
|
|
207
195
|
}
|
|
208
196
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlNumberField.vue.js","sources":["../../../../../../../../../lib/ui/uikit/src/components/PlNumberField/PlNumberField.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport './pl-number-field.scss';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport { computed, ref, useSlots, watch } from 'vue';\nimport { PlTooltip } from '../PlTooltip';\n\ntype NumberInputProps = {\n /** Input is disabled if true */\n disabled?: boolean;\n /** Label on the top border of the field, empty by default */\n label?: string;\n /** Input placeholder, empty by default */\n placeholder?: string;\n /** Step for increment/decrement buttons, 1 by default */\n step?: number;\n /** If defined - show an error if value is lower */\n minValue?: number;\n /** If defined - show an error if value is higher */\n maxValue?: number;\n /** If false - remove buttons on the right */\n useIncrementButtons?: boolean;\n /** If true - changes do not apply immediately, they apply only by removing focus from the input (by click enter or by click outside) */\n updateOnEnterOrClickOutside?: boolean;\n /** Error message that shows always when it's provided, without other checks */\n errorMessage?: string;\n /** Additional validity check for input value that must return an error text if failed */\n validate?: (v: number) => string | undefined;\n};\n\nconst props = withDefaults(defineProps<NumberInputProps>(), {\n step: 1,\n label: undefined,\n placeholder: undefined,\n minValue: undefined,\n maxValue: undefined,\n useIncrementButtons: true,\n updateOnEnter: false,\n errorMessage: undefined,\n validate: undefined,\n});\n\nconst modelValue = defineModel<number | undefined>({ required: true });\n\nconst root = ref<HTMLElement>();\nconst slots = useSlots();\nconst input = ref<HTMLInputElement>();\n\nuseLabelNotch(root);\n\nfunction modelToString(v: number | undefined) {\n return v === undefined ? '' : String(+v); // (+v) to avoid staying in input non-number values if they are provided in model\n}\n\nfunction isPartial(v: string) {\n return v === '.' || v === ',' || v === '-';\n}\nfunction stringToModel(v: string) {\n if (v === '') {\n return undefined;\n }\n if (isPartial(v)) {\n return 0;\n }\n let forParsing = v;\n forParsing = forParsing.replace(',', '.');\n forParsing = forParsing.replace('−', '-'); // minus, replacing for the case of input the whole copied value\n forParsing = forParsing.replace('–', '-'); // dash, replacing for the case of input the whole copied value\n forParsing = forParsing.replace('+', '');\n return parseFloat(forParsing);\n}\n\nconst innerTextValue = ref(modelToString(modelValue.value));\nconst innerNumberValue = computed(() => stringToModel(innerTextValue.value));\n\nwatch(() => modelValue.value, (outerValue) => { // update inner value if outer value is changed\n if (parseFloat(innerTextValue.value) !== outerValue) {\n innerTextValue.value = modelToString(outerValue);\n }\n});\n\nconst NUMBER_REGEX = /^[-−–+]?(\\d+)?[\\\\.,]?(\\d+)?$/; // parseFloat works without errors on strings with multiple dots, or letters in value\nconst inputValue = computed({\n get() {\n return innerTextValue.value;\n },\n set(nextValue: string) {\n const parsedValue = stringToModel(nextValue);\n // we allow to set empty value or valid numeric value, otherwise reset input value to previous valid\n if (parsedValue === undefined\n || (nextValue.match(NUMBER_REGEX) && !isNaN(parsedValue))\n ) {\n innerTextValue.value = nextValue;\n if (!props.updateOnEnterOrClickOutside && !isPartial(nextValue)) { // to avoid applying '-' or '.'\n applyChanges();\n }\n } else if (input.value) {\n input.value.value = innerTextValue.value;\n }\n },\n});\nconst focused = ref(false);\n\nfunction applyChanges() {\n if (innerTextValue.value === '') {\n modelValue.value = undefined;\n return;\n }\n modelValue.value = innerNumberValue.value;\n}\n\nconst errors = computed(() => {\n let ers: string[] = [];\n if (props.errorMessage) {\n ers.push(props.errorMessage);\n }\n const parsedValue = innerNumberValue.value;\n if (parsedValue !== undefined && isNaN(parsedValue)) {\n ers.push('Value is not a number');\n } else if (props.validate && parsedValue !== undefined) {\n const error = props.validate(parsedValue);\n if (error) {\n ers.push(error);\n }\n } else {\n if (props.minValue !== undefined && parsedValue !== undefined && parsedValue < props.minValue) {\n ers.push(`Value must be higher than ${props.minValue}`);\n }\n if (props.maxValue !== undefined && parsedValue !== undefined && parsedValue > props.maxValue) {\n ers.push(`Value must be less than ${props.maxValue}`);\n }\n }\n\n ers = [...ers];\n\n return ers.join(' ');\n});\n\nconst isIncrementDisabled = computed(() => {\n const parsedValue = innerNumberValue.value;\n if (props.maxValue !== undefined && parsedValue !== undefined) {\n return parsedValue >= props.maxValue;\n }\n return false;\n});\n\nconst isDecrementDisabled = computed(() => {\n const parsedValue = innerNumberValue.value;\n if (props.minValue !== undefined && parsedValue !== undefined) {\n return parsedValue <= props.minValue;\n }\n return false;\n});\n\nconst multiplier = computed(() =>\n 10 ** (props.step.toString().split('.').at(1)?.length ?? 0),\n);\n\nfunction increment() {\n const parsedValue = innerNumberValue.value;\n if (!isIncrementDisabled.value) {\n let nV;\n if (parsedValue === undefined) {\n nV = props.minValue ? props.minValue : 0;\n } else {\n nV = ((parsedValue || 0) * multiplier.value\n + props.step * multiplier.value)\n / multiplier.value;\n }\n modelValue.value = props.maxValue !== undefined ? Math.min(props.maxValue, nV) : nV;\n }\n}\n\nfunction decrement() {\n const parsedValue = innerNumberValue.value;\n if (!isDecrementDisabled.value) {\n let nV;\n if (parsedValue === undefined) {\n nV = 0;\n } else {\n nV = ((parsedValue || 0) * multiplier.value\n - props.step * multiplier.value)\n / multiplier.value;\n }\n modelValue.value = props.minValue !== undefined ? Math.max(props.minValue, nV) : nV;\n }\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }) {\n if (props.updateOnEnterOrClickOutside) {\n if (e.code === 'Escape') {\n innerTextValue.value = modelToString(modelValue.value);\n input.value?.blur();\n }\n if (e.code === 'Enter') {\n input.value?.blur();\n }\n }\n\n if (e.code === 'Enter') {\n innerTextValue.value = String(modelValue.value); // to make .1 => 0.1, 10.00 => 10, remove leading zeros etc\n }\n\n if (['ArrowDown', 'ArrowUp'].includes(e.code)) {\n e.preventDefault();\n }\n if (props.useIncrementButtons && e.code === 'ArrowUp') {\n increment();\n }\n if (props.useIncrementButtons && e.code === 'ArrowDown') {\n decrement();\n }\n}\n\n// https://stackoverflow.com/questions/880512/prevent-text-selection-after-double-click#:~:text=If%20you%20encounter%20a%20situation,none%3B%20to%20the%20summary%20element.\n// this prevents selecting of more than input content in some cases,\n// but also disable selecting input content by double-click (useful feature)\nconst onMousedown = (ev: MouseEvent) => {\n if (ev.detail > 1) {\n ev.preventDefault();\n }\n};\n</script>\n\n<template>\n <div\n ref=\"root\"\n :class=\"{ error: !!errors.trim(), disabled: disabled }\"\n class=\"mi-number-field d-flex-column\"\n @keydown=\"handleKeyPress($event)\"\n >\n <div class=\"mi-number-field__main-wrapper d-flex\">\n <DoubleContour class=\"mi-number-field__contour\"/>\n <div\n class=\"mi-number-field__wrapper flex-grow d-flex flex-align-center\"\n :class=\"{withoutArrows: !useIncrementButtons}\"\n >\n <label v-if=\"label\" class=\"text-description\">\n {{ label }}\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\"/>\n </template>\n </PlTooltip>\n </label>\n <input\n ref=\"input\"\n v-model=\"inputValue\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder\"\n class=\"text-s flex-grow\"\n @focusin=\"focused = true\"\n @focusout=\"focused = false; applyChanges()\"\n />\n </div>\n <div v-if=\"useIncrementButtons\" class=\"mi-number-field__icons d-flex-column\" @mousedown=\"onMousedown\">\n <div\n :class=\"{ disabled: isIncrementDisabled }\"\n class=\"mi-number-field__icon d-flex flex-justify-center uc-pointer flex-grow flex-align-center\"\n @click=\"increment\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M8 4.93933L13.5303 10.4697L12.4697 11.5303L8 7.06065L3.53033 11.5303L2.46967 10.4697L8 4.93933Z\"\n fill=\"#110529\"\n />\n </svg>\n </div>\n <div\n :class=\"{ disabled: isDecrementDisabled }\"\n class=\"mi-number-field__icon d-flex flex-justify-center uc-pointer flex-grow flex-align-center\"\n @click=\"decrement\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M2.46967 6.53033L3.53033 5.46967L8 9.93934L12.4697 5.46967L13.5303 6.53033L8 12.0607L2.46967 6.53033Z\"\n fill=\"#110529\"\n />\n </svg>\n </div>\n </div>\n </div>\n <div v-if=\"errors.trim()\" class=\"mi-number-field__hint text-description\">\n {{ errors }}\n </div>\n </div>\n</template>\n"],"names":["w","__props","useLabelNotch","t","a","A","g","v","D","T","d","X","x","h","forParsing","l","watch","o","V","r","s","P","NUMBER_REGEX","O","y","parsedValue","nextValue","B","k","innerTextValue","ers","props","error","i","computed","M","nV","N","_","ev"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BA,MAAAA,GAAcC;AAkBdC,UAAkBC,IAAAH,GAAAI,IAAAC,EAAAL,GAAA,YAAA,GAAAM,IAAAC,EAAA,GAAAC,IAAAC,EAAA,GAAAC,IAAAH,EAAA;AAElBI,IAAAA,EAAAL,CAAA;AACE,aAAOC,EAAM,GAAA;AAA0B,aAAA,MAAA,SAAA,KAAA,OAAA,CAAA,CAAA;AAAA,IAGzC;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D,EAAA,aAAA,SAAA,KAAA,IAAAA,EAAA,UAAAY,CAAA,IAAAA;AAAA,MAAA;AAAA,IAIrF;AACE,iBAAqC;AACjC,gBAA4BI,EAAA;AAC1BiB,UAAAA,CAAAA,EAAAA,OAAAA;AACAX,YAAAA;AAO6E,cAAA,SAAAV,IAAA,IAAAA,MAAA,KAAA,KAAA,EAAA,QAAAZ,EAAA,OAAA,EAAA,SAAA,EAAA,OAAAC,EAAA,QAAAD,EAAA,aAAA,SAAA,KAAA,IAAAA,EAAA,UAAAY,CAAA,IAAAA;AAAA,MAAA;AAAA,IAIrF;;AACMgB,UACEhB,GAAAkB;AAqBN,MAAA9B,EAAA,gCAAA,EAAA,SAAA,aAAAc,EAAA,QAAAC,EAAAd,EAAA,KAAA,IAAAW,IAAAL,EAAA,UAAA,QAAAK,EAAA,KAAA,IAAA,EAAA,SAAA,aAAAkB,IAAAvB,EAAA,UAAA,QAAAuB,EAAA,KAAA,KAAA,EAAA,SAAA,YAAAhB,EAAA,QAAA,OAAAb,EAAA,KAAA,IAAA,CAAA,aAAA,SAAA,EAAA,SAAA,EAAA,IAAA,KAAA,EAAA,eAAA,GAAAD,EAAA,uBAAA,EAAA,SAAA,aAAAkC,EAAA,GAAAlC,EAAA,uBAAA,EAAA,SAAA,eAAAmC,EAAA;AAAA,IAMI;AACA,UAAG,IAAA,CAAA,MACLC;AAEJ,QAAA,SAAA,KAAA,EAAA,eAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"PlNumberField.vue.js","sources":["../../../../../../../../../lib/ui/uikit/src/components/PlNumberField/PlNumberField.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Number input field with increment/decrement buttons, validation, and min/max constraints.\n *\n * @example\n * <PlNumberField v-model=\"price\" :step=\"0.01\" :min-value=\"0\" label=\"Price\" />\n *\n * @example\n * <PlNumberField\n * v-model=\"evenNumber\"\n * :validate=\"(v) => v % 2 !== 0 ? 'Number must be even' : undefined\"\n * :update-on-enter-or-click-outside=\"true\"\n * label=\"Even Number\"\n * />\n */\nexport default {\n name: 'PlNumberField',\n};\n</script>\n\n<script setup lang=\"ts\">\nimport './pl-number-field.scss';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport { computed, ref, useSlots, watch } from 'vue';\nimport { PlTooltip } from '../PlTooltip';\nimport { parseNumber } from './parseNumber';\n\nconst props = withDefaults(defineProps<{\n /** Input is disabled if true */\n disabled?: boolean;\n /** Label on the top border of the field, empty by default */\n label?: string;\n /** Input placeholder, empty by default */\n placeholder?: string;\n /** Step for increment/decrement buttons, 1 by default */\n step?: number;\n /** If defined - show an error if value is lower */\n minValue?: number;\n /** If defined - show an error if value is higher */\n maxValue?: number;\n /** If false - remove buttons on the right */\n useIncrementButtons?: boolean;\n /** If true - changes do not apply immediately, they apply only by removing focus from the input (by click enter or by click outside) */\n updateOnEnterOrClickOutside?: boolean;\n /** Error message that shows always when it's provided, without other checks */\n errorMessage?: string;\n /** Additional validity check for input value that must return an error text if failed */\n validate?: (v: number) => string | undefined;\n}>(), {\n step: 1,\n label: undefined,\n placeholder: undefined,\n minValue: undefined,\n maxValue: undefined,\n useIncrementButtons: true,\n updateOnEnter: false,\n errorMessage: undefined,\n validate: undefined,\n});\n\nconst modelValue = defineModel<number | undefined>({ required: true });\n\nconst slots = useSlots();\n\nconst rootRef = ref<HTMLElement>();\nconst inputRef = ref<HTMLInputElement>();\n\nuseLabelNotch(rootRef);\n\nfunction modelToString(v: number | undefined) {\n return v === undefined ? '' : String(+v); // (+v) to avoid staying in input non-number values if they are provided in model\n}\n\nconst parsedResult = computed(() => parseNumber(props, inputValue.value));\n\nconst cachedValue = ref<string | undefined>(undefined);\n\nconst resetCachedValue = () => cachedValue.value = undefined;\n\nwatch(modelValue, (n) => {\n const r = parsedResult.value;\n if (r.error || n !== r.value) {\n resetCachedValue();\n }\n});\n\nconst inputValue = computed({\n get() {\n return cachedValue.value ?? modelToString(modelValue.value);\n },\n set(nextValue: string) {\n const r = parseNumber(props, nextValue);\n\n cachedValue.value = r.cleanInput;\n\n if (r.error || props.updateOnEnterOrClickOutside) {\n inputRef.value!.value = r.cleanInput;\n } else {\n modelValue.value = r.value;\n }\n },\n});\n\nconst focused = ref(false);\n\nfunction applyChanges() {\n if (parsedResult.value.error === undefined) {\n modelValue.value = parsedResult.value.value;\n }\n}\n\nconst errors = computed(() => {\n let ers: string[] = [];\n\n if (props.errorMessage) {\n ers.push(props.errorMessage);\n }\n\n const r = parsedResult.value;\n\n if (r.error) {\n ers.push(r.error.message);\n } else if (props.validate && r.value !== undefined) {\n const error = props.validate(r.value);\n if (error) {\n ers.push(error);\n }\n }\n\n ers = [...ers];\n\n return ers.join(' ');\n});\n\nconst isIncrementDisabled = computed(() => {\n const r = parsedResult.value;\n\n if (props.maxValue !== undefined && r.value !== undefined) {\n return r.value >= props.maxValue;\n }\n\n return false;\n});\n\nconst isDecrementDisabled = computed(() => {\n const r = parsedResult.value;\n\n if (props.minValue !== undefined && r.value !== undefined) {\n return r.value <= props.minValue;\n }\n\n return false;\n});\n\nconst multiplier = computed(() =>\n 10 ** (props.step.toString().split('.').at(1)?.length ?? 0),\n);\n\nfunction increment() {\n const r = parsedResult.value;\n\n const parsedValue = r.value;\n\n if (!isIncrementDisabled.value) {\n let nV;\n if (parsedValue === undefined) {\n nV = props.minValue ? props.minValue : 0;\n } else {\n nV = ((parsedValue || 0) * multiplier.value\n + props.step * multiplier.value)\n / multiplier.value;\n }\n modelValue.value = props.maxValue !== undefined ? Math.min(props.maxValue, nV) : nV;\n }\n}\n\nfunction decrement() {\n const r = parsedResult.value;\n\n const parsedValue = r.value;\n\n if (!isDecrementDisabled.value) {\n let nV;\n if (parsedValue === undefined) {\n nV = 0;\n } else {\n nV = ((parsedValue || 0) * multiplier.value\n - props.step * multiplier.value)\n / multiplier.value;\n }\n modelValue.value = props.minValue !== undefined ? Math.max(props.minValue, nV) : nV;\n }\n}\n\nfunction handleKeyPress(e: { code: string; preventDefault(): void }) {\n if (props.updateOnEnterOrClickOutside) {\n if (e.code === 'Escape') {\n inputValue.value = modelToString(modelValue.value);\n inputRef.value?.blur();\n }\n if (e.code === 'Enter') {\n inputRef.value?.blur();\n }\n }\n\n if (e.code === 'Enter') {\n inputValue.value = String(modelValue.value); // to make .1 => 0.1, 10.00 => 10, remove leading zeros etc\n }\n\n if (['ArrowDown', 'ArrowUp'].includes(e.code)) {\n e.preventDefault();\n }\n\n if (props.useIncrementButtons && e.code === 'ArrowUp') {\n increment();\n }\n\n if (props.useIncrementButtons && e.code === 'ArrowDown') {\n decrement();\n }\n}\n\n// https://stackoverflow.com/questions/880512/prevent-text-selection-after-double-click#:~:text=If%20you%20encounter%20a%20situation,none%3B%20to%20the%20summary%20element.\n// this prevents selecting of more than input content in some cases,\n// but also disable selecting input content by double-click (useful feature)\nconst onMousedown = (ev: MouseEvent) => {\n if (ev.detail > 1) {\n ev.preventDefault();\n }\n};\n</script>\n\n<template>\n <div\n ref=\"rootRef\"\n :class=\"{ error: !!errors.trim(), disabled: disabled }\"\n class=\"pl-number-field d-flex-column\"\n @keydown=\"handleKeyPress($event)\"\n >\n <div class=\"pl-number-field__main-wrapper d-flex\">\n <DoubleContour class=\"pl-number-field__contour\"/>\n <div\n class=\"pl-number-field__wrapper flex-grow d-flex flex-align-center\"\n :class=\"{withoutArrows: !useIncrementButtons}\"\n >\n <label v-if=\"label\" class=\"text-description\">\n {{ label }}\n <PlTooltip v-if=\"slots.tooltip\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot name=\"tooltip\"/>\n </template>\n </PlTooltip>\n </label>\n <input\n ref=\"inputRef\"\n v-model=\"inputValue\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder\"\n class=\"text-s flex-grow\"\n @focusin=\"focused = true\"\n @focusout=\"focused = false; applyChanges()\"\n />\n </div>\n <div v-if=\"useIncrementButtons\" class=\"pl-number-field__icons d-flex-column\" @mousedown=\"onMousedown\">\n <div\n :class=\"{ disabled: isIncrementDisabled }\"\n class=\"pl-number-field__icon d-flex flex-justify-center uc-pointer flex-grow flex-align-center\"\n @click=\"increment\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M8 4.93933L13.5303 10.4697L12.4697 11.5303L8 7.06065L3.53033 11.5303L2.46967 10.4697L8 4.93933Z\"\n fill=\"#110529\"\n />\n </svg>\n </div>\n <div\n :class=\"{ disabled: isDecrementDisabled }\"\n class=\"pl-number-field__icon d-flex flex-justify-center uc-pointer flex-grow flex-align-center\"\n @click=\"decrement\"\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M2.46967 6.53033L3.53033 5.46967L8 9.93934L12.4697 5.46967L13.5303 6.53033L8 12.0607L2.46967 6.53033Z\"\n fill=\"#110529\"\n />\n </svg>\n </div>\n </div>\n </div>\n <div v-if=\"errors.trim()\" class=\"pl-number-field__error\">\n {{ errors }}\n </div>\n </div>\n</template>\n"],"names":["Y","g","__props","useLabelNotch","t","n","R","D","F","V","f","v","G","watch","i","M","w","O","$","parsedResult","u","x","r","cachedValue","h","E","ers","props","error","o","computed","k","parsedValue","nV","l","B","L","N","ev"],"mappings":";;;;;;;;;;;;;;;;;;;;SAee;AAAA,GACPA,IAAA;AAAA,EACR,MAAA;;;;;;;;;;;;;;;;;;;EAWA,MAAAC,GAAcC;AAwCdC,UAAqBC,IAAAH,GAAAI,IAAAC,EAAAL,GAAA,YAAA,GAAAM,IAAAC,EAAA,GAAAC,IAAAC,EAAA,GAAAC,IAAAD,EAAA;AAErBE,IA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,IAAAlB,EAAA,UAAA,QAAAkB,EAAA,KAAA,KAAA,EAAA,SAAA,YAAA,EAAA,QAAA,OAAAxB,EAAA,KAAA,IAAA,CAAA,aAAA,SAAA,EAAA,SAAA,EAAA,IAAA,KAAA,EAAA,eAAA,GAAAD,EAAA,uBAAA,EAAA,SAAA,aAAA+B,EAAA,GAAA/B,EAAA,uBAAA,EAAA,SAAA,eAAAgC,EAAA;AAAA,IAMI;AACA,UAAGC,IAAA,CAAA,MACLC;AAEJ,QAAA,SAAA,KAAA,EAAA,eAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const a = /^[-−–+]?(\d+)?[.,]?(\d+)?$/;
|
|
2
|
+
function i(e) {
|
|
3
|
+
return e === "." || e === "," || e === "-";
|
|
4
|
+
}
|
|
5
|
+
function l(e) {
|
|
6
|
+
return e = e.trim(), e = e.replace(",", "."), e = e.replace("−", "-"), e = e.replace("–", "-"), e = e.replace("+", ""), e;
|
|
7
|
+
}
|
|
8
|
+
function o(e) {
|
|
9
|
+
return parseFloat(l(e));
|
|
10
|
+
}
|
|
11
|
+
function c(e) {
|
|
12
|
+
if (e = e.trim(), i(e))
|
|
13
|
+
return e;
|
|
14
|
+
if (/^-[^0-9.]/.test(e))
|
|
15
|
+
return "-";
|
|
16
|
+
const t = e.match(/^(.*)[.,][^0-9].*$/);
|
|
17
|
+
if (t)
|
|
18
|
+
return t[1] + ".";
|
|
19
|
+
if (e.match(a))
|
|
20
|
+
return l(e);
|
|
21
|
+
const r = o(e);
|
|
22
|
+
return isNaN(r) ? "" : String(+r);
|
|
23
|
+
}
|
|
24
|
+
function m(e, t) {
|
|
25
|
+
t = t.trim();
|
|
26
|
+
const r = c(t);
|
|
27
|
+
if (t === "")
|
|
28
|
+
return {
|
|
29
|
+
value: void 0,
|
|
30
|
+
cleanInput: r
|
|
31
|
+
};
|
|
32
|
+
if (!t.match(a))
|
|
33
|
+
return {
|
|
34
|
+
error: Error("Value is not a number"),
|
|
35
|
+
cleanInput: r
|
|
36
|
+
};
|
|
37
|
+
if (i(t))
|
|
38
|
+
return {
|
|
39
|
+
error: Error("Enter a number"),
|
|
40
|
+
cleanInput: r
|
|
41
|
+
};
|
|
42
|
+
const n = o(t);
|
|
43
|
+
if (isNaN(n))
|
|
44
|
+
return {
|
|
45
|
+
error: Error("Value is not a number"),
|
|
46
|
+
cleanInput: r
|
|
47
|
+
};
|
|
48
|
+
if (e.minValue !== void 0 && n < e.minValue)
|
|
49
|
+
return {
|
|
50
|
+
error: Error(`Value must be higher than ${e.minValue}`),
|
|
51
|
+
value: n,
|
|
52
|
+
cleanInput: r
|
|
53
|
+
};
|
|
54
|
+
if (e.maxValue !== void 0 && n > e.maxValue)
|
|
55
|
+
return {
|
|
56
|
+
error: Error(`Value must be less than ${e.maxValue}`),
|
|
57
|
+
value: n,
|
|
58
|
+
cleanInput: r
|
|
59
|
+
};
|
|
60
|
+
if (e.validate) {
|
|
61
|
+
const u = e.validate(n);
|
|
62
|
+
if (u)
|
|
63
|
+
return {
|
|
64
|
+
error: Error(u),
|
|
65
|
+
value: n,
|
|
66
|
+
cleanInput: r
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
value: n,
|
|
71
|
+
cleanInput: r
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
m as parseNumber
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=parseNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseNumber.js","sources":["../../../../../../../../../lib/ui/uikit/src/components/PlNumberField/parseNumber.ts"],"sourcesContent":["type ParseResult = {\n error?: Error;\n value?: number;\n cleanInput: string;\n};\n\nconst NUMBER_REGEX = /^[-−–+]?(\\d+)?[.,]?(\\d+)?$/; // parseFloat works without errors on strings with multiple dots, or letters in value\n\nfunction isPartial(v: string) {\n return v === '.' || v === ',' || v === '-';\n}\n\nfunction clearNumericValue(v: string) {\n v = v.trim();\n v = v.replace(',', '.');\n v = v.replace('−', '-'); // minus, replacing for the case of input the whole copied value\n v = v.replace('–', '-'); // dash, replacing for the case of input the whole copied value\n v = v.replace('+', '');\n return v;\n}\n\nfunction stringToNumber(v: string) {\n return parseFloat(clearNumericValue(v));\n}\n\nfunction clearInput(v: string): string {\n v = v.trim();\n\n if (isPartial(v)) {\n return v;\n }\n\n if (/^-[^0-9.]/.test(v)) {\n return '-';\n }\n\n const match = v.match(/^(.*)[.,][^0-9].*$/);\n if (match) {\n return match[1] + '.';\n }\n\n if (v.match(NUMBER_REGEX)) {\n return clearNumericValue(v);\n }\n\n const n = stringToNumber(v);\n\n return isNaN(n) ? '' : String(+n);\n}\n\nexport function parseNumber(props: {\n minValue?: number;\n maxValue?: number;\n validate?: (v: number) => string | undefined;\n}, str: string): ParseResult {\n str = str.trim();\n\n const cleanInput = clearInput(str);\n\n if (str === '') {\n return {\n value: undefined,\n cleanInput,\n };\n }\n\n if (!str.match(NUMBER_REGEX)) {\n return {\n error: Error('Value is not a number'),\n cleanInput,\n };\n }\n\n if (isPartial(str)) {\n return {\n error: Error('Enter a number'),\n cleanInput,\n };\n }\n\n const value = stringToNumber(str);\n\n if (isNaN(value)) {\n return {\n error: Error('Value is not a number'),\n cleanInput,\n };\n }\n\n if (props.minValue !== undefined && value < props.minValue) {\n return {\n error: Error(`Value must be higher than ${props.minValue}`),\n value,\n cleanInput,\n };\n }\n\n if (props.maxValue !== undefined && value > props.maxValue) {\n return {\n error: Error(`Value must be less than ${props.maxValue}`),\n value,\n cleanInput,\n };\n }\n\n if (props.validate) {\n const error = props.validate(value);\n if (error) {\n return {\n error: Error(error),\n value,\n cleanInput,\n };\n }\n }\n\n return {\n value,\n cleanInput,\n };\n}\n"],"names":["NUMBER_REGEX","isPartial","v","clearNumericValue","stringToN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