zds-pickers 4.0.3 → 4.0.6

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 (101) hide show
  1. package/.editorconfig +19 -0
  2. package/.github/workflows/codeql-analysis.yml +67 -0
  3. package/.nvmrc +1 -0
  4. package/.prettierignore +0 -0
  5. package/.prettierrc +13 -0
  6. package/.storybook/main.ts +42 -0
  7. package/.storybook/manager.ts +12 -0
  8. package/.storybook/preview.tsx +26 -0
  9. package/.vscode/extensions.json +32 -0
  10. package/.vscode/javascript.code-snippets +229 -0
  11. package/.vscode/settings.json +358 -0
  12. package/biome.jsonc +158 -0
  13. package/dist/index.cjs.js +15 -32
  14. package/dist/index.es.js +4144 -10129
  15. package/dist/types/hooks/useComponentSize.d.ts +5 -0
  16. package/dist/types/hooks/useStateWithDynamicDefault.d.ts +2 -0
  17. package/dist/types/index.d.ts +266 -2
  18. package/dist/types/main.d.ts +19 -0
  19. package/dist/types/midi/ccValues.d.ts +3 -0
  20. package/dist/types/midi/export.d.ts +22 -0
  21. package/dist/types/other/DefaultTooltip.d.ts +10 -0
  22. package/dist/types/other/OctavePlayer.d.ts +20 -0
  23. package/dist/types/other/SVGText.d.ts +17 -0
  24. package/dist/types/other/SoundFontProvider.d.ts +17 -0
  25. package/dist/types/pickers/CCPicker.d.ts +7 -0
  26. package/dist/types/pickers/ChannelMappingPicker.d.ts +14 -0
  27. package/dist/types/pickers/ChannelPicker.d.ts +8 -0
  28. package/dist/types/pickers/Knob.d.ts +12 -0
  29. package/dist/types/pickers/KnobPicker.d.ts +27 -0
  30. package/dist/types/pickers/LatchPicker.d.ts +8 -0
  31. package/dist/types/pickers/MappingPicker.d.ts +11 -0
  32. package/dist/types/pickers/NotePicker.d.ts +20 -0
  33. package/dist/types/pickers/PianoPicker.d.ts +9 -0
  34. package/dist/types/pickers/PolarityPicker.d.ts +14 -0
  35. package/dist/types/pickers/ResponseCurve.d.ts +40 -0
  36. package/dist/types/pickers/ResponseCurvePicker.d.ts +15 -0
  37. package/dist/types/pickers/Select.d.ts +29 -0
  38. package/dist/types/pickers/StatusPicker.d.ts +12 -0
  39. package/dist/types/pickers/ValuePicker.d.ts +15 -0
  40. package/dist/types/pickers/knobSkin10.d.ts +14 -0
  41. package/dist/types/rotaryKnob/InternalInput.d.ts +18 -0
  42. package/dist/types/rotaryKnob/Types.d.ts +5 -0
  43. package/dist/types/rotaryKnob/helpers/DrawCircle.d.ts +18 -0
  44. package/dist/types/rotaryKnob/helpers/DrawLine.d.ts +15 -0
  45. package/dist/types/rotaryKnob/helpers/HelpersOverlay.d.ts +11 -0
  46. package/dist/types/rotaryKnob/helpers/KnobVisualHelpers.d.ts +30 -0
  47. package/dist/types/rotaryKnob/index.d.ts +49 -0
  48. package/dist/types/rotaryKnob/knobdefaultskin.d.ts +6 -0
  49. package/dist/types/rotaryKnob/utils.d.ts +49 -0
  50. package/dist/types/utils.d.ts +9 -0
  51. package/lib/@types/nebiru-react-rotary-knob.d.ts +20 -0
  52. package/lib/@types/react-svgmt.d.ts +74 -0
  53. package/lib/@types/zds-mappings.d.ts +55 -0
  54. package/lib/@types/zds-react-piano.d.ts +17 -0
  55. package/lib/hooks/useComponentSize.ts +52 -0
  56. package/lib/hooks/useStateWithDynamicDefault.ts +13 -0
  57. package/lib/main.ts +34 -0
  58. package/lib/midi/ccValues.ts +139 -0
  59. package/lib/midi/export.ts +54 -0
  60. package/lib/other/DefaultTooltip.ts +14 -0
  61. package/lib/other/OctavePlayer.tsx +141 -0
  62. package/lib/other/SVGText.tsx +221 -0
  63. package/lib/other/SoundFontProvider.tsx +130 -0
  64. package/lib/pickers/CCPicker.tsx +28 -0
  65. package/lib/pickers/ChannelMappingPicker.tsx +135 -0
  66. package/lib/pickers/ChannelPicker.tsx +76 -0
  67. package/lib/pickers/Knob.tsx +93 -0
  68. package/lib/pickers/KnobPicker.tsx +93 -0
  69. package/lib/pickers/LatchPicker.tsx +33 -0
  70. package/lib/pickers/MappingPicker.tsx +68 -0
  71. package/lib/pickers/NotePicker.tsx +95 -0
  72. package/lib/pickers/PianoPicker.tsx +77 -0
  73. package/lib/pickers/PolarityPicker.tsx +39 -0
  74. package/lib/pickers/ResponseCurve.tsx +304 -0
  75. package/lib/pickers/ResponseCurvePicker.tsx +74 -0
  76. package/lib/pickers/Select.tsx +248 -0
  77. package/lib/pickers/StatusPicker.tsx +28 -0
  78. package/lib/pickers/ValuePicker.tsx +67 -0
  79. package/lib/pickers/knobSkin10.tsx +94 -0
  80. package/lib/rotaryKnob/InternalInput.tsx +43 -0
  81. package/lib/rotaryKnob/Types.ts +6 -0
  82. package/lib/rotaryKnob/helpers/DrawCircle.tsx +41 -0
  83. package/lib/rotaryKnob/helpers/DrawLine.tsx +32 -0
  84. package/lib/rotaryKnob/helpers/HelpersOverlay.tsx +43 -0
  85. package/lib/rotaryKnob/helpers/KnobVisualHelpers.tsx +138 -0
  86. package/lib/rotaryKnob/index.tsx +417 -0
  87. package/lib/rotaryKnob/knobdefaultskin.ts +56 -0
  88. package/lib/rotaryKnob/utils.ts +112 -0
  89. package/lib/temp/acoustic_grand_piano-mp3.js +94 -0
  90. package/lib/utils.ts +41 -0
  91. package/package.json +3 -7
  92. package/stories/assets/sampleStyles.css +349 -0
  93. package/stories/assets/utils.js +7 -0
  94. package/stories/picker.stories.tsx +313 -0
  95. package/tsconfig.app.json +26 -0
  96. package/tsconfig.json +34 -0
  97. package/tsconfig.node.json +24 -0
  98. package/vite.config.ts +45 -0
  99. package/dist/index.cjs.js.map +0 -1
  100. package/dist/index.d.ts +0 -244
  101. package/dist/index.es.js.map +0 -1
