Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7bc6ea4
Scrollbar implementation (#258)
stefashkaa Jul 21, 2021
e993ecf
fix storybook build scss (#260)
Nikita-Polyakov Jul 21, 2021
fc99cbd
Add an item in the installation instructions with the addition of ele…
Sociopacific Jul 21, 2021
78fa8fe
Merge pull request #262 from soramitsu/feature/add-element-ui-types-i…
Sociopacific Jul 21, 2021
055b7c4
Fix select arrow icon
Sociopacific Jul 22, 2021
2ee27db
Merge pull request #263 from soramitsu/fix/fix-select-arrow-icon
Sociopacific Jul 22, 2021
ca4dcaa
Improve build config (#264)
stefashkaa Jul 22, 2021
7825b3f
Fix customization page (#266)
stefashkaa Jul 22, 2021
269e3f7
Improve build config (#268)
stefashkaa Jul 26, 2021
263b952
Fix UI issues part 1 (#269)
stefashkaa Jul 27, 2021
48e4b4b
add style fixes for input button tabs (#270)
Nikita-Polyakov Jul 27, 2021
0f22278
Fix readme (#271)
stefashkaa Jul 28, 2021
c294da7
PW-239: Bridge Design Update (#273)
alexnatalia Jul 28, 2021
44b620f
Add dark theme (#275)
stefashkaa Aug 2, 2021
3505bfc
Fix theming issues (#276)
stefashkaa Aug 2, 2021
a76834d
Border Radiuses and Sizes Fixing (#272)
alexnatalia Aug 2, 2021
b8e7f20
Neumorphic switch in storybook (#278)
stefashkaa Aug 3, 2021
bef0ae8
update components styles (#280)
Nikita-Polyakov Aug 3, 2021
dcbe95f
Fixed button storybook typograhy behaviour. (#282)
alexnatalia Aug 4, 2021
1941c2f
Add switch theme function (#283)
stefashkaa Aug 4, 2021
28d81ab
fix action button (#285)
Nikita-Polyakov Aug 4, 2021
6ea8e2a
Fixed icons colors. (#287)
alexnatalia Aug 4, 2021
b395663
fix action button style (#289)
Nikita-Polyakov Aug 5, 2021
ddd273c
fix box-shadow (#292)
Nikita-Polyakov Aug 5, 2021
3f6afeb
Added tertiary SDivider type. (#291)
alexnatalia Aug 5, 2021
4615eca
Update UI Lib version. (#293)
alexnatalia Aug 5, 2021
8889d5e
Fix message box and dialog styles (#296)
stefashkaa Aug 5, 2021
ddf5bd4
add table empty-text color (#295)
Nikita-Polyakov Aug 6, 2021
9c54b55
Improve theme switch for storybook layouts (#298)
stefashkaa Aug 9, 2021
af52c27
tooltip close delay & hide after props (#300)
Nikita-Polyakov Aug 9, 2021
c1a8a0c
Fix dialog close state (#301)
stefashkaa Aug 10, 2021
dd0c0b6
Float input improvemens (#303)
Nikita-Polyakov Aug 10, 2021
76aaa48
Merge branch 'develop' into release/1.0.15
stefashkaa Aug 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@soramitsu/soramitsu-js-ui",
"version": "1.0.14",
"version": "1.0.15",
"private": false,
"publishConfig": {
"registry": "https://nexus.iroha.tech/repository/npm-soramitsu/"
Expand Down
62 changes: 46 additions & 16 deletions src/components/Dialog/SDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:class="computedClasses"
:close-on-click-modal="closeOnClickModal"
:close-on-press-escape="closeOnEsc"
:before-close="beforeClose"
:before-close="handleBeforeClose"
:center="center"
@open="handleOpen"
@close="handleClose"
Expand Down Expand Up @@ -135,9 +135,9 @@ export default class SDialog extends Mixins(BorderRadiusMixin, DesignSystemInjec
/**
* Function that will be called before closing.
*
* `(done: boolean) => {}`
* `beforeClose(closeFn: () => void)`
*/
@Prop({ type: Function }) readonly beforeClose!: (done: boolean) => {}
@Prop({ type: Function }) readonly beforeClose!: ((closeFn: () => void) => void) | null
/**
* Key for dialog content.
* If you need force rerender of table content (for instance, columns were changed)
Expand All @@ -151,9 +151,27 @@ export default class SDialog extends Mixins(BorderRadiusMixin, DesignSystemInjec

model = this.visible
computedTop = this.top
shouldNotBeClosed = false

@Watch('visible')
private handlePropChange (value: boolean): void {
const wrapper = (this.dialog || {}).$el as HTMLElement
if (!wrapper) {
return
}
const activeDialog = wrapper.children[0]
if (!activeDialog) {
return
}
if (!value) {
this.erd.uninstall(wrapper)
this.erd.uninstall(activeDialog)
activeDialog.removeEventListener('mouseleave', this.handleCheckCursorPosition)
} else {
this.erd.listenTo(wrapper, this.computeTop)
this.erd.listenTo(activeDialog, this.computeTop)
activeDialog.addEventListener('mouseleave', this.handleCheckCursorPosition)
}
this.model = value
}

Expand All @@ -162,6 +180,24 @@ export default class SDialog extends Mixins(BorderRadiusMixin, DesignSystemInjec
this.$emit('update:visible', value)
}

handleCheckCursorPosition (e): void {
if (e.buttons) { // When was pressed and left
this.shouldNotBeClosed = true
}
}

handleBeforeClose (closeFn: () => void) {
if (this.shouldNotBeClosed) {
this.shouldNotBeClosed = false
return
}
if (this.beforeClose) {
this.beforeClose(closeFn)
} else {
closeFn()
}
}

get computedClasses (): Array<string> {
const cssClasses: Array<string> = []
if (this.designSystemClass) {
Expand All @@ -176,26 +212,20 @@ export default class SDialog extends Mixins(BorderRadiusMixin, DesignSystemInjec
return cssClasses
}

mounted (): void {
this.$nextTick(() => {
destroyed (): void {
if (this.model) {
const wrapper = (this.dialog || {}).$el as HTMLElement
if (!wrapper) {
return
}
this.erd.listenTo(wrapper, this.computeTop)
this.erd.listenTo(wrapper.children[0], this.computeTop)
})
}

destroyed (): void {
this.$nextTick(() => {
const wrapper = (this.dialog || {}).$el as HTMLElement
if (!wrapper) {
const activeDialog = wrapper.children[0]
if (!activeDialog) {
return
}
this.erd.uninstall(wrapper)
this.erd.uninstall(wrapper.children[0])
})
this.erd.uninstall(activeDialog)
activeDialog.removeEventListener('mouseleave', this.handleCheckCursorPosition)
}
}

computeTop (): void {
Expand Down
56 changes: 52 additions & 4 deletions src/components/Input/SFloatInput/SFloatInput.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<template>
<s-input
ref="input"
:placeholder="placeholderValue"
:value="formatted"
v-bind="$attrs"
v-on="{
...$listeners,
input: handleInput,
blur: onBlur
blur: onBlur,
dblclick: onDblClick
}"
>
<template v-for="(_, scopedSlotName) in $scopedSlots" v-slot:[scopedSlotName]="slotData">
Expand All @@ -16,7 +18,7 @@
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
import { Vue, Component, Prop, Ref } from 'vue-property-decorator'

import SInput from '../SInput'
import { Float } from '../../../directives'
Expand Down Expand Up @@ -50,6 +52,10 @@ export default class SFloatInput extends Vue {
@Prop({ type: Object, default: () => DEFAULT_DELIMITERS }) readonly delimiters?: any
@Prop({ type: [String, Number], default: undefined, validator: isNumberLikeValue }) readonly max!: string | number

@Ref('input') inputComponent!: any

charsCountBeforeSelection = 0

get placeholderValue (): string {
return this.placeholder || '0'.concat(this.delimiters.decimal, '0')
}
Expand All @@ -58,21 +64,58 @@ export default class SFloatInput extends Vue {
return this.hasLocaleString ? this.toLocaleString() : this.value
}

handleInput (value: string): void {
get input (): HTMLInputElement {
return this.inputComponent.$refs['el-input'].$refs.input
}

saveSelectionPosition (value: string): void {
const pos = this.input.selectionStart as number
const chars = value.slice(0, pos).replace(new RegExp('\\' + this.delimiters.thousand, 'g'), '')

this.charsCountBeforeSelection = chars.length
}

updateSelectionPosition (): void {
const {
charsCountBeforeSelection: charsCount,
formatted: value,
delimiters: { thousand }
} = this

let selection = 0

for (let handledChars = 0; handledChars < charsCount; selection++) {
if (value.charAt(selection) !== thousand) {
handledChars++
}
}

this.input.selectionStart = this.input.selectionEnd = selection
}

async handleInput (value: string): Promise<void> {
if (this.hasLocaleString) {
// save selection position to update it later in new formatted value
this.saveSelectionPosition(value)
// Cleanup value's format
value = value.replace(new RegExp('\\' + this.delimiters.thousand, 'g'), '')
if (this.delimiters.decimal !== DEFAULT_DECIMAL_DELIMITER) {
value = value.replace(this.delimiters.decimal, DEFAULT_DECIMAL_DELIMITER)
}
}

const newValue = [
(v) => this.formatNumberField(v, this.decimals),
(v) => isNumberLikeValue(v) ? v : DEFAULT_VALUE,
(v) => this.checkValueForExtremum(v)
].reduce((buffer, rule) => rule(buffer), value)

this.onInput(newValue)

if (this.hasLocaleString) {
await this.$nextTick()
this.updateSelectionPosition()
}
}

onBlur (event: Event): void {
Expand All @@ -87,6 +130,11 @@ export default class SFloatInput extends Vue {
this.$emit('blur', event)
}

onDblClick (event: Event): void {
const target = event.target as any
target.select()
}

onInput (value: string): void {
this.$emit('input', value)
}
Expand Down Expand Up @@ -120,7 +168,7 @@ export default class SFloatInput extends Vue {
}

// Avoid several decimal delimiters
if ((value.match(new RegExp(DEFAULT_DECIMAL_DELIMITER, 'g')) || []).length > 1) {
if ((value.match(new RegExp(`\\${DEFAULT_DECIMAL_DELIMITER}`, 'g')) || []).length > 1) {
formatted = formatted.substring(0, decimalDelimiterIndex + 1) + formatted.substring(decimalDelimiterIndex + 1).replace(DEFAULT_DECIMAL_DELIMITER, '')
}

Expand Down
5 changes: 5 additions & 0 deletions src/components/Input/SInput/SInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@blur="handleBlur"
@focus="handleFocus"
@paste.native="handlePaste"
@dblclick.native="handleDblClick"
@keypress.enter.native="handleEnter"
>
<slot slot="prefix" name="prefix"></slot>
Expand Down Expand Up @@ -265,6 +266,10 @@ export default class SInput extends Mixins(BorderRadiusMixin, DesignSystemInject
this.$emit('paste', value)
}

handleDblClick (event: Event): void {
this.$emit('dblclick', event)
}

handleBlur (event: Event): void {
this.focused = false
this.$emit('blur', event)
Expand Down