umaki 0.2.5 → 0.2.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 (96) hide show
  1. package/README.md +193 -79
  2. package/dist/_virtual/_commonjsHelpers.cjs.js +1 -1
  3. package/dist/_virtual/_commonjsHelpers.es.js +1 -1
  4. package/dist/_virtual/isBetween.cjs.js +1 -1
  5. package/dist/_virtual/isBetween.es.js +1 -1
  6. package/dist/index.cjs.js +1 -1
  7. package/dist/index.es.js +1 -1
  8. package/dist/libs/control/bgScrollStop.cjs.js +1 -1
  9. package/dist/libs/control/bgScrollStop.es.js +1 -1
  10. package/dist/libs/control/pd.cjs.js +1 -1
  11. package/dist/libs/control/pd.es.js +1 -1
  12. package/dist/libs/control/scrollToHash.cjs.js +1 -1
  13. package/dist/libs/control/scrollToHash.es.js +1 -1
  14. package/dist/libs/control/videoPlayControl.cjs.js +1 -1
  15. package/dist/libs/control/videoPlayControl.es.js +1 -1
  16. package/dist/libs/convert/changeDateStringToSpecificFormat.cjs.js +1 -1
  17. package/dist/libs/convert/changeDateStringToSpecificFormat.es.js +1 -1
  18. package/dist/libs/convert/jsonStringToJsonObject.cjs.js +1 -1
  19. package/dist/libs/convert/jsonStringToJsonObject.es.js +1 -1
  20. package/dist/libs/get/getAspectRatio.cjs.js +1 -1
  21. package/dist/libs/get/getAspectRatio.es.js +1 -1
  22. package/dist/libs/get/getClassNames.cjs.js +1 -1
  23. package/dist/libs/get/getClassNames.es.js +1 -1
  24. package/dist/libs/get/getDocumentHeight.cjs.js +1 -1
  25. package/dist/libs/get/getDocumentHeight.es.js +1 -1
  26. package/dist/libs/get/getEventPaths.cjs.js +1 -1
  27. package/dist/libs/get/getEventPaths.es.js +1 -1
  28. package/dist/libs/get/getGcd.cjs.js +1 -1
  29. package/dist/libs/get/getGcd.es.js +1 -1
  30. package/dist/libs/get/getOrientation.cjs.js +1 -1
  31. package/dist/libs/get/getOrientation.es.js +1 -1
  32. package/dist/libs/get/getParentList.cjs.js +1 -1
  33. package/dist/libs/get/getParentList.es.js +1 -1
  34. package/dist/libs/get/getQueryParams.cjs.js +1 -1
  35. package/dist/libs/get/getQueryParams.es.js +1 -1
  36. package/dist/libs/get/getRem.cjs.js +1 -1
  37. package/dist/libs/get/getRem.es.js +1 -1
  38. package/dist/libs/get/getScrollbarWidth.cjs.js +1 -1
  39. package/dist/libs/get/getScrollbarWidth.es.js +1 -1
  40. package/dist/libs/get/getSessionStorage.cjs.js +1 -1
  41. package/dist/libs/get/getSessionStorage.es.js +1 -1
  42. package/dist/libs/get/getStringLength.cjs.js +1 -1
  43. package/dist/libs/get/getStringLength.es.js +1 -1
  44. package/dist/libs/get/getStylePropertyValue.cjs.js +1 -1
  45. package/dist/libs/get/getStylePropertyValue.es.js +1 -1
  46. package/dist/libs/get/getStylePropertyValueToNumber.cjs.js +1 -1
  47. package/dist/libs/get/getStylePropertyValueToNumber.es.js +1 -1
  48. package/dist/libs/get/getUaData.cjs.js +1 -1
  49. package/dist/libs/get/getUaData.es.js +1 -1
  50. package/dist/libs/is/isBetweenDateTime.cjs.js +1 -1
  51. package/dist/libs/is/isBetweenDateTime.es.js +1 -1
  52. package/dist/libs/is/isExistAllElements.cjs.js +1 -1
  53. package/dist/libs/is/isExistAllElements.es.js +1 -1
  54. package/dist/libs/is/isIpad.cjs.js +1 -1
  55. package/dist/libs/is/isIpad.es.js +1 -1
  56. package/dist/libs/is/isKeyExists.cjs.js +1 -1
  57. package/dist/libs/is/isKeyExists.es.js +1 -1
  58. package/dist/libs/is/isSafari.cjs.js +1 -1
  59. package/dist/libs/is/isSafari.es.js +1 -1
  60. package/dist/libs/is/isScrollable.cjs.js +1 -1
  61. package/dist/libs/is/isScrollable.es.js +1 -1
  62. package/dist/libs/is/isTouchSupport.cjs.js +1 -1
  63. package/dist/libs/is/isTouchSupport.es.js +1 -1
  64. package/dist/libs/remove/removeAllHtmlTags.cjs.js +1 -1
  65. package/dist/libs/remove/removeAllHtmlTags.es.js +1 -1
  66. package/dist/libs/remove/removeAttribute.cjs.js +1 -1
  67. package/dist/libs/remove/removeAttribute.es.js +1 -1
  68. package/dist/libs/remove/removeSessionStorage.cjs.js +1 -1
  69. package/dist/libs/remove/removeSessionStorage.es.js +1 -1
  70. package/dist/libs/remove/removeStylePropertyValue.cjs.js +1 -1
  71. package/dist/libs/remove/removeStylePropertyValue.es.js +1 -1
  72. package/dist/libs/set/set100vh.cjs.js +1 -1
  73. package/dist/libs/set/set100vh.es.js +1 -1
  74. package/dist/libs/set/set100vw.cjs.js +1 -1
  75. package/dist/libs/set/set100vw.es.js +1 -1
  76. package/dist/libs/set/setAttribute.cjs.js +1 -1
  77. package/dist/libs/set/setAttribute.es.js +1 -1
  78. package/dist/libs/set/setScrollPositionToCenter.cjs.js +1 -1
  79. package/dist/libs/set/setScrollPositionToCenter.es.js +1 -1
  80. package/dist/libs/set/setSessionStorage.cjs.js +1 -1
  81. package/dist/libs/set/setSessionStorage.es.js +1 -1
  82. package/dist/libs/set/setStylePropertyValue.cjs.js +1 -1
  83. package/dist/libs/set/setStylePropertyValue.es.js +1 -1
  84. package/dist/libs/to/toBoolean.cjs.js +1 -1
  85. package/dist/libs/to/toBoolean.es.js +1 -1
  86. package/dist/libs/to/toPositiveNumber.cjs.js +1 -1
  87. package/dist/libs/to/toPositiveNumber.es.js +1 -1
  88. package/dist/libs/transform/wrapTextWithSpans.cjs.js +1 -1
  89. package/dist/libs/transform/wrapTextWithSpans.es.js +1 -1
  90. package/dist/libs/wait/sleep.cjs.js +1 -1
  91. package/dist/libs/wait/sleep.es.js +1 -1
  92. package/dist/libs/wait/waitForAllMediaLoaded.cjs.js +1 -1
  93. package/dist/libs/wait/waitForAllMediaLoaded.es.js +1 -1
  94. package/dist/node_modules/dayjs/plugin/isBetween.cjs.js +1 -1
  95. package/dist/node_modules/dayjs/plugin/isBetween.es.js +1 -1
  96. package/package.json +1 -1
