@operato/pull-to-refresh 8.0.0-beta.0 β†’ 8.0.0-beta.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.0.0-beta.2](https://github.com/hatiolab/operato/compare/v8.0.0-beta.1...v8.0.0-beta.2) (2025-01-08)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * typo .npmignore ([d9c0c8c](https://github.com/hatiolab/operato/commit/d9c0c8c79abc688c3c2cfb6c37fcb689483a5977))
12
+
13
+
14
+
15
+ ## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
16
+
17
+
18
+ ### :bug: Bug Fix
19
+
20
+ * missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
21
+
22
+
23
+
6
24
  ## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
7
25
 
8
26
  **Note:** Version bump only for package @operato/pull-to-refresh
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/pull-to-refresh",
3
3
  "description": "Webcomponent pull-to-refresh following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "8.0.0-beta.0",
5
+ "version": "8.0.0-beta.2",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "license": "MIT",
@@ -68,5 +68,5 @@
68
68
  "prettier --write"
69
69
  ]
70
70
  },
71
- "gitHead": "c4e9cc245659d050a9ffd66542083a6daad4bcb9"
71
+ "gitHead": "ee1b5124995accb99272d3b5854f3df1d8746dda"
72
72
  }
package/.editorconfig DELETED
@@ -1,29 +0,0 @@
1
- # EditorConfig helps developers define and maintain consistent
2
- # coding styles between different editors and IDEs
3
- # editorconfig.org
4
-
5
- root = true
6
-
7
-
8
- [*]
9
-
10
- # Change these settings to your own preference
11
- indent_style = space
12
- indent_size = 2
13
-
14
- # We recommend you to keep these unchanged
15
- end_of_line = lf
16
- charset = utf-8
17
- trim_trailing_whitespace = true
18
- insert_final_newline = true
19
-
20
- [*.md]
21
- trim_trailing_whitespace = false
22
-
23
- [*.json]
24
- indent_size = 2
25
-
26
- [*.{html,js,md}]
27
- block_comment_start = /**
28
- block_comment = *
29
- block_comment_end = */
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- stories: ['../dist/stories/**/*.stories.{js,md,mdx}'],
3
- };
@@ -1,52 +0,0 @@
1
- import { i18next } from '@operato/i18n'
2
-
3
- export const globalTypes = {
4
- locale: {
5
- name: 'Locale',
6
- description: 'Internationalization locale',
7
- toolbar: {
8
- icon: 'globe',
9
- items: [
10
- { value: 'en', right: 'πŸ‡ΊπŸ‡Έ', title: 'English' },
11
- { value: 'ko', right: 'πŸ‡°πŸ‡·', title: 'ν•œκ΅­μ–΄' },
12
- { value: 'zh', right: 'πŸ‡¨πŸ‡³', title: 'δΈ­ζ–‡' },
13
- { value: 'ja', right: 'πŸ‡―πŸ‡΅', title: 'ζ—₯本θͺž' },
14
- { value: 'ms', right: 'πŸ‡²πŸ‡Ύ', title: 'Bahasa Melayu' }
15
- ],
16
- showName: true
17
- }
18
- },
19
- theme: {
20
- name: 'Theme',
21
- description: 'Global theme for components',
22
- toolbar: {
23
- icon: 'paintbrush',
24
- items: [
25
- { value: 'light', title: 'Light' },
26
- { value: 'dark', title: 'Dark' }
27
- ],
28
- showName: true
29
- }
30
- }
31
- }
32
-
33
- export const decorators = [
34
- (Story, context) => {
35
- const { locale, theme } = context.globals
36
-
37
- if (locale) {
38
- i18next.changeLanguage(locale)
39
- }
40
-
41
- // Set the theme class for the document
42
- if (theme === 'dark') {
43
- document.documentElement.classList.add('dark')
44
- document.documentElement.classList.remove('light')
45
- } else {
46
- document.documentElement.classList.add('light')
47
- document.documentElement.classList.remove('dark')
48
- }
49
-
50
- return Story()
51
- }
52
- ]
@@ -1,8 +0,0 @@
1
- import { storybookPlugin } from '@web/dev-server-storybook';
2
- import baseConfig from '../web-dev-server.config.mjs';
3
-
4
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
- ...baseConfig,
6
- open: '/',
7
- plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
8
- });
package/demo/index.html DELETED
@@ -1,35 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en-GB">
3
- <head>
4
- <meta charset="utf-8" />
5
- <style>
6
- body {
7
- display: flex;
8
- width: 100vw;
9
- height: 100dvh;
10
- margin: 0;
11
- padding: 0;
12
- }
13
-
14
- #demo {
15
- flex: 1;
16
- background-color: red;
17
- }
18
- </style>
19
- </head>
20
- <body>
21
- <div id="demo"></div>
22
-
23
- <script type="module">
24
- import { pulltorefresh } from '../dist/src/pull-to-refresh.js'
25
-
26
- pulltorefresh({
27
- container: document.body,
28
- scrollable: document.querySelector('#demo'),
29
- refresh: () => {
30
- console.log('refreshed...')
31
- }
32
- })
33
- </script>
34
- </body>
35
- </html>
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './pull-to-refresh'
@@ -1,211 +0,0 @@
1
- import { css, html, LitElement } from 'lit'
2
- import { customElement } from 'lit/decorators.js'
3
-
4
- @customElement('ox-pulltorefresh-control')
5
- export class PullToRefreshControl extends LitElement {
6
- static styles = css`
7
- :host {
8
- position: absolute;
9
- top: -50px;
10
- left: 50%;
11
- -webkit-transform: translate3d(-50%, 0, 0);
12
- transform: translate3d(-50%, 0, 0);
13
- width: 40px;
14
- height: 40px;
15
- justify-content: center;
16
- align-items: center;
17
- background: #fff;
18
- border-radius: 50%;
19
- box-shadow: 0 1px 6px rgba(0, 0, 0, 0.117647), 0 1px 4px rgba(0, 0, 0, 0.117647);
20
- display: none;
21
-
22
- z-index: 10000;
23
-
24
- will-change: transform;
25
- }
26
-
27
- :host(.pull-to-refresh--pulling),
28
- :host(.pull-to-refresh--aborting),
29
- :host(.pull-to-refresh--reached),
30
- :host(.pull-to-refresh--refreshing),
31
- :host(.pull-to-refresh--restoring) {
32
- display: flex;
33
- }
34
-
35
- :host(.pull-to-refresh--pulling) .pull-to-refresh-material__spinner,
36
- :host(.pull-to-refresh--aborting) .pull-to-refresh-material__spinner,
37
- :host(.pull-to-refresh--reached) .pull-to-refresh-material__spinner,
38
- :host(.pull-to-refresh--refreshing) .pull-to-refresh-material__icon,
39
- :host(.pull-to-refresh--restoring) .pull-to-refresh-material__icon {
40
- display: none;
41
- }
42
-
43
- .pull-to-refresh-material__spinner {
44
- -webkit-transform-origin: center center;
45
- transform-origin: center center;
46
- -webkit-animation: pull-to-refresh-material-rotate 2s linear infinite;
47
- animation: pull-to-refresh-material-rotate 2s linear infinite;
48
- }
49
-
50
- .pull-to-refresh-material__path {
51
- stroke-dasharray: 1, 200;
52
- stroke-dashoffset: 0;
53
- stroke-linecap: round;
54
- -webkit-animation: pull-to-refresh-material-dash 1.5s ease-in-out infinite;
55
- animation: pull-to-refresh-material-dash 1.5s ease-in-out infinite;
56
- }
57
-
58
- .pull-to-refresh-material__path--colorful {
59
- -webkit-animation: pull-to-refresh-material-dash 1.5s ease-in-out infinite,
60
- pull-to-refresh-material-colorful 6s ease-in-out infinite;
61
- animation: pull-to-refresh-material-dash 1.5s ease-in-out infinite,
62
- pull-to-refresh-material-colorful 6s ease-in-out infinite;
63
- }
64
-
65
- @-webkit-keyframes pull-to-refresh-material-rotate {
66
- 100% {
67
- -webkit-transform: rotate(360deg);
68
- transform: rotate(360deg);
69
- }
70
- }
71
-
72
- @keyframes pull-to-refresh-material-rotate {
73
- 100% {
74
- -webkit-transform: rotate(360deg);
75
- transform: rotate(360deg);
76
- }
77
- }
78
-
79
- @-webkit-keyframes pull-to-refresh-material-dash {
80
- 0% {
81
- stroke-dasharray: 1, 200;
82
- stroke-dashoffset: 0;
83
- }
84
- 50% {
85
- stroke-dasharray: 89, 200;
86
- stroke-dashoffset: -35px;
87
- }
88
- 100% {
89
- stroke-dasharray: 89, 200;
90
- stroke-dashoffset: -124px;
91
- }
92
- }
93
-
94
- @keyframes pull-to-refresh-material-dash {
95
- 0% {
96
- stroke-dasharray: 1, 200;
97
- stroke-dashoffset: 0;
98
- }
99
- 50% {
100
- stroke-dasharray: 89, 200;
101
- stroke-dashoffset: -35px;
102
- }
103
- 100% {
104
- stroke-dasharray: 89, 200;
105
- stroke-dashoffset: -124px;
106
- }
107
- }
108
-
109
- @-webkit-keyframes pull-to-refresh-material-colorful {
110
- 100%,
111
- 0% {
112
- stroke: #4285f4;
113
- }
114
- 40% {
115
- stroke: #ea4335;
116
- }
117
- 66% {
118
- stroke: #fbbc05;
119
- }
120
- 80%,
121
- 90% {
122
- stroke: #34a853;
123
- }
124
- }
125
-
126
- @keyframes pull-to-refresh-material-colorful {
127
- 100%,
128
- 0% {
129
- stroke: #4285f4;
130
- }
131
- 40% {
132
- stroke: #ea4335;
133
- }
134
- 66% {
135
- stroke: #fbbc05;
136
- }
137
- 80%,
138
- 90% {
139
- stroke: #34a853;
140
- }
141
- }
142
- `
143
-
144
- render() {
145
- return html`
146
- <svg class="pull-to-refresh-material__icon" fill="#4285f4" width="24" height="24" viewBox="0 0 24 24">
147
- <path
148
- d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
149
- />
150
- <path d="M0 0h24v24H0z" fill="none" />
151
- </svg>
152
-
153
- <svg class="pull-to-refresh-material__spinner" width="24" height="24" viewBox="25 25 50 50">
154
- <circle
155
- class="pull-to-refresh-material__path"
156
- cx="50"
157
- cy="50"
158
- r="20"
159
- fill="none"
160
- stroke="#4285f4"
161
- stroke-width="4"
162
- stroke-miterlimit="10"
163
- />
164
- </svg>
165
- `
166
- }
167
-
168
- pulling(d: number, opts: any) {
169
- const { threshold } = opts
170
-
171
- let p = d / threshold
172
- if (p > 1) p = 1
173
- else p = p * p * p
174
- const y = d / 2.5
175
-
176
- this.style.opacity = String(p)
177
- this.style.transform = y ? `translate3d(-50%, ${y}px, 0) rotate(${360 * p}deg)` : ''
178
- }
179
-
180
- refreshing({ threshold }: any) {
181
- this.style.transition = 'transform 0.2s'
182
- this.style.transform = `translate3d(-50%, ${threshold / 2.5}px, 0)`
183
- }
184
-
185
- aborting() {
186
- return new Promise<void>(resolve => {
187
- if (this.style.transform) {
188
- this.style.transition = 'transform 0.3s, opacity 0.15s'
189
- this.style.transform = 'translate3d(-50%, 0, 0)'
190
- this.style.opacity = '0'
191
- this.addEventListener('transitionend', () => {
192
- this.style.transition = ''
193
- resolve()
194
- })
195
- } else {
196
- resolve()
197
- }
198
- })
199
- }
200
-
201
- restoring() {
202
- return new Promise<void>(resolve => {
203
- this.style.transition = 'transform 0.3s'
204
- this.style.transform += ' scale(0.01)'
205
- this.addEventListener('transitionend', () => {
206
- this.style.transition = ''
207
- resolve()
208
- })
209
- })
210
- }
211
- }
@@ -1,180 +0,0 @@
1
- /**
2
- * inspired by https://github.com/jiangfengming/pull-to-refresh
3
- */
4
-
5
- import './pull-to-refresh-control'
6
-
7
- function ontouchpan({
8
- element,
9
- animates,
10
- onpanstart,
11
- onpanmove,
12
- onpanend
13
- }: {
14
- element: HTMLElement
15
- animates: HTMLElement
16
- onpanstart?: any
17
- onpanmove: any
18
- onpanend: any
19
- }): boolean | (() => void) {
20
- let touchId: number, startX: number, startY: number, panstartCalled: boolean
21
-
22
- function calcMovement(e: any) {
23
- const touch = Array.prototype.slice.call(e.changedTouches).filter(touch => touch.identifier === touchId)[0]
24
- if (!touch) return false
25
-
26
- e.deltaX = touch.screenX - startX
27
- e.deltaY = touch.screenY - startY
28
- return true
29
- }
30
-
31
- function touchstart(e: TouchEvent) {
32
- const touch = e.changedTouches[0]
33
- touchId = touch.identifier
34
- startX = touch.screenX
35
- startY = touch.screenY
36
- }
37
-
38
- function touchmove(e: TouchEvent) {
39
- if (calcMovement(e)) {
40
- if (onpanstart && !panstartCalled) {
41
- onpanstart(e)
42
- panstartCalled = true
43
- }
44
-
45
- onpanmove(e)
46
- }
47
- }
48
-
49
- function touchend(e: TouchEvent) {
50
- if (calcMovement(e)) onpanend(e)
51
- }
52
-
53
- element.addEventListener('touchstart', touchstart)
54
- if (onpanmove) element.addEventListener('touchmove', touchmove)
55
- if (onpanend) element.addEventListener('touchend', touchend)
56
-
57
- return function () {
58
- element.removeEventListener('touchstart', touchstart)
59
- if (onpanmove) element.removeEventListener('touchmove', touchmove)
60
- if (onpanend) element.removeEventListener('touchend', touchend)
61
-
62
- animates && animates.remove()
63
- }
64
- }
65
-
66
- export function pulltorefresh(opts: any) {
67
- opts = Object.assign(
68
- {
69
- // https://bugs.chromium.org/p/chromium/issues/detail?id=766938
70
- scrollable: document.body,
71
- threshold: 150,
72
- onStateChange(/* state, opts */) {
73
- /* noop */
74
- }
75
- },
76
- opts
77
- )
78
-
79
- var { container, scrollable, threshold, refresh, onStateChange, animates } = opts
80
-
81
- if (!animates) {
82
- animates = document.createElement('ox-pulltorefresh-control')
83
- container.appendChild(animates)
84
- }
85
-
86
- let distance: number = -1,
87
- offset: number = -1,
88
- state: string // state: pulling, aborting, reached, refreshing, restoring
89
-
90
- function addClass(cls: string) {
91
- animates.classList.add('pull-to-refresh--' + cls)
92
- }
93
-
94
- function removeClass(cls: string) {
95
- animates.classList.remove('pull-to-refresh--' + cls)
96
- }
97
-
98
- function scrollTop() {
99
- if (!scrollable || [window, document, document.body, document.documentElement].includes(scrollable)) {
100
- return document.documentElement.scrollTop || document.body.scrollTop
101
- } else {
102
- return scrollable.scrollTop
103
- }
104
- }
105
-
106
- return ontouchpan({
107
- element: container,
108
- animates,
109
-
110
- onpanmove(e: any) {
111
- let d = e.deltaY
112
-
113
- if (scrollTop() > 0 || (d < 0 && !state) || state in { aborting: 1, refreshing: 1, restoring: 1 }) return
114
-
115
- if (e.cancelable) {
116
- e.preventDefault()
117
- }
118
-
119
- if (distance == -1) {
120
- offset = d
121
- state = 'pulling'
122
- addClass(state)
123
- onStateChange(state, opts)
124
- }
125
-
126
- d = d - offset
127
- if (d < 0) d = 0
128
- distance = d
129
-
130
- if ((d >= threshold && state !== 'reached') || (d < threshold && state !== 'pulling')) {
131
- removeClass(state)
132
- state = state === 'reached' ? 'pulling' : 'reached'
133
- addClass(state)
134
- onStateChange(state, opts)
135
- }
136
-
137
- animates.pulling(d, opts)
138
- },
139
-
140
- async onpanend() {
141
- if (state == '') return
142
-
143
- if (state === 'pulling') {
144
- removeClass(state)
145
- state = 'aborting'
146
- onStateChange(state)
147
- addClass(state)
148
-
149
- await animates.aborting(opts)
150
-
151
- removeClass(state)
152
- distance = -1
153
- state = ''
154
- offset = -1
155
- onStateChange(state)
156
- } else if (state === 'reached') {
157
- removeClass(state)
158
- state = 'refreshing'
159
- addClass(state)
160
- onStateChange(state, opts)
161
- animates.refreshing(opts)
162
-
163
- await refresh()
164
-
165
- removeClass(state)
166
- state = 'restoring'
167
- addClass(state)
168
- onStateChange(state)
169
-
170
- await animates.restoring(opts)
171
-
172
- removeClass(state)
173
- distance = -1
174
- state = ''
175
- offset = -1
176
- onStateChange(state)
177
- }
178
- }
179
- })
180
- }
@@ -1,60 +0,0 @@
1
- import { html, TemplateResult } from 'lit';
2
- import '../src/pull-to-refresh.js';
3
-
4
- export default {
5
- title: 'PullToRefresh',
6
- component: 'pull-to-refresh',
7
- argTypes: {
8
- title: { control: 'text' },
9
- counter: { control: 'number' },
10
- textColor: { control: 'color' },
11
- }
12
- };
13
-
14
- interface Story<T> {
15
- (args: T): TemplateResult;
16
- args?: Partial<T>;
17
- argTypes?: Record<string, unknown>;
18
- }
19
-
20
- interface ArgTypes {
21
- title?: string;
22
- counter?: number;
23
- textColor?: string;
24
- slot?: TemplateResult;
25
- }
26
-
27
- const Template: Story<ArgTypes> = ({
28
- title = 'Hello world',
29
- counter = 5,
30
- textColor,
31
- slot,
32
- }: ArgTypes) => html`
33
- <pull-to-refresh
34
- style="--pull-to-refresh-text-color: ${textColor || 'black'}"
35
- .title=${title}
36
- .counter=${counter}
37
- >
38
- ${slot}
39
- </pull-to-refresh>
40
- `;
41
-
42
- export const Regular = Template.bind({});
43
-
44
- export const CustomTitle = Template.bind({});
45
- CustomTitle.args = {
46
- title: 'My title',
47
- };
48
-
49
- export const CustomCounter = Template.bind({});
50
- CustomCounter.args = {
51
- counter: 123456,
52
- };
53
-
54
- export const SlottedContent = Template.bind({});
55
- SlottedContent.args = {
56
- slot: html`<p>Slotted content</p>`,
57
- };
58
- SlottedContent.argTypes = {
59
- slot: { table: { disable: true } },
60
- };
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "useDefineForClassFields": false,
13
- "importHelpers": true,
14
- "outDir": "dist",
15
- "sourceMap": true,
16
- "inlineSources": true,
17
- "rootDir": "./",
18
- "declaration": true,
19
- "incremental": true,
20
- "skipLibCheck": true,
21
- "types": ["node", "mocha"]
22
- },
23
- "include": ["**/*.ts", "*.d.ts"]
24
- }
@@ -1,27 +0,0 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- open: '/demo/',
8
- /** Use regular watch mode if HMR is not enabled. */
9
- watch: !hmr,
10
- /** Resolve bare module imports */
11
- nodeResolve: {
12
- exportConditions: ['browser', 'development'],
13
- },
14
-
15
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
- // esbuildTarget: 'auto'
17
-
18
- /** Set appIndex to enable SPA routing */
19
- // appIndex: 'demo/index.html',
20
-
21
- plugins: [
22
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
23
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
24
- ],
25
-
26
- // See documentation for all available options
27
- });
@@ -1,41 +0,0 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
- files: 'dist/test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
23
-
24
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
- // esbuildTarget: 'auto',
26
-
27
- /** Amount of browsers to run concurrently */
28
- // concurrentBrowsers: 2,
29
-
30
- /** Amount of test files per browser to test concurrently */
31
- // concurrency: 1,
32
-
33
- /** Browsers to run tests on */
34
- // browsers: [
35
- // playwrightLauncher({ product: 'chromium' }),
36
- // playwrightLauncher({ product: 'firefox' }),
37
- // playwrightLauncher({ product: 'webkit' }),
38
- // ],
39
-
40
- // See documentation for all available options
41
- });