gm-printer-label 3.3.6-beta.2 → 3.4.0

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.
Files changed (73) hide show
  1. package/lib/main.js +27 -0
  2. package/lib/package.json +96 -0
  3. package/package.json +10 -14
  4. package/.eslintrc.js +0 -12
  5. package/.github/workflows/release.yml +0 -46
  6. package/.prettierrc.js +0 -5
  7. package/.stylelintrc +0 -3
  8. package/babel.config.js +0 -7
  9. package/i18n.config.js +0 -9
  10. package/locales/en.json +0 -42
  11. package/locales/index.js +0 -32
  12. package/locales/th.json +0 -42
  13. package/locales/zh-HK.json +0 -43
  14. package/locales/zh.json +0 -1
  15. package/postcss.config.js +0 -9
  16. package/src/common/config.js +0 -82
  17. package/src/common/editor_compoents/component.js +0 -481
  18. package/src/common/editor_compoents/config_text.js +0 -47
  19. package/src/common/editor_compoents/context_menu.js +0 -129
  20. package/src/common/editor_compoents/edit.js +0 -106
  21. package/src/common/editor_compoents/edit_add_filed.js +0 -54
  22. package/src/common/editor_compoents/edit_modify_filed.js +0 -199
  23. package/src/common/editor_compoents/edit_select.js +0 -212
  24. package/src/common/editor_compoents/edit_title.js +0 -110
  25. package/src/common/editor_compoents/index.js +0 -10
  26. package/src/common/editor_compoents/store.js +0 -381
  27. package/src/common/editor_compoents/style.less +0 -425
  28. package/src/common/editor_compoents/with_shadow_dom_hoc.js +0 -30
  29. package/src/common/editor_compoents/with_store_hoc.js +0 -92
  30. package/src/components/css/animation.less +0 -95
  31. package/src/components/css/button.less +0 -49
  32. package/src/components/css/distance.less +0 -324
  33. package/src/components/css/text.less +0 -74
  34. package/src/components/css/variables.less +0 -12
  35. package/src/components/dialog/index.js +0 -72
  36. package/src/components/dialog/style.less +0 -64
  37. package/src/components/dropdown/drop_down.js +0 -67
  38. package/src/components/dropdown/drop_down_item.js +0 -37
  39. package/src/components/dropdown/drop_down_items.js +0 -22
  40. package/src/components/dropdown/index.js +0 -9
  41. package/src/components/dropdown/style.less +0 -51
  42. package/src/components/flex/index.js +0 -103
  43. package/src/components/flex/style.less +0 -101
  44. package/src/components/index.js +0 -15
  45. package/src/components/index.less +0 -10
  46. package/src/components/input_number/index.js +0 -158
  47. package/src/components/input_number/style.less +0 -10
  48. package/src/components/select/index.js +0 -7
  49. package/src/components/select/option.js +0 -32
  50. package/src/components/select/select.js +0 -122
  51. package/src/components/select/style.less +0 -79
  52. package/src/components/tip/index.js +0 -48
  53. package/src/components/tip/style.less +0 -22
  54. package/src/editor_label/edit_store.js +0 -3
  55. package/src/editor_label/editor.js +0 -5
  56. package/src/editor_label/editor_with_shadow_dom.js +0 -4
  57. package/src/editor_label/index.js +0 -1
  58. package/src/editor_presorting/edit_store.js +0 -3
  59. package/src/editor_presorting/editor_with_shadow_dom.js +0 -6
  60. package/src/editor_presorting/index.js +0 -1
  61. package/src/index.js +0 -7
  62. package/src/printer/barcode.js +0 -38
  63. package/src/printer/batch_printer.js +0 -43
  64. package/src/printer/block.js +0 -544
  65. package/src/printer/components/table_type.js +0 -46
  66. package/src/printer/index.js +0 -111
  67. package/src/printer/normalize.css +0 -341
  68. package/src/printer/page.js +0 -26
  69. package/src/printer/printer.js +0 -71
  70. package/src/printer/qrcode.js +0 -17
  71. package/src/printer/style.less +0 -28
  72. package/src/util.js +0 -87
  73. package/webpack.config.js +0 -53
@@ -1,51 +0,0 @@
1
- .dropdown-menu {
2
- display: block;
3
- position: initial;
4
- float: none;
5
- margin-top: 0;
6
- margin-bottom: 0;
7
- top: 100%;
8
- left: 0;
9
- padding: 5px 0;
10
- list-style: none;
11
- font-size: 12px;
12
- text-align: left;
13
- background-color: #fff;
14
- border: 1px solid #eee;
15
- border-radius: 0;
16
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
17
- background-clip: padding-box;
18
-
19
- a {
20
- cursor: pointer;
21
- text-decoration: none;
22
- display: block;
23
- padding: 3px 20px;
24
- clear: both;
25
- font-weight: 400;
26
- line-height: 1.5;
27
- color: #333;
28
- white-space: nowrap;
29
-
30
- &:hover {
31
- text-decoration: none;
32
- color: #262626;
33
- background-color: #f5f5f5;
34
- }
35
- }
36
- }
37
-
38
- .caret {
39
- display: inline-block;
40
- width: 0;
41
- height: 0;
42
- margin-left: -3px;
43
- vertical-align: middle;
44
- border-top: 4px dashed;
45
- border-right: 4px solid transparent;
46
- border-left: 4px solid transparent;
47
- }
48
-
49
- .dropdown-toggle {
50
- width: 24px;
51
- }
@@ -1,103 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import classNames from 'classnames'
4
-
5
- class Flex extends React.Component {
6
- render () {
7
- const {
8
- flex,
9
-
10
- auto, none, width, height,
11
-
12
- row, column,
13
-
14
- wrap, nowrap,
15
-
16
- justifyStart, justifyEnd, justifyCenter, justifyBetween, justifyAround,
17
-
18
- alignStart, alignEnd, alignCenter, alignBaseline, alignStretch,
19
-
20
- alignContentStart, alignContentEnd, alignContentCenter, alignContentBetween, alignContentAround, alignContentStretch,
21
-
22
- className, style,
23
-
24
- ...rest
25
- } = this.props
26
- const cn = classNames({
27
- 'gm-flex': true,
28
-
29
- 'gm-flex-flex': flex,
30
- 'gm-flex-auto': auto,
31
- 'gm-flex-none': none || width || height,
32
-
33
- 'gm-flex-row': row,
34
- 'gm-flex-column': column,
35
-
36
- 'gm-flex-wrap': wrap,
37
- 'gm-flex-nowrap': nowrap,
38
-
39
- 'gm-flex-justify-start': justifyStart,
40
- 'gm-flex-justify-end': justifyEnd,
41
- 'gm-flex-justify-center': justifyCenter,
42
- 'gm-flex-justify-between': justifyBetween,
43
- 'gm-flex-justify-around': justifyAround,
44
-
45
- 'gm-flex-align-start': alignStart,
46
- 'gm-flex-align-end': alignEnd,
47
- 'gm-flex-align-center': alignCenter,
48
- 'gm-flex-align-baseline': alignBaseline,
49
- 'gm-flex-align-stretch': alignStretch,
50
-
51
- 'gm-flex-align-content-start': alignContentStart,
52
- 'gm-flex-align-content-end': alignContentEnd,
53
- 'gm-flex-align-content-center': alignContentCenter,
54
- 'gm-flex-align-content-between': alignContentBetween,
55
- 'gm-flex-align-content-around': alignContentAround,
56
- 'gm-flex-align-content-stretch': alignContentStretch
57
- }, className)
58
-
59
- let s = Object.assign({}, style)
60
- if (flex) {
61
- s.flex = (typeof flex === 'boolean') ? 1 : flex
62
- s.WebKitFlex = (typeof flex === 'boolean') ? 1 : flex
63
- }
64
- if (height) {
65
- s.height = height
66
- }
67
- if (width) {
68
- s.width = width
69
- }
70
-
71
- return <div {...rest} className={cn} style={s}>{this.props.children}</div>
72
- }
73
- }
74
-
75
- Flex.propTypes = {
76
- flex: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),
77
- auto: PropTypes.bool,
78
- none: PropTypes.bool,
79
- width: PropTypes.string,
80
- height: PropTypes.string,
81
- row: PropTypes.bool,
82
- column: PropTypes.bool,
83
- wrap: PropTypes.bool,
84
- nowrap: PropTypes.bool,
85
- justifyStart: PropTypes.bool,
86
- justifyEnd: PropTypes.bool,
87
- justifyCenter: PropTypes.bool,
88
- justifyBetween: PropTypes.bool,
89
- justifyAround: PropTypes.bool,
90
- alignStart: PropTypes.bool,
91
- alignEnd: PropTypes.bool,
92
- alignCenter: PropTypes.bool,
93
- alignBaseline: PropTypes.bool,
94
- alignStretch: PropTypes.bool,
95
- alignContentStart: PropTypes.bool,
96
- alignContentEnd: PropTypes.bool,
97
- alignContentCenter: PropTypes.bool,
98
- alignContentBetween: PropTypes.bool,
99
- alignContentAround: PropTypes.bool,
100
- alignContentStretch: PropTypes.bool
101
- }
102
-
103
- export default Flex
@@ -1,101 +0,0 @@
1
- .gm-flex-flex {
2
- flex: 1;
3
- }
4
-
5
- .gm-flex-auto {
6
- flex: auto;
7
- }
8
-
9
- .gm-flex-none {
10
- flex: none;
11
- }
12
-
13
- .gm-flex {
14
- display: flex;
15
- flex-direction: row;
16
- flex-wrap: nowrap;
17
- justify-content: flex-start;
18
- align-content: stretch;
19
- align-items: stretch;
20
- box-sizing: border-box;
21
-
22
- &.gm-flex-wrap {
23
- flex-wrap: wrap;
24
- }
25
-
26
- &.gm-flex-nowrap {
27
- flex-wrap: nowrap;
28
- }
29
-
30
- &.gm-flex-row {
31
- flex-direction: row;
32
- }
33
-
34
- &.gm-flex-column {
35
- flex-direction: column;
36
- }
37
-
38
- &.gm-flex-justify-start {
39
- justify-content: flex-start;
40
- }
41
-
42
- &.gm-flex-justify-end {
43
- justify-content: flex-end;
44
- }
45
-
46
- &.gm-flex-justify-center {
47
- justify-content: center;
48
- }
49
-
50
- &.gm-flex-justify-between {
51
- justify-content: space-between;
52
- }
53
-
54
- &.gm-flex-justify-around {
55
- justify-content: space-around;
56
- }
57
-
58
- &.gm-flex-align-start {
59
- align-items: flex-start;
60
- }
61
-
62
- &.gm-flex-align-end {
63
- align-items: flex-end;
64
- }
65
-
66
- &.gm-flex-align-center {
67
- align-items: center;
68
- }
69
-
70
- &.gm-flex-align-baseline {
71
- align-items: baseline;
72
- }
73
-
74
- &.gm-flex-align-stretch {
75
- align-items: stretch;
76
- }
77
-
78
- &.gm-flex-align-content-start {
79
- align-content: flex-start;
80
- }
81
-
82
- &.gm-flex-align-content-end {
83
- align-content: flex-end;
84
- }
85
-
86
- &.gm-flex-align-content-center {
87
- align-content: center;
88
- }
89
-
90
- &.gm-flex-align-content-between {
91
- align-content: space-between;
92
- }
93
-
94
- &.gm-flex-align-content-around {
95
- align-content: space-around;
96
- }
97
-
98
- &.gm-flex-align-content-stretch {
99
- align-content: stretch;
100
- }
101
- }
@@ -1,15 +0,0 @@
1
- import Flex from './flex'
2
- import { Select, Option } from './select'
3
- import Tip from './tip'
4
- import { DropDown, DropDownItems, DropDownItem } from './dropdown'
5
- import Dialog from './dialog'
6
- import InputNumber from './input_number'
7
-
8
- export {
9
- Flex,
10
- Select, Option,
11
- Tip,
12
- DropDown, DropDownItems, DropDownItem,
13
- Dialog,
14
- InputNumber
15
- }
@@ -1,10 +0,0 @@
1
- @import './flex/style.less';
2
- @import './select/style.less';
3
- @import './tip/style.less';
4
- @import './dropdown/style.less';
5
- @import './dialog/style.less';
6
- @import './css/variables.less';
7
- @import './css/distance.less';
8
- @import './css/text.less';
9
- @import './css/button.less';
10
- @import './css/animation.less';
@@ -1,158 +0,0 @@
1
- import _ from 'lodash'
2
- import React from 'react'
3
- import PropTypes from 'prop-types'
4
- import classNames from 'classnames'
5
-
6
- function processPropsValue (value) {
7
- if (value === null) {
8
- return ''
9
- }
10
- return value + ''
11
- }
12
-
13
- function text2Number (value) {
14
- if (value === '') {
15
- return null
16
- }
17
- return _.isNaN(parseFloat(value)) ? null : parseFloat(value)
18
- }
19
-
20
- function checkValue (value, precision) {
21
- // 正则说明:前置无限【1-9】的数字加小数点加精度个数字,前置为「0」加小数点加精度个数字
22
- const reg = new RegExp(
23
- '(^[1-9]\\d*(\\.\\d{0,' +
24
- precision +
25
- '})?$)|(^0(\\.\\d{0,' +
26
- precision +
27
- '})?$)'
28
- )
29
-
30
- if (value.startsWith('-')) {
31
- value = value.slice(1)
32
- }
33
-
34
- if (value === '') {
35
- return true
36
- }
37
-
38
- return reg.test(value)
39
- }
40
-
41
- function fixNumber (value, min, max) {
42
- if (value !== null) {
43
- if (max !== undefined && value > max) {
44
- value = max
45
- } else if (min !== undefined && value < min) {
46
- value = min
47
- }
48
- }
49
-
50
- return value
51
- }
52
-
53
- class InputNumberV2 extends React.Component {
54
- constructor (props) {
55
- super(props)
56
-
57
- this.refInput = React.createRef()
58
- this.__isUnmount = false
59
-
60
- this.state = {
61
- value: processPropsValue(props.value)
62
- }
63
- }
64
-
65
- apiDoFocus () {
66
- if (this.__isUnmount) {
67
- return
68
- }
69
-
70
- this.refInput.current.focus()
71
- }
72
-
73
- componentWillUnmount () {
74
- this.__isUnmount = true
75
- }
76
-
77
- static getDerivedStateFromProps (props, state) {
78
- // 一旦不一致就应该改,要比较 number 形式
79
- if (props.value !== text2Number(state.value)) {
80
- return {
81
- value: processPropsValue(props.value)
82
- }
83
- }
84
-
85
- return null
86
- }
87
-
88
- handleChange = e => {
89
- const { min, max, precision, onChange } = this.props
90
-
91
- const eValue = e.target.value
92
-
93
- // 检测是否合法输入
94
- if (!checkValue(eValue, precision)) {
95
- return
96
- }
97
-
98
- const newValue = text2Number(eValue)
99
-
100
- const newFixValue = fixNumber(newValue, min, max)
101
-
102
- // 如果数据有被修正,则同步下修改的值到 state
103
- if (newFixValue !== newValue) {
104
- this.setState({
105
- value: processPropsValue(newFixValue)
106
- })
107
- } else {
108
- this.setState({
109
- value: eValue
110
- })
111
- }
112
-
113
- onChange(newFixValue)
114
- }
115
-
116
- render () {
117
- const {
118
- value,
119
- onChange,
120
- max,
121
- min,
122
- precision,
123
- className,
124
- ...rest
125
- } = this.props
126
-
127
- return (
128
- <input
129
- {...rest}
130
- type='text'
131
- ref={this.refInput}
132
- value={this.state.value}
133
- className={classNames('gm-input-number', className)}
134
- onChange={this.handleChange}
135
- />
136
- )
137
- }
138
- }
139
-
140
- InputNumberV2.displayName = 'InputNumberV2'
141
-
142
- InputNumberV2.propTypes = {
143
- max: PropTypes.number,
144
- min: PropTypes.number,
145
- value: PropTypes.number,
146
- placeholder: PropTypes.string,
147
- onChange: PropTypes.func.isRequired,
148
- precision: PropTypes.number, // 精确度,保留几位小数
149
- className: PropTypes.string,
150
- style: PropTypes.object
151
- }
152
-
153
- InputNumberV2.defaultProps = {
154
- value: null,
155
- precision: 2
156
- }
157
-
158
- export default InputNumberV2
@@ -1,10 +0,0 @@
1
- .gm-input-number {
2
- /* Firefox */
3
- -moz-appearance: textfield;
4
- }
5
-
6
- .gm-input-number::-webkit-outer-spin-button,
7
- .gm-input-number::-webkit-inner-spin-button {
8
- margin: 0;
9
- -webkit-appearance: none !important;
10
- }
@@ -1,7 +0,0 @@
1
- import Select from './select'
2
- import Option from './option'
3
-
4
- export {
5
- Select,
6
- Option
7
- }
@@ -1,32 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import classNames from 'classnames'
4
-
5
- class Option extends React.Component {
6
- render () {
7
- const {
8
- children,
9
- className,
10
- disabled,
11
- value, // eslint-disable-line
12
- ...rest
13
- } = this.props
14
- return (
15
- <div
16
- {...rest}
17
- className={classNames('gm-select-option', className, {
18
- 'disabled': disabled
19
- })}
20
- >{children}</div>
21
- )
22
- }
23
- }
24
-
25
- Option.displayName = 'Option'
26
-
27
- Option.propTypes = {
28
- value: PropTypes.any.isRequired,
29
- disabled: PropTypes.bool
30
- }
31
-
32
- export default Option
@@ -1,122 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import classNames from 'classnames'
4
- import { findDOMNode } from 'react-dom'
5
- import { contains } from 'gm-util'
6
- import _ from 'lodash'
7
-
8
- const findItemByValFromChildren = (children, val) => {
9
- children = React.Children.toArray(children)
10
- return _.find(children, (el) => (el.props.value === val))
11
- }
12
-
13
- class Select extends React.Component {
14
- constructor (props) {
15
- super(props)
16
- this.state = {
17
- show: false
18
- }
19
- }
20
-
21
- componentDidMount () {
22
- window.shadowRoot.addEventListener('click', this.handleBodyClick)
23
- }
24
-
25
- componentWillUnmount () {
26
- window.shadowRoot.removeEventListener('click', this.handleBodyClick)
27
- }
28
-
29
- handleBodyClick = (e) => {
30
- const target = e.target
31
- const selectDOM = findDOMNode(this)
32
- if (this.state.show && !contains(selectDOM, target)) {
33
- this.setState({ show: false })
34
- }
35
- }
36
-
37
- handleSelectionClick = () => {
38
- const { disabled } = this.props
39
- const { show } = this.state
40
-
41
- if (!disabled) {
42
- this.setState({
43
- show: !show
44
- })
45
- }
46
- }
47
-
48
- handleOptionClick (elProps) {
49
- const { onChange } = this.props
50
- const {
51
- value: elPropsValue,
52
- disabled: elPropsDisabled
53
- } = elProps
54
-
55
- if (!elPropsDisabled) {
56
- onChange(elPropsValue)
57
- this.setState({ show: false })
58
- }
59
- }
60
-
61
- render () {
62
- const { show } = this.state
63
- const {
64
- value,
65
- children,
66
- disabled,
67
- className,
68
- clean,
69
- ...rest
70
- } = this.props
71
-
72
- const selected = findItemByValFromChildren(children, value)
73
- const selectedChildren = selected && selected.props.children
74
-
75
- return (
76
- <div
77
- {...rest}
78
- className={classNames(className, `gm-select`, {
79
- 'gm-select-clean': clean,
80
- 'gm-select-open': show,
81
- 'disabled': disabled
82
- })}
83
- >
84
- <div
85
- className='gm-select-selection'
86
- onClick={this.handleSelectionClick}
87
- >
88
- <div className='gm-select-selected'>
89
- {selectedChildren !== undefined ? selectedChildren : <span>&nbsp;</span>}
90
- </div>
91
- <i className={classNames({
92
- 'gm-arrow-up': show,
93
- 'gm-arrow-down': !show
94
- })}/>
95
- </div>
96
-
97
- {show && (
98
- <div key='list' className='gm-select-list gm-animated gm-animated-fade-in-right'>
99
- {React.Children.map(children, (el) => (
100
- React.cloneElement(el, Object.assign({}, el.props, {
101
- className: classNames(el.props.className, {
102
- 'selected': el.props.value === value
103
- }),
104
- onClick: this.handleOptionClick.bind(this, el.props)
105
- }))
106
- ))}
107
- </div>
108
- )}
109
- </div>
110
- )
111
- }
112
- }
113
-
114
- Select.displayName = 'Select'
115
-
116
- Select.propTypes = {
117
- clean: PropTypes.bool,
118
- value: PropTypes.any.isRequired,
119
- onChange: PropTypes.func.isRequired
120
- }
121
-
122
- export default Select
@@ -1,79 +0,0 @@
1
- .gm-select {
2
- vertical-align: middle;
3
- display: inline-block;
4
- position: relative;
5
- min-width: 70px;
6
- background-color: #fff;
7
- user-select: none;
8
- cursor: pointer;
9
-
10
- &.disabled {
11
- cursor: not-allowed;
12
- background-color: #eee;
13
- opacity: 1;
14
- color: #848586;
15
- }
16
-
17
- .gm-select-selection {
18
- position: relative;
19
- border: 1px solid #eee;
20
- height: 30px;
21
- padding: 5px 18px 5px 10px;
22
-
23
- .gm-select-selected {
24
- overflow: hidden;
25
- text-overflow: ellipsis;
26
- white-space: nowrap;
27
- }
28
- }
29
-
30
- .gm-select-list {
31
- display: none;
32
- position: absolute;
33
- z-index: 3000;
34
- min-width: 70px;
35
- max-height: 250px;
36
- overflow-y: auto;
37
- border: 1px solid #eee;
38
- margin-top: 2px;
39
- background: white;
40
- }
41
-
42
- .gm-select-option {
43
- cursor: pointer;
44
- padding: 5px 10px;
45
- overflow: hidden;
46
- text-overflow: ellipsis;
47
- white-space: nowrap;
48
-
49
- &:hover {
50
- background-color: #edf3f9;
51
- }
52
-
53
- &.disabled {
54
- cursor: not-allowed;
55
- color: #848586;
56
- }
57
-
58
- &.selected {
59
- color: #56a3f2;
60
- }
61
- }
62
-
63
- &.gm-select-open {
64
- .gm-select-selection {
65
- border-color: #56a3f2;
66
- }
67
-
68
- .gm-select-list {
69
- display: block;
70
- }
71
- }
72
-
73
- &.gm-select-clean {
74
- .gm-select-selection {
75
- border: none;
76
- padding: 6px 18px 6px 10px;
77
- }
78
- }
79
- }