package/.editorconfig ADDED
@@ -0,0 +1,19 @@
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+
3
+ # https://github.com/jokeyrhyme/standard-editorconfig
4
+
5
+ # top-most EditorConfig file
6
+ root = true
7
+
8
+ # defaults
9
+ [*]
10
+ charset = utf-8
11
+ end_of_line = lf
12
+ insert_final_newline = true
13
+ trim_trailing_whitespace = true
14
+ indent_size = 2
15
+ indent_style = space
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
19
+ max_line_length = 200
@@ -0,0 +1,67 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '34 5 * * 0'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ language: [ 'javascript' ]
32
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33
+ # Learn more:
34
+ # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35
+
36
+ steps:
37
+ - name: Checkout repository
38
+ uses: actions/checkout@v2
39
+
40
+ # Initializes the CodeQL tools for scanning.
41
+ - name: Initialize CodeQL
42
+ uses: github/codeql-action/init@v1
43
+ with:
44
+ languages: ${{ matrix.language }}
45
+ # If you wish to specify custom queries, you can do so here or in a config file.
46
+ # By default, queries listed here will override any specified in a config file.
47
+ # Prefix the list here with "+" to use these queries and those in the config file.
48
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
49
+
50
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51
+ # If this step fails, then you should remove it and run the build manually (see below)
52
+ - name: Autobuild
53
+ uses: github/codeql-action/autobuild@v1
54
+
55
+ # ℹ️ Command-line programs to run using the OS shell.
56
+ # 📚 https://git.io/JvXDl
57
+
58
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59
+ # and modify them (or add more) to build your code if your project
60
+ # uses a compiled language
61
+
62
+ #- run: |
63
+ # make bootstrap
64
+ # make release
65
+
66
+ - name: Perform CodeQL Analysis
67
+ uses: github/codeql-action/analyze@v1
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 22.13.0
File without changes
package/.prettierrc ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "eslintIntegration": true,
3
+ "singleQuote": true,
4
+ "trailingComma": "all",
5
+ "semi": false,
6
+ "tabWidth": 2,
7
+ "overrides": [
8
+ {
9
+ "files": "mdx",
10
+ "options": { "parser": "mdx" }
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,42 @@
1
+ import type { StorybookConfig } from '@storybook/react-vite'
2
+
3
+ const config: StorybookConfig = {
4
+ stories: ['../stories/*.stories.tsx'],
5
+
6
+ addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
7
+
8
+ framework: {
9
+ name: '@storybook/react-vite',
10
+ options: {},
11
+ },
12
+
13
+ core: {
14
+ disableTelemetry: true,
15
+ builder: '@storybook/builder-vite',
16
+ },
17
+
18
+ docs: {
19
+ autodocs: false,
20
+ },
21
+
22
+ typescript: {
23
+ // reactDocgen: 'react-docgen-typescript',
24
+ },
25
+
26
+ viteFinal(config) {
27
+ return {
28
+ ...config,
29
+ optimizeDeps: {
30
+ exclude: ['storybook-dark-mode'],
31
+ },
32
+ css: {
33
+ postcss: {},
34
+ modules: {
35
+ localsConvention: 'camelCase',
36
+ },
37
+ },
38
+ }
39
+ },
40
+ }
41
+
42
+ export default config
@@ -0,0 +1,12 @@
1
+ import { addons } from '@storybook/manager-api'
2
+
3
+ addons.setConfig({
4
+ sidebar: {
5
+ renderLabel: (item: { name: string }) => {
6
+ return item.name
7
+ .replace(/([A-Z])/g, ' $1')
8
+ .trim()
9
+ .replaceAll('Story', '')
10
+ },
11
+ },
12
+ })
@@ -0,0 +1,26 @@
1
+ import type { Preview, StoryContext, StoryFn } from '@storybook/react'
2
+ // biome-ignore lint/correctness/noUnusedImports: <explanation>
3
+ import React from 'react'
4
+ import { useState } from 'react'
5
+ import '../stories/assets/sampleStyles.css'
6
+
7
+ const preview: Preview = {
8
+ decorators: [
9
+ (Story: StoryFn, context: StoryContext) => {
10
+ const [value, setValue] = useState(context.args.value || 0)
11
+ return (
12
+ <div>
13
+ <Story
14
+ args={{
15
+ ...context.args,
16
+ value,
17
+ onChange: setValue,
18
+ }}
19
+ />
20
+ </div>
21
+ )
22
+ },
23
+ ],
24
+ }
25
+
26
+ export default preview
@@ -0,0 +1,32 @@
1
+ {
2
+ // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3
+ // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4
+
5
+ // List of extensions which should be recommended for users of this workspace.
6
+ "recommendations": [
7
+ "christian-kohler.npm-intellisense",
8
+ "christian-kohler.path-intellisense",
9
+ "dbaeumer.vscode-eslint",
10
+ "dsznajder.es7-react-js-snippets",
11
+ "editorconfig.editorconfig",
12
+ "esbenp.prettier-vscode",
13
+ "formulahendry.auto-close-tag",
14
+ "formulahendry.auto-rename-tag",
15
+ "jzarzoso.break-from-comma",
16
+ "lihui.vs-color-picker",
17
+ "meganrogge.template-string-converter",
18
+ "mrmlnc.vscode-json5",
19
+ "msjsdiag.debugger-for-chrome",
20
+ "naumovs.color-highlight",
21
+ "paulmolluzzo.convert-css-in-js",
22
+ "pflannery.vscode-versionlens",
23
+ "quicktype.quicktype",
24
+ "richie5um2.vscode-sort-json",
25
+ "streetsidesoftware.code-spell-checker",
26
+ "unifiedjs.vscode-mdx",
27
+ "wayou.vscode-todo-highlight",
28
+ "zignd.html-css-class-completion"
29
+ ],
30
+ // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
31
+ "unwantedRecommendations": ["silvenon.mdx"]
32
+ }
@@ -0,0 +1,229 @@
1
+ {
2
+ "Debugger": {
3
+ "prefix": "db",
4
+ "body": ["debugger // eslint-disable-line"],
5
+ "description": "Break for debugger, but have eslint leave us alone."
6
+ },
7
+
8
+ "Print to console": {
9
+ "prefix": "lg",
10
+ "body": ["console.log($1)", "$2"],
11
+ "description": "Log output to console"
12
+ },
13
+
14
+ "Print debug to console": {
15
+ "prefix": "lgw",
16
+ "body": ["console.log(wrapper.debug())"],
17
+ "description": "Log output to console"
18
+ },
19
+
20
+ "Import act (for enzyme only)": {
21
+ "prefix": "ac",
22
+ "body": ["import { act } from 'react-dom/test-utils'"],
23
+ "description": "Import act() suitable for Enzyme"
24
+ },
25
+
26
+ "Import PropTypes": {
27
+ "prefix": "pt",
28
+ "body": ["import PropTypes from 'prop-types'"],
29
+ "description": "Adds import for PropTypes"
30
+ },
31
+
32
+ "Import classNames": {
33
+ "prefix": "cl",
34
+ "body": ["import cl from 'classnames'"],
35
+ "description": "Adds import for classnames"
36
+ },
37
+
38
+ "Import makeStyles": {
39
+ "prefix": "ms",
40
+ "body": ["import makeStyles from '@material-ui/core/styles/makeStyles'"],
41
+ "description": "Adds import for makeStyles"
42
+ },
43
+
44
+ "Import matchmedia mock": {
45
+ "prefix": "mm",
46
+ "body": [
47
+ "import '@mocks/matchMedia-mock'",
48
+ ],
49
+ "description": "Adds import for the matchmedia mock"
50
+ },
51
+
52
+ "Import styled": {
53
+ "prefix": "sty",
54
+ "body": ["import styled from '@material-ui/core/styles/styled'"],
55
+ "description": "Adds import for styled"
56
+ },
57
+
58
+ "Add a useState declaration": {
59
+ "prefix": "ss",
60
+ "body": ["const [${1/(.*)/${1}, set${1:/capitalize}/}] = useState()"],
61
+ "description": "Adds a state hook"
62
+ },
63
+
64
+ "useStyles": {
65
+ "prefix": "us",
66
+ "body": [
67
+ "const useStyles = makeStyles(({ mixins: { rem }, palette }) => ({",
68
+ " root: {",
69
+ " },",
70
+ "}), { name: '${1:$TM_FILENAME_BASE}' })"
71
+ ],
72
+ "description": "Adds useStyles"
73
+ },
74
+
75
+ "Insert styles": {
76
+ "prefix": "uss",
77
+ "body": ["const classes = useStyles()"],
78
+ "description": "Get classes from useStyles hook"
79
+ },
80
+
81
+ "use styled": {
82
+ "prefix": "st",
83
+ "body": [
84
+ "export default styled(${1:$TM_FILENAME_BASE})(({ theme: { mixins: {}, palette } }) => ({",
85
+ "}), { name: '${1:$TM_FILENAME_BASE}' })",
86
+ ],
87
+ "description": "the styled components form of makeStyles"
88
+ },
89
+
90
+ "React pure function": {
91
+ "prefix": "rcp",
92
+ "body": [
93
+ "import PropTypes from 'prop-types'",
94
+ "",
95
+ "const ${1:$TM_FILENAME_BASE} = (props) => {",
96
+ " const { } = props",
97
+ " return <div>${1:$TM_FILENAME_BASE}</div>",
98
+ "}",
99
+ "",
100
+ "${1:$TM_FILENAME_BASE}.propTypes = {}",
101
+ "",
102
+ "export default ${1:$TM_FILENAME_BASE}",
103
+ "",
104
+ ],
105
+ "description": "Shell for a simple react component"
106
+ },
107
+
108
+ "React styled component": {
109
+ "prefix": "rcs",
110
+ "body": [
111
+ "import styled from '@material-ui/core/styles/styled'",
112
+ "",
113
+ "const ${1:$TM_FILENAME_BASE} = ({ className }) => {",
114
+ " return <div className={className}>${1:$TM_FILENAME_BASE}</div>",
115
+ "}",
116
+ "",
117
+ "export default styled(${1:$TM_FILENAME_BASE})(({ theme: { mixins: {}, palette } }) => ({",
118
+ "}), { name: '${1:$TM_FILENAME_BASE}' })",
119
+ "",
120
+ ],
121
+ "description": "Shell for a simple styled component"
122
+ },
123
+
124
+ "React pure function useStyles": {
125
+ "prefix": "rcps",
126
+ "body": [
127
+ "import PropTypes from 'prop-types'",
128
+ "import makeStyles from '@material-ui/core/styles/makeStyles'",
129
+ "",
130
+ "const useStyles = makeStyles(({ mixins: {}, palette }) => ({",
131
+ " root: {},",
132
+ "}), { name: '${1:$TM_FILENAME_BASE}' })",
133
+ "",
134
+ "const ${1:$TM_FILENAME_BASE} = (props) => {",
135
+ " const { } = props",
136
+ " const classes = useStyles()",
137
+ "",
138
+ " return <div className={classes.root}>${1:$TM_FILENAME_BASE}</div>",
139
+ "}",
140
+ "",
141
+ "${1:$TM_FILENAME_BASE}.propTypes = {}",
142
+ "",
143
+ "export default ${1:$TM_FILENAME_BASE}",
144
+ "",
145
+ ],
146
+ "description": "Shell for simple react component with useStyles"
147
+ },
148
+
149
+ "Empty reducer": {
150
+ "prefix": "red",
151
+ "body": [
152
+ "import PropTypes from 'prop-types'",
153
+ "import { createReducer } from '../utils'",
154
+ "",
155
+ "export const actionTypes = {}",
156
+ "",
157
+ "export const initialState = {}",
158
+ "",
159
+ "export const ${1:name}Shape = PropTypes.shape({})",
160
+ "",
161
+ "export const actions = {}",
162
+ "",
163
+ "export default createReducer(initialState, {})",
164
+ ""
165
+ ],
166
+ "description": ""
167
+ },
168
+
169
+ "Component test shell": {
170
+ "prefix": "rct",
171
+ "body": [
172
+ "import { compose } from 'redux'",
173
+ "import ${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g} from './${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g}'",
174
+ "",
175
+ "describe('<${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g} />', () => {",
176
+ " const defaultProps = {}",
177
+ "",
178
+ " beforeEach(jest.resetAllMocks)",
179
+ "",
180
+ " const getWrapper = compose(",
181
+ " mount,",
182
+ " createElement(${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g}),",
183
+ " withProps(defaultProps),",
184
+ " )",
185
+ "",
186
+ " it('should render', () => {",
187
+ " const wrapper = getWrapper()",
188
+ " console.log(wrapper.debug())",
189
+ " })",
190
+ "})",
191
+ "",
192
+ ],
193
+ "description": "Shell for typical component test"
194
+ },
195
+
196
+ "Component test shell (RTL)": {
197
+ "prefix": "rctl",
198
+ "body": [
199
+ "import '@config/testingLibrary'",
200
+ "import { compose } from 'redux'",
201
+ "import { screen } from '@testing-library/dom'",
202
+ "import { act } from '@testing-library/react'",
203
+ "import userEvent from '@testing-library/user-event'",
204
+ "import ${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g} from './${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g}'",
205
+ "",
206
+ "describe('<${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g} />', () => {",
207
+ " const defaultProps = {}",
208
+ "",
209
+ " beforeEach(jest.resetAllMocks)",
210
+ " afterEach(cleanup)",
211
+ "",
212
+ " const { debug, getByTestId } = screen",
213
+ "",
214
+ " const getWrapper = compose(",
215
+ " render,",
216
+ " createElement(${TM_FILENAME_BASE/(?:\\.spec$)/${1}/g}),",
217
+ " withProps(defaultProps),",
218
+ " )",
219
+ "",
220
+ " it('should render', () => {",
221
+ " getWrapper()",
222
+ " debug()",
223
+ " })",
224
+ "})",
225
+ "",
226
+ ],
227
+ "description": "Shell for typical component test, using RTL"
228
+ },
229
+ }