package/README.md CHANGED
@@ -1,18 +1,22 @@
1
1
  # umaki
2
2
 
3
+ <p>
4
+ <img alt="NPM Version" src="https://img.shields.io/npm/v/umaki">
5
+ <img alt="NPM Type Definitions" src="https://img.shields.io/npm/types/umaki">
6
+ <img alt="NPM Downloads" src="https://img.shields.io/npm/dy/umaki">
7
+ </p>
8
+
3
9
  ![character](docs/character.jpg)
4
10
 
5
- Web制作で多用するユーティリティーをこれ1つでインポート出来るようにしたパッケージです。
6
- 基本的には私がよく使っているものを中心に追加していきます。
7
- パッケージの中身や種類のリクエストがあれば、Issueを立ててください。
11
+ A package that allows you to import frequently used utilities for web development in one place. Primarily, it includes utilities that I often use. If you have any requests for the contents or types of utilities, please open an issue.
8
12
 
9
- ## 使い方
13
+ ## Usage
10
14
 
11
15
  ``` ts
12
16
  import { foo } from 'umaki'
13
17
  ```
14
18
 
15
- ## ユーティリティー一覧
19
+ ## List of Utilities
16
20
 
17
21
  - [Control](#control)
18
22
  - [bgScrollStop](#bgscrollstop)
@@ -71,17 +75,20 @@ import { foo } from 'umaki'
71
75
 
72
76
  ### bgScrollStop
73
77
 
74
- スクロールを止める関数です。
78
+ A function that stops scrolling.
75
79
 
76
80
  ``` ts
77
81
  import { bgScrollStop } from 'umaki'
78
82
 
79
- bgScrollStop()
83
+ bgScrollStop() // scroll stop
84
+ bgScrollStop(false) // scroll start
80
85
  ```
81
86
 
87
+ [View file →](src/libs/control/bgScrollStop.ts)
88
+
82
89
  ### pd
83
90
 
84
- デフォルトのイベント動作を防ぐ関数です。
91
+ A function that prevents the default event behavior.
85
92
 
86
93
  ``` ts
87
94
  import { pd } from 'umaki'
@@ -89,36 +96,48 @@ import { pd } from 'umaki'
89
96
  document.getElementById('myElement').addEventListener('click', pd)
90
97
  ```
91
98
 
92
- ### scrollToHash
99
+ [View file →](src/libs/control/pd.ts)
93
100
 
94
- 特定のハッシュ位置にスクロールする関数です。
101
+ ### scrollToHash (Promise)
102
+
103
+ A function that scrolls to a specific hash position.
95
104
 
96
105
  ``` ts
97
106
  import { scrollToHash } from 'umaki'
98
107
 
99
- ;(async(() => {
108
+ ;(async () => {
100
109
  await scrollToHash('#target')
101
- console.log('スクロール完了')
102
- }))()
110
+ console.log('Scrolled!')
111
+
112
+ // smooth scroll
113
+ await scrollToHash('#target', true)
114
+
115
+ // smooth scroll + offset
116
+ await scrollToHash('#target', true, 100)
117
+ })()
103
118
  ```
104
119
 
120
+ [View file →](src/libs/control/scrollToHash.ts)
121
+
105
122
  ### videoPlayControl
106
123
 
107
- ビデオ要素の再生を制御する関数です。
124
+ A function that controls the playback of a video element.
108
125
 
109
126
  ``` ts
110
127
  import { videoPlayControl } from 'umaki'
111
128
 
112
129
  const videoElement = document.getElementById('myVideo')
113
- videoPlayControl(videoElement, true) // 再生
114
- videoPlayControl(videoElement, false) // 一時停止
130
+ videoPlayControl(videoElement, true) // play
131
+ videoPlayControl(videoElement, false) // pause
115
132
  ```
116
133
 
134
+ [View file →](src/libs/control/videoPlayControl.ts)
135
+
117
136
  ## Convert
118
137
 
119
138
  ### changeDateStringToSpecificFormat
120
139
 
121
- 日付文字列を特定のフォーマットに変換する関数です。
140
+ A function that converts a date string to a specific format.
122
141
 
123
142
  ```ts
124
143
  import { changeDateStringToSpecificFormat } from 'umaki'
@@ -128,9 +147,11 @@ const formattedDate = changeDateStringToSpecificFormat(date, 'MM/DD/YYYY')
128
147
  console.log(formattedDate) // '10/05/2023'
129
148
  ```
130
149
 
150
+ [View file →](src/libs/convert/changeDateStringToSpecificFormat.ts)
151
+
131
152
  ### jsonStringToJsonObject
132
153
 
133
- JSON文字列をJSONオブジェクトに変換する関数です。
154
+ A function that converts a JSON string to a JSON object.
134
155
 
135
156
  ```ts
136
157
  import { jsonStringToJsonObject } from 'umaki'
@@ -140,11 +161,13 @@ const jsonObject = jsonStringToJsonObject(jsonString)
140
161
  console.log(jsonObject) // { name: 'John', age: 30 }
141
162
  ```
142
163
 
164
+ [View file →](src/libs/convert/jsonStringToJsonObject.ts)
165
+
143
166
  ## Get
144
167
 
145
168
  ### getAspectRatio
146
169
 
147
- 指定された幅と高さのアスペクト比を返す関数です。
170
+ A function that returns the aspect ratio of the specified width and height.
148
171
 
149
172
  ```ts
150
173
  import { getAspectRatio } from 'umaki'
@@ -153,9 +176,11 @@ const aspectRatio = getAspectRatio(1920, 1080)
153
176
  console.log(aspectRatio) // { w: 16, h: 9 }
154
177
  ```
155
178
 
179
+ [View file →](src/libs/get/getAspectRatio.ts)
180
+
156
181
  ### getClassNames
157
182
 
158
- 指定されたHTML要素のクラス名を配列として取得する関数です。
183
+ A function that retrieves the class names of the specified HTML element as an array.
159
184
 
160
185
  ```ts
161
186
  import { getClassNames } from 'umaki'
@@ -166,33 +191,39 @@ const classNames = getClassNames(element)
166
191
  console.log(classNames) // ['class1', 'class2', 'class3']
167
192
  ```
168
193
 
194
+ [View file →](src/libs/get/getClassNames.ts)
195
+
169
196
  ### getDocumentHeight
170
197
 
171
- ドキュメントの高さを取得する関数です。
198
+ A function that retrieves the height of the document.
172
199
 
173
200
  ```ts
174
201
  import { getDocumentHeight } from 'umaki'
175
202
 
176
203
  const height = getDocumentHeight()
177
- console.log(height) // ドキュメントの高さを表示
204
+ console.log(height)
178
205
  ```
179
206
 
207
+ [View file →](src/libs/get/getDocumentHeight.ts)
208
+
180
209
  ### getEventPaths
181
210
 
182
- イベントのパスを取得する関数です。
211
+ A function that retrieves the event paths.
183
212
 
184
213
  ```ts
185
214
  import { getEventPaths } from 'umaki'
186
215
 
187
216
  document.addEventListener('click', (event) => {
188
217
  const paths = getEventPaths(event)
189
- console.log(paths) // イベントパスを表示
218
+ console.log(paths)
190
219
  })
191
220
  ```
192
221
 
222
+ [View file →](src/libs/get/getEventPaths.ts)
223
+
193
224
  ### getGcd
194
225
 
195
- 2つの数値の最大公約数を計算する関数です。
226
+ A function that calculates the greatest common divisor of two numbers.
196
227
 
197
228
  ```ts
198
229
  import { getGcd } from 'umaki'
@@ -201,43 +232,56 @@ const gcd = getGcd(48, 18)
201
232
  console.log(gcd) // 6
202
233
  ```
203
234
 
235
+ [View file →](src/libs/get/getGcd.ts)
236
+
204
237
  ### getOrientation
205
238
 
206
- デバイスの現在の向きを取得する関数です。
239
+ A function that retrieves the current orientation of the device.
207
240
 
208
241
  ```ts
209
242
  import { getOrientation } from 'umaki'
210
243
 
211
244
  const orientation = getOrientation()
212
- console.log(orientation) // 'landscape' または 'portrait'
245
+ console.log(orientation) // 'landscape' or 'portrait'
213
246
  ```
214
247
 
248
+ [View file →](src/libs/get/getOrientation.ts)
249
+
215
250
  ### getParentList
216
251
 
217
- 指定されたHTML要素の親要素を再帰的に取得する関数です。
252
+ A function that recursively retrieves the parent elements of the specified HTML element.
218
253
 
219
254
  ```ts
220
255
  import { getParentList } from 'umaki'
221
256
 
222
257
  const element = document.createElement('div')
223
258
  const parentList = getParentList(element)
224
- console.log(parentList) // 親要素のリストを表示
259
+ console.log(parentList)
225
260
  ```
226
261
 
262
+ [View file →](src/libs/get/getParentList.ts)
263
+
227
264
  ### getQueryParams
228
265
 
229
- URLのクエリパラメータを取得する関数です。
266
+ A function that retrieves the query parameters from the URL.
267
+ This is a wrapper around query-string, so you can specify [options](https://github.com/sindresorhus/query-string) in the second argument.
230
268
 
231
269
  ```ts
232
270
  import { getQueryParams } from 'umaki'
233
271
 
234
- const params = getQueryParams('test')
235
- console.log(params) // クエリパラメータの値を表示
272
+ const params = getQueryParams('test') // https://example.com?test=123
273
+ console.log(params) // 123
274
+
275
+ // Example of specifying options
276
+ const params = getQueryParams('test', { parseNumbers: false })
277
+ console.log(params) // '123'
236
278
  ```
237
279
 
280
+ [View file →](src/libs/get/getQueryParams.ts)
281
+
238
282
  ### getRem
239
283
 
240
- ピクセル値をrem単位に変換する関数です。
284
+ A function that converts a pixel value to rem units.
241
285
 
242
286
  ```ts
243
287
  import { getRem } from 'umaki'
@@ -246,31 +290,37 @@ const remValue = getRem(16)
246
290
  console.log(remValue) // '1rem'
247
291
  ```
248
292
 
293
+ [View file →](src/libs/get/getRem.ts)
294
+
249
295
  ### getScrollbarWidth
250
296
 
251
- スクロールバーの幅を取得する関数です。
297
+ A function that retrieves the width of the scrollbar.
252
298
 
253
299
  ```ts
254
300
  import { getScrollbarWidth } from 'umaki'
255
301
 
256
302
  const scrollbarWidth = getScrollbarWidth()
257
- console.log(scrollbarWidth) // スクロールバーの幅を表示
303
+ console.log(scrollbarWidth) // 15
258
304
  ```
259
305
 
306
+ [View file →](src/libs/get/getScrollbarWidth.ts)
307
+
260
308
  ### getSessionStorage
261
309
 
262
- セッションストレージから値を取得する関数です。
310
+ A function that retrieves a value from session storage.
263
311
 
264
312
  ```ts
265
313
  import { getSessionStorage } from 'umaki'
266
314
 
267
315
  const value = getSessionStorage('testKey')
268
- console.log(value) // セッションストレージの値を表示
316
+ console.log(value) // 'testValue'
269
317
  ```
270
318
 
319
+ [View file →](src/libs/get/getSessionStorage.ts)
320
+
271
321
  ### getStringLength
272
322
 
273
- 文字列の長さを取得する関数です(Unicode文字を考慮)。
323
+ A function that retrieves the length of a string (considering Unicode characters).
274
324
 
275
325
  ```ts
276
326
  import { getStringLength } from 'umaki'
@@ -279,44 +329,60 @@ const length = getStringLength('こんにちは')
279
329
  console.log(length) // 5
280
330
  ```
281
331
 
332
+ [View file →](src/libs/get/getStringLength.ts)
333
+
282
334
  ### getStylePropertyValue
283
335
 
284
- 指定されたCSSカスタムプロパティの値を取得する関数です。
336
+ A function that retrieves the value of the specified CSS custom property.
285
337
 
286
338
  ```ts
287
339
  import { getStylePropertyValue } from 'umaki'
288
340
 
289
341
  const value = getStylePropertyValue('--custom-property')
290
- console.log(value) // カスタムプロパティの値を表示
342
+ console.log(value)
291
343
  ```
292
344
 
345
+ [View file →](src/libs/get/getStylePropertyValue.ts)
346
+
293
347
  ### getStylePropertyValueToNumber
294
348
 
295
- 指定されたCSSカスタムプロパティの値を数値として取得する関数です。
349
+ A function that retrieves the value of the specified CSS custom property as a number.
296
350
 
297
351
  ```ts
298
352
  import { getStylePropertyValueToNumber } from 'umaki'
299
353
 
300
354
  const value = getStylePropertyValueToNumber('--custom-property')
301
- console.log(value) // カスタムプロパティの数値を表示
355
+ console.log(value)
302
356
  ```
303
357
 
358
+ [View file →](src/libs/get/getStylePropertyValueToNumber.ts)
359
+
304
360
  ### getUaData
305
361
 
306
- ユーザーエージェント情報を取得する関数です。
362
+ A function that retrieves user agent information.
307
363
 
308
364
  ```ts
309
365
  import { getUaData } from 'umaki'
310
366
 
311
367
  const uaData = getUaData()
312
- console.log(uaData) // ユーザーエージェント情報を表示
368
+ console.log(uaData)
369
+ // {
370
+ // browserName: 'chrome',
371
+ // browserVersion: '91.0.4472.124',
372
+ // browserEngine: 'blink',
373
+ // osName: 'windows',
374
+ // type: 'desktop',
375
+ // touchSupport: false
376
+ // }
313
377
  ```
314
378
 
379
+ [View file →](src/libs/get/getUaData.ts)
380
+
315
381
  ## Is
316
382
 
317
383
  ### isBetweenDateTime
318
384
 
319
- 現在の日付が指定された2つの日付の間にあるかどうかをチェックする関数です。
385
+ A function that checks if the current date is between two specified dates.
320
386
 
321
387
  ```ts
322
388
  import { isBetweenDateTime } from 'umaki'
@@ -324,58 +390,68 @@ import { isBetweenDateTime } from 'umaki'
324
390
  const dateA = '2023-10-01'
325
391
  const dateB = '2023-10-10'
326
392
  const result = isBetweenDateTime(dateA, dateB)
327
- console.log(result) // true または false
393
+ console.log(result) // true or false
328
394
  ```
329
395
 
396
+ [View file →](src/libs/is/isBetweenDateTime.ts)
397
+
330
398
  ### isExistAllElements
331
399
 
332
- すべての要素が存在するかどうかをチェックする関数です。
400
+ A function that checks if all elements exist.
333
401
 
334
402
  ```ts
335
403
  import { isExistAllElements } from 'umaki'
336
404
 
337
405
  const elements = [document.createElement('div'), document.createElement('span')]
338
406
  const result = isExistAllElements(elements)
339
- console.log(result) // true または false
407
+ console.log(result) // true or false
340
408
  ```
341
409
 
410
+ [View file →](src/libs/is/isExistAllElements.ts)
411
+
342
412
  ### isIpad
343
413
 
344
- デバイスがiPadかどうかをチェックする関数です。
414
+ A function that checks if the device is an iPad.
345
415
 
346
416
  ```ts
347
417
  import { isIpad } from 'umaki'
348
418
 
349
419
  const result = isIpad()
350
- console.log(result) // true または false
420
+ console.log(result) // true or false
351
421
  ```
352
422
 
423
+ [View file →](src/libs/is/isIpad.ts)
424
+
353
425
  ### isKeyExists
354
426
 
355
- オブジェクトに特定のキーが存在するかどうかをチェックする関数です。
427
+ A function that checks if a specific key exists in an object.
356
428
 
357
429
  ```ts
358
430
  import { isKeyExists } from 'umaki'
359
431
 
360
432
  const obj = { a: 1, b: 2 }
361
433
  const result = isKeyExists(obj, 'a')
362
- console.log(result) // true または false
434
+ console.log(result) // true or false
363
435
  ```
364
436
 
437
+ [View file →](src/libs/is/isKeyExists.ts)
438
+
365
439
  ### isSafari
366
440
 
367
- ブラウザがSafariかどうかをチェックする関数です。
441
+ A function that checks if the browser is Safari.
368
442
 
369
443
  ```ts
370
444
  import { isSafari } from 'umaki'
371
445
 
372
446
  const result = isSafari()
373
- console.log(result) // true または false
447
+ console.log(result) // true or false
374
448
  ```
375
449
 
450
+ [View file →](src/libs/is/isSafari.ts)
451
+
376
452
  ### isScrollable
377
453
 
378
- 要素がスクロール可能かどうかをチェックする関数です。
454
+ A function that checks if an element is scrollable.
379
455
 
380
456
  ```ts
381
457
  import { isScrollable } from 'umaki'
@@ -384,25 +460,29 @@ const element = document.createElement('div')
384
460
  element.style.overflow = 'auto'
385
461
  element.innerHTML = '<div style="height: 200px;"></div>'
386
462
  const result = isScrollable(element)
387
- console.log(result) // true または false
463
+ console.log(result) // true or false
388
464
  ```
389
465
 
466
+ [View file →](src/libs/is/isScrollable.ts)
467
+
390
468
  ### isTouchSupport
391
469
 
392
- デバイスがタッチサポートを持っているかどうかをチェックする関数です。
470
+ A function that checks if the device supports touch.
393
471
 
394
472
  ```ts
395
473
  import { isTouchSupport } from 'umaki'
396
474
 
397
475
  const result = isTouchSupport()
398
- console.log(result) // true または false
476
+ console.log(result) // true or false
399
477
  ```
400
478
 
479
+ [View file →](src/libs/is/isTouchSupport.ts)
480
+
401
481
  ## Remove
402
482
 
403
483
  ### removeAllHtmlTags
404
484
 
405
- 文字列からすべてのHTMLタグを削除する関数です。
485
+ A function that removes all HTML tags from a string.
406
486
 
407
487
  ```ts
408
488
  import { removeAllHtmlTags } from 'umaki'
@@ -412,9 +492,11 @@ const output = removeAllHtmlTags(input)
412
492
  console.log(output) // 'Hello World!'
413
493
  ```
414
494
 
495
+ [View file →](src/libs/remove/removeAllHtmlTags.ts)
496
+
415
497
  ### removeAttribute
416
498
 
417
- 指定されたHTML要素から属性を削除する関数です。
499
+ A function that removes an attribute from the specified HTML element.
418
500
 
419
501
  ```ts
420
502
  import { removeAttribute } from 'umaki'
@@ -425,9 +507,11 @@ removeAttribute(element, 'data-test')
425
507
  console.log(element.hasAttribute('data-test')) // false
426
508
  ```
427
509
 
510
+ [View file →](src/libs/remove/removeAttribute.ts)
511
+
428
512
  ### removeSessionStorage
429
513
 
430
- セッションストレージから指定されたキーのアイテムを削除する関数です。
514
+ A function that removes an item with the specified key from session storage.
431
515
 
432
516
  ```ts
433
517
  import { removeSessionStorage } from 'umaki'
@@ -437,9 +521,11 @@ removeSessionStorage(key)
437
521
  console.log(sessionStorage.getItem(key)) // null
438
522
  ```
439
523
 
524
+ [View file →](src/libs/remove/removeSessionStorage.ts)
525
+
440
526
  ### removeStylePropertyValue
441
527
 
442
- 指定されたCSSカスタムプロパティを削除する関数です。
528
+ A function that removes the specified CSS custom property.
443
529
 
444
530
  ```ts
445
531
  import { removeStylePropertyValue } from 'umaki'
@@ -449,11 +535,13 @@ removeStylePropertyValue(key)
449
535
  console.log(getComputedStyle(document.documentElement).getPropertyValue(key)) // ''
450
536
  ```
451
537
 
538
+ [View file →](src/libs/remove/removeStylePropertyValue.ts)
539
+
452
540
  ## Set
453
541
 
454
542
  ### set100vh
455
543
 
456
- モバイルデバイスでのビューポート単位の問題を解決するために、CSS変数を100vhに設定する関数です。
544
+ A function that sets a CSS variable to 100vh to address viewport unit issues on mobile devices.
457
545
 
458
546
  ```ts
459
547
  import { set100vh } from 'umaki'
@@ -461,9 +549,11 @@ import { set100vh } from 'umaki'
461
549
  set100vh()
462
550
  ```
463
551
 
552
+ [View file →](src/libs/set/set100vh.ts)
553
+
464
554
  ### set100vw
465
555
 
466
- スクロールバーの幅を除いた100vwの値をCSS変数に設定する関数です。
556
+ A function that sets a CSS variable to 100vw minus the scrollbar width.
467
557
 
468
558
  ```ts
469
559
  import { set100vw } from 'umaki'
@@ -471,9 +561,11 @@ import { set100vw } from 'umaki'
471
561
  set100vw()
472
562
  ```
473
563
 
564
+ [View file →](src/libs/set/set100vw.ts)
565
+
474
566
  ### setAttribute
475
567
 
476
- 指定されたHTML要素に属性を設定する関数です。
568
+ A function that sets an attribute on the specified HTML element.
477
569
 
478
570
  ```ts
479
571
  import { setAttribute } from 'umaki'
@@ -483,9 +575,11 @@ setAttribute(element, 'data-test', 'value')
483
575
  console.log(element.getAttribute('data-test')) // 'value'
484
576
  ```
485
577
 
578
+ [View file →](src/libs/set/setAttribute.ts)
579
+
486
580
  ### setScrollPositionToCenter
487
581
 
488
- ルート要素の水平スクロール位置を調整して、ターゲット要素を中央に配置する関数です。
582
+ A function that adjusts the horizontal scroll position of the root element to center the target element.
489
583
 
490
584
  ```ts
491
585
  import { setScrollPositionToCenter } from 'umaki'
@@ -495,9 +589,11 @@ const targetElement = document.getElementById('target')
495
589
  setScrollPositionToCenter(rootElement, targetElement)
496
590
  ```
497
591
 
592
+ [View file →](src/libs/set/setScrollPositionToCenter.ts)
593
+
498
594
  ### setSessionStorage
499
595
 
500
- セッションストレージに値を設定する関数です。
596
+ A function that sets a value in session storage.
501
597
 
502
598
  ```ts
503
599
  import { setSessionStorage } from 'umaki'
@@ -508,9 +604,11 @@ setSessionStorage(key, value)
508
604
  console.log(sessionStorage.getItem(key)) // 'testValue'
509
605
  ```
510
606
 
607
+ [View file →](src/libs/set/setSessionStorage.ts)
608
+
511
609
  ### setStylePropertyValue
512
610
 
513
- ルート要素にCSSカスタムプロパティを設定する関数です。
611
+ A function that sets a CSS custom property on the root element.
514
612
 
515
613
  ```ts
516
614
  import { setStylePropertyValue } from 'umaki'
@@ -521,11 +619,13 @@ setStylePropertyValue(key, value)
521
619
  console.log(getComputedStyle(document.documentElement).getPropertyValue(key)) // 'blue'
522
620
  ```
523
621
 
622
+ [View file →](src/libs/set/setStylePropertyValue.ts)
623
+
524
624
  ## To
525
625
 
526
626
  ### toBoolean
527
627
 
528
- 文字列をブール値に変換する関数です。
628
+ A function that converts a string to a boolean value.
529
629
 
530
630
  ```ts
531
631
  import { toBoolean } from 'umaki'
@@ -535,9 +635,11 @@ console.log(toBoolean('false')) // false
535
635
  console.log(toBoolean('random')) // false
536
636
  ```
537
637
 
638
+ [View file →](src/libs/to/toBoolean.ts)
639
+
538
640
  ### toPositiveNumber
539
641
 
540
- 数値を正の数に変換する関数です。負の数の場合は絶対値を返します。
642
+ A function that converts a number to a positive number. Returns the absolute value if the number is negative.
541
643
 
542
644
  ```ts
543
645
  import { toPositiveNumber } from 'umaki'
@@ -549,11 +651,13 @@ console.log(toPositiveNumber(-3.14)) // 3.14
549
651
  console.log(toPositiveNumber(3.14)) // 3.14
550
652
  ```
551
653
 
654
+ [View file →](src/libs/to/toPositiveNumber.ts)
655
+
552
656
  ## Transform
553
657
 
554
658
  ### wrapTextWithSpans
555
659
 
556
- HTML要素のテキストコンテンツの各文字を個別の<span>要素でラップする関数です。
660
+ A function that wraps each character of the text content of an HTML element with individual `<span>` elements.
557
661
 
558
662
  ```ts
559
663
  import { wrapTextWithSpans } from 'umaki'
@@ -564,42 +668,52 @@ wrapTextWithSpans(element)
564
668
  console.log(element.innerHTML) // '<span>h</span><span>e</span><span>l</span><span>l</span><span>o</span>'
565
669
  ```
566
670
 
671
+ [View file →](src/libs/transform/wrapTextWithSpans.ts)
672
+
567
673
  ## Wait
568
674
 
569
- ### sleep
675
+ ### sleep (Promise)
570
676
 
571
- 指定した時間だけ処理を一時停止する関数です。
677
+ A function that pauses execution for a specified amount of time.
572
678
 
573
679
  ```ts
574
680
  import { sleep } from 'umaki'
575
681
 
576
682
  ;(async () => {
577
683
  console.log('Start')
578
- await sleep(1) // 1秒間待機
684
+ await sleep(1) // 1ms wait
579
685
  console.log('End')
580
686
  })()
581
687
  ```
582
688
 
583
- ### waitForAllMediaLoaded
689
+ [View file →](src/libs/wait/sleep.ts)
584
690
 
585
- ドキュメント内のすべての画像とビデオが完全に読み込まれるのを待つ関数です。
691
+ ### waitForAllMediaLoaded (Promise)
692
+
693
+ A function that waits until all images and videos in the document are fully loaded.
586
694
 
587
695
  ```ts
588
696
  import { waitForAllMediaLoaded } from 'umaki'
589
697
 
590
698
  ;(async () => {
591
699
  const allMediaLoaded = await waitForAllMediaLoaded()
592
- console.log(allMediaLoaded) // true または false
700
+ console.log(allMediaLoaded) // true or false
701
+
702
+ // first view only
703
+ const firstViewMediaLoaded = await waitForAllMediaLoaded(true)
704
+ console.log(firstViewMediaLoaded) // true or false
593
705
  })()
594
706
  ```
595
707
 
708
+ [View file →](src/libs/wait/waitForAllMediaLoaded.ts)
709
+
596
710
  ## Using for framework and tools
597
711
 
598
- フレームワークまたは各種ツール特有の使い方を以下に記載します。
712
+ Specific usage for frameworks or various tools is described below.
599
713
 
600
714
  ### Astro or Vite
601
715
 
602
- AstroにてSSRする箇所で利用する場合は`vite.ssr.noExternal`に`umaki`を追加してください。
716
+ When using with Astro for SSR, add `umaki` to `vite.ssr.noExternal.`
603
717
 
604
718
  ``` ts
605
719
  // astro.config.ts