Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(b-form-file): improved drag and drop handling (closes #3673) #5727

Merged
merged 31 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5225ddf
feat(b-form-file): improved drag and drop handling
jacobmllr95 Sep 3, 2020
3dfcc86
Update form-file.js
jacobmllr95 Sep 3, 2020
1622c7b
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 3, 2020
00c5f88
Update form-file.js
jacobmllr95 Sep 3, 2020
1952292
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 4, 2020
1f0dd71
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 4, 2020
eb2272f
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 7, 2020
3f4c619
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 8, 2020
39a030f
Further implementation
jacobmllr95 Sep 8, 2020
870b2e5
Update form-file.spec.js
jacobmllr95 Sep 8, 2020
f6bba36
add global `stopEvent()` util
jacobmllr95 Sep 8, 2020
2e9f22e
Improve tests
jacobmllr95 Sep 8, 2020
a542eac
Update form-file.spec.js
jacobmllr95 Sep 8, 2020
4aaf8b7
Update form-file.js
jacobmllr95 Sep 8, 2020
9f5b572
Update form-file.js
jacobmllr95 Sep 8, 2020
7f9d454
Update form-file.js
jacobmllr95 Sep 8, 2020
69f11f4
Update form-file.js
jacobmllr95 Sep 8, 2020
16ad043
Update common-props.json
jacobmllr95 Sep 9, 2020
8f4b474
Update form-file.js
jacobmllr95 Sep 9, 2020
a8dab4d
Update package.json
jacobmllr95 Sep 9, 2020
26846cf
Update form-file.js
jacobmllr95 Sep 9, 2020
5829ddc
Update README.md
jacobmllr95 Sep 9, 2020
84b3f9d
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 9, 2020
3f0f2a4
Update form-file.js
jacobmllr95 Sep 9, 2020
c042745
Update index.d.ts
jacobmllr95 Sep 9, 2020
1b7d867
Merge branch 'feat-b-form-file-advanced-drag-and-drop' of https://git…
jacobmllr95 Sep 9, 2020
22e5794
Update README.md
Hiws Sep 9, 2020
b106777
Keep current event prevent behavior
jacobmllr95 Sep 9, 2020
7320a4b
Update form-spinbutton.js
jacobmllr95 Sep 9, 2020
b2bde62
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 9, 2020
371d3f7
Merge branch 'dev' into feat-b-form-file-advanced-drag-and-drop
jacobmllr95 Sep 10, 2020
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
ignoreRestSiblings: false
}
],
'object-shorthand': ['error', 'properties'],
'spaced-comment': 'off', // needed to ignore `/*#__PURE__*/` comments
'vue/html-self-closing': [
'error',
Expand Down
60 changes: 30 additions & 30 deletions docs/common-props.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": {
"description": "Used to set the 'id' attribute on the rendered content, and used as the base to generate any additional element IDs as needed"
"description": "Used to set the `id` attribute on the rendered content, and used as the base to generate any additional element IDs as needed"
},
"variant": {
"description": "Applies one of the Bootstrap theme color variants to the component"
Expand Down Expand Up @@ -114,22 +114,22 @@
"description": "Set the size of the component's appearance. 'sm', 'md' (default), or 'lg'"
},
"required": {
"description": "Adds the 'required' attribute to the form control"
"description": "Adds the `required` attribute to the form control"
},
"form": {
"description": "ID of the form that the form control belongs to. Sets the 'form' attribute on the control"
"description": "ID of the form that the form control belongs to. Sets the `form` attribute on the control"
},
"name": {
"description": "Sets the value of the 'name' attribute on the form control"
"description": "Sets the value of the `name` attribute on the form control"
},
"placeholder": {
"description": "Sets the 'placeholder' attribute value on the form control"
"description": "Sets the `placeholder` attribute value on the form control"
},
"disabled": {
"description": "When set to 'true', disables the component's functionality and places it in a disabled state"
},
"readonly": {
"description": "Sets the 'readonly' attribute on the form control"
"description": "Sets the `readonly` attribute on the form control"
},
"plaintext": {
"description": "Set the form control as readonly and renders the control to look like plain text (no borders)"
Expand All @@ -138,25 +138,25 @@
"description": "Sets the 'autocomplete' attribute value on the form control"
},
"autofocus": {
"description": "When set to 'true', attempts to auto-focus the control when it is mounted, or re-activated when in a keep-alive. Does not set the 'autofocus' attribute on the control"
"description": "When set to `true`, attempts to auto-focus the control when it is mounted, or re-activated when in a keep-alive. Does not set the `autofocus` attribute on the control"
},
"state": {
"description": "Controls the validation state appearance of the component. 'true' for valid, 'false' for invalid', or 'null' for no validation state"
"description": "Controls the validation state appearance of the component. `true` for valid, `false` for invalid, or `null` for no validation state"
},
"options": {
"description": "Array of items to render in the component"
},
"valueField": {
"description": "Field name in the 'options' array that should be used for the value"
"description": "Field name in the `options` array that should be used for the value"
},
"textField": {
"description": "Field name in the 'options' array that should be used for the text label"
"description": "Field name in the `options` array that should be used for the text label"
},
"htmlField": {
"description": "Field name in the 'options' array that should be used for the html label instead of text field. Use with caution."
"description": "Field name in the `options` array that should be used for the html label instead of text field. Use with caution"
},
"disabledField": {
"description": "Field name in the 'options' array that should be used for the disabled state"
"description": "Field name in the `options` array that should be used for the disabled state"
},
"plain": {
"description": "Render the form control in plain mode, rather than custom styled mode"
Expand All @@ -165,52 +165,52 @@
"description": "Renders the content of the component in-place in the DOM, rather than portalling it to be appended to the body element"
},
"src": {
"description": "URL to set for the 'src' attribute"
"description": "URL to set for the `src` attribute"
},
"alt": {
"description": "Value to set for the 'alt' attribute"
"description": "Value to set for the `alt` attribute"
},
"role": {
"description": "Sets the ARIA attribute 'role' to a specific value"
"description": "Sets the ARIA attribute `role` to a specific value"
},
"ariaRole": {
"description": "Sets the ARIA attribute 'role' to a specific value"
"description": "Sets the ARIA attribute `role` to a specific value"
},
"ariaLabel": {
"description": "Sets the value of 'aria-label' attribute on the rendered element"
"description": "Sets the value of `aria-label` attribute on the rendered element"
},
"ariaLabelledby": {
"description": "The ID of the element that provides a label for this component. Used as the value for the 'aria-labelledby' attribute"
"description": "The ID of the element that provides a label for this component. Used as the value for the `aria-labelledby` attribute"
},
"ariaDescribedby": {
"description": "The ID of the element that provides additional context for this component. Used as the value for the 'aria-describedby' attribute"
"description": "The ID of the element that provides additional context for this component. Used as the value for the `aria-describedby` attribute"
},
"ariaLive": {
"description": "When the rendered element is an aria-live region (for screen reader users), set to either 'polite' or 'assertive'"
"description": "When the rendered element is an `aria-live` region (for screen reader users), set to either 'polite' or 'assertive'"
},
"fade": {
"description": "When set to 'true', enables the fade animation/transition on the component"
"description": "When set to `true`, enables the fade animation/transition on the component"
},
"noFade": {
"description": "When set to 'true', disables the fade animation/transition on the component"
"description": "When set to `true`, disables the fade animation/transition on the component"
},
"active": {
"description": "When set to 'true', places the component in the active state with active styling"
"description": "When set to `true`, places the component in the active state with active styling"
},
"href": {
"description": "<b-link> prop: Denotes the target URL of the link for standard a links"
},
"rel": {
"description": "<b-link> prop: Sets the 'rel' attribute on the rendered link"
"description": "<b-link> prop: Sets the `rel` attribute on the rendered link"
},
"target": {
"description": "<b-link> prop: Sets the 'target' attribute on the rendered link"
"description": "<b-link> prop: Sets the `target` attribute on the rendered link"
},
"to": {
"description": "<router-link> prop: Denotes the target route of the link. When clicked, the value of the to prop will be passed to router.push() internally, so the value can be either a string or a Location descriptor object"
"description": "<router-link> prop: Denotes the target route of the link. When clicked, the value of the to prop will be passed to `router.push()` internally, so the value can be either a string or a Location descriptor object"
},
"replace": {
"description": "<router-link> prop: Setting the replace prop will call 'router.replace()' instead of 'router.push()' when clicked, so the navigation will not leave a history record"
"description": "<router-link> prop: Setting the replace prop will call `router.replace()` instead of `router.push()` when clicked, so the navigation will not leave a history record"
},
"append": {
"description": "<router-link> prop: Setting append prop always appends the relative path to the current path"
Expand All @@ -225,17 +225,17 @@
"description": "<router-link> prop: Configure the active CSS class applied when the link is active with exact match. Typically you will want to set this to class name 'active'"
},
"routerTag": {
"description": "<router-link> prop: Specify which tag to render, and it will still listen to click events for navigation. 'router-tag' translates to the tag prop on the final rendered router-link. Typically you should use the default value"
"description": "<router-link> prop: Specify which tag to render, and it will still listen to click events for navigation. `router-tag` translates to the tag prop on the final rendered `<router-link>`. Typically you should use the default value"
},
"event": {
"description": "<router-link> prop: Specify the event that triggers the link. In most cases you should leave this as the default"
},
"prefetch": {
"description": "<nuxt-link> prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting 'prefetch' to 'true' or 'false' will overwrite the default value of 'router.prefetchLinks'",
"description": "<nuxt-link> prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting `prefetch` to `true` or `false` will overwrite the default value of `router.prefetchLinks`",
"version": "2.15.0"
},
"noPrefetch": {
"description": "<nuxt-link> prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting 'no-prefetch' will disabled this feature for the specific link"
"description": "<nuxt-link> prop: To improve the responsiveness of your Nuxt.js applications, when the link will be displayed within the viewport, Nuxt.js will automatically prefetch the code splitted page. Setting `no-prefetch` will disabled this feature for the specific link"
},
"routerComponentName": {
"description": "<b-link> prop: BootstrapVue auto detects between `<router-link>` and `<nuxt-link>`. In cases where you want to use a 3rd party link component based on `<router-link>`, set this prop to the component name. e.g. set it to 'g-link' if you are using Gridsome (note only `<router-link>` specific props are passed to the component)",
Expand Down
6 changes: 3 additions & 3 deletions docs/components/contributors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default {
const fallbackUrl = slug ? `https://opencollective.com/${slug}` : null
// Return the normalized result
return {
slug: slug,
slug,
name: entry.fromAccount.name,
// type: 'ORGANIZATION', 'INDIVIDUAL'
type: entry.fromAccount.type,
Expand All @@ -245,10 +245,10 @@ export default {
status: entry.status,
// For recurring donations, this is the installment amount
// For one time donations, this is the donation amount (most recent)
amount: amount,
amount,
// For recurring donations, this is the total amount donated
// For users that donate multiple times, this will be the total of all one time donations
totalAmount: totalAmount,
totalAmount,
// For recurring donations, this is how often the donation is received
frequency: entry.frequency,
// We now have sponsor tiers, but some appear as
Expand Down
26 changes: 13 additions & 13 deletions docs/pages/play.vue
Original file line number Diff line number Diff line change
Expand Up @@ -524,37 +524,37 @@ export default {
oWarn = window.console.warn
oError = window.console.error
oClear = window.console.clear
} catch (e) {}
} catch {}
return {
info: function() {
info() {
try {
logger('info', ...arguments)
oInfo.apply(oConsole, arguments)
} catch (e) {}
} catch {}
},
log: function() {
log() {
try {
logger('info', ...arguments)
oLog.apply(oConsole, arguments)
} catch (e) {}
} catch {}
},
warn: function() {
warn() {
try {
logger('warning', ...arguments)
oWarn.apply(oConsole, arguments)
} catch (e) {}
} catch {}
},
error: function() {
error() {
try {
logger('danger', ...arguments)
oError.apply(oConsole, arguments)
} catch (e) {}
} catch {}
},
clear: function() {
clear() {
try {
clear()
oClear.apply(oConsole)
} catch (e) {}
} catch {}
}
}
}
Expand Down Expand Up @@ -651,10 +651,10 @@ export default {
vm.$destroy()
removeNode(vm.$el)
vm.$el.innerHTML = ''
} catch (err) {}
} catch {}
try {
parent.$destroy()
} catch (err) {}
} catch {}
}
this.playVM = vm = null
this.$refs.result.innerHTML = ''
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
"nuxt": "^2.14.4",
"postcss-cli": "^7.1.2",
"prettier": "1.14.3",
"regenerator-runtime": "^0.13.7",
"require-context": "^1.1.0",
"rollup": "^2.26.11",
"rollup-plugin-babel": "^4.4.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const processFile = (file, data) =>
// Remove leading/trailing whitespace
.trim()
// Add to the iconsData object
data.icons[componentName] = { name: name, content: content }
data.icons[componentName] = { name, content }
data.componentNames.push(componentName)
// Resolve
resolve()
Expand Down
7 changes: 3 additions & 4 deletions scripts/create-web-types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Creates a web-types.json, tags.json and attributes.json files and places them in /dist
require('regenerator-runtime/runtime')
const path = require('path')
const fs = require('fs')
const requireContext = require('require-context')
Expand Down Expand Up @@ -166,7 +165,7 @@ const processComponentMeta = (meta, groupRef, groupDescription, docUrl) => {
name: propName,
value: {
kind: 'expression',
type: type
type
},
default: computePropDefault($prop),
'doc-url': docUrl
Expand Down Expand Up @@ -212,7 +211,7 @@ const processComponentMeta = (meta, groupRef, groupDescription, docUrl) => {
}
if (Array.isArray(eventObj.args)) {
event.arguments = eventObj.args.map((arg, index) => {
arg = typeof arg === 'object' ? arg : { arg: arg }
arg = typeof arg === 'object' ? arg : { arg }
const name = arg.arg || (arg.type ? computePropType(arg) : undefined) || 'arg' + index
const argument = {
name: name.charAt(0).toLowerCase() + name.slice(1),
Expand Down Expand Up @@ -448,7 +447,7 @@ try {
const type = (attrObj.value || { type: 'any' }).type
veturAttributes[`${tag}/${kebabCase(attrObj.name)}`] = {
description: attrObj.description || `One of: ${type.split('|').join(' or ')}`,
type: type
type
}
})
})
Expand Down
8 changes: 1 addition & 7 deletions src/components/button-toolbar/button-toolbar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from '../../utils/vue'
import KeyCodes from '../../utils/key-codes'
import { attemptFocus, contains, isVisible, selectAll } from '../../utils/dom'
import { stopEvent } from '../../utils/events'
import normalizeSlotMixin from '../../mixins/normalize-slot'

// --- Constants ---
Expand All @@ -13,13 +14,6 @@ const ITEM_SELECTOR = [
'input[type="radio"]:not(.disabled)'
].join(',')

// --- Utility methods ---

const stopEvent = evt => {
evt.preventDefault()
evt.stopPropagation()
}

// --- Main component ---

// @vue/component
Expand Down
4 changes: 2 additions & 2 deletions src/components/button/button-close.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from '../../utils/vue'
import { mergeData } from 'vue-functional-data-merge'
import { getComponentConfig } from '../../utils/config'
import { stopEvent } from '../../utils/events'
import { isEvent } from '../../utils/inspect'
import { hasNormalizedSlot, normalizeSlot } from '../../utils/normalize-slot'

Expand Down Expand Up @@ -49,8 +50,7 @@ export const BButtonClose = /*#__PURE__*/ Vue.extend({
// Ensure click on button HTML content is also disabled
/* istanbul ignore if: bug in JSDOM still emits click on inner element */
if (props.disabled && isEvent(evt)) {
evt.stopPropagation()
evt.preventDefault()
stopEvent(evt)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import KeyCodes from '../../utils/key-codes'
import { concat } from '../../utils/array'
import { getComponentConfig } from '../../utils/config'
import { addClass, isTag, removeClass } from '../../utils/dom'
import { stopEvent } from '../../utils/events'
import { isBoolean, isEvent, isFunction } from '../../utils/inspect'
import { omit } from '../../utils/object'
import { pluckProps } from '../../utils/props'
Expand Down Expand Up @@ -163,15 +164,14 @@ export const BButton = /*#__PURE__*/ Vue.extend({
// Add SPACE handler for `href="#"` and ENTER handler for non-standard tags
if (keyCode === KeyCodes.SPACE || (keyCode === KeyCodes.ENTER && nonStandardTag)) {
const target = evt.currentTarget || evt.target
evt.preventDefault()
stopEvent(evt, { propagation: false })
target.click()
}
},
click(evt) {
/* istanbul ignore if: blink/button disabled should handle this */
if (props.disabled && isEvent(evt)) {
evt.stopPropagation()
evt.preventDefault()
stopEvent(evt)
} else if (toggle && listeners && listeners['update:pressed']) {
// Send `.sync` updates to any "pressed" prop (if `.sync` listeners)
// `concat()` will normalize the value to an array without
Expand Down
Loading