itmar-block-packages 1.2.2 → 1.3.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.
package/README.md CHANGED
@@ -7,6 +7,20 @@ import {関数名又はコンポーネント名} from "itmar-block-packages"
7
7
  ```
8
8
  名前付きインポートでお願いします。
9
9
 
10
+ ## 必要条件
11
+
12
+ このパッケージは`@wordpress/scripts`によるWebPackのトランスパイル環境でトランスパイルされています。そして、このパッケージを使用するには、`@wordpress/scripts`のバージョン^27.6.0以上が必要です。以下のコマンドを実行して、`@wordpress/scripts`を更新してください:
13
+
14
+ npm i @wordpress/scripts@^27.6.0 --save-dev
15
+
16
+ ## 更新履歴
17
+ = 1.3.0 =
18
+ - WordPressのデータをRest APIを通して取得する関数等に、次の関数とReactコンポーネントを追加した
19
+ - restTaxonomies
20
+ - TermChoiceControl
21
+ - edit.scssおよびstyle.scssを配置し、これをトランスパイルして、複数のプラグインから共通のスタイルとして使用できるようにした
22
+
23
+
10
24
  # 各コンポーネント・関数の機能
11
25
  ## カスタムフック
12
26
  ### useIsIframeMobile
@@ -343,27 +357,114 @@ WordPressのブロックエディタのサイドバーにTypographyを設定す
343
357
 
344
358
  ## WordPressのデータをRest APIを通して取得する関数等
345
359
  ### fetchPagesOptions
346
- 固定ページのid,title,linkを返します。
360
+ 固定ページの情報を取得して配列で返します。
361
+ #### 引数
362
+ - `homeUrl` string
363
+ サイトのホームURL
364
+
365
+ #### 戻り値
366
+ 次のようなキーを持つオブジェクトの配列を返します。
367
+ `value` 固定ページのid。ただし、サイトのホームについては-1をかえす。
368
+ `slug` 固定ページのスラッグ
369
+ `link` 固定ページのURL
370
+ `label` 固定ページの名称
371
+
347
372
  ### fetchArchiveOptions
348
- 投稿タイプのアーカイブのurlを返します。
373
+ カスタム投稿タイプ(ビルトインを含む)の情報を取得して配列で返します。
374
+ #### 引数
375
+ - `homeUrl` string
376
+ サイトのホームURL
377
+
378
+ #### 戻り値
379
+ 次のようなキーを持つオブジェクトの配列を返します。
380
+ `value` 0から始まる通し番号
381
+ `slug` ポストタイプのスラッグ
382
+ `link` アーカイブページのURL
383
+ `label` ポストタイプの名称
384
+
385
+ ### restTaxonomies
386
+ 投稿タイプに登録されているタクソノミー(カテゴリ、タグを含む)の情報およびそのタームの情報をを取得して配列で返します。
387
+ #### 引数
388
+ - `post_type` string
389
+ 投稿タイプのスラッグ
390
+
391
+ #### 戻り値
392
+ 次のようなキーを持つオブジェクトの配列を返します。
393
+ `slug` タクソノミーのスラッグ
394
+ `name` タクソノミーの名称
395
+ `rest_base` タクソノミーのREST_APIの名称
396
+ `terms` ターム情報オブジェクトの配列
397
+
349
398
  ### PageSelectControl
350
- 固定ページのタイトルを表示し、そのリンクを返すセレクトコントロールを表示させます。
399
+ 固定ページを選択できるコンボボックス表示し、固定ページの情報を返します。
400
+ #### プロプス
401
+ - `selectedSlug` string
402
+ 選択済みの固定ページのスラッグ
403
+ - `label` string
404
+ コンボボックスのラベル
405
+ - `homeUrl` string
406
+ サイトのホームURL
407
+ - `onChange` func
408
+ コンボボックスの内容が変化したとき発生するコールバック関数。引数には`fetchPagesOptions`の戻り値が入る。
409
+
351
410
  ```
352
411
  <PageSelectControl
353
- attributes={attributes}
354
- setAttributes={setAttributes}
355
- label={__("Select a fixed page to link to", "text-domain")}
356
- homeUrl={block_collections.home_url}
412
+ selectedSlug={selectedSlug}
413
+ label={__("Select Post Type", "post-blocks")}
414
+ homeUrl={post_blocks.home_url}
415
+ onChange={(postInfo) => {
416
+ setAttributes({ selectedSlug: postInfo.slug });
417
+ }}
357
418
  />
358
419
  ```
420
+
359
421
  ### ArchiveSelectControl
360
- 投稿タイプ名を表示し、そのアーカイブのURLを返すセレクトコントロールを表示させます。
422
+ 投稿タイプ名を選択できるコンボボックス表示し、投稿タイプの情報を返します。
423
+ #### プロプス
424
+ - `selectedSlug` string
425
+ 選択済みの投稿タイプのスラッグ
426
+ - `label` string
427
+ コンボボックスのラベル
428
+ - `homeUrl` string
429
+ サイトのホームURL
430
+ - `onChange` func
431
+ コンボボックスの内容が変化したとき発生するコールバック関数。引数には`fetchArchiveOptions`の戻り値が入る。
432
+
361
433
  ```
362
434
  <ArchiveSelectControl
363
- attributes={attributes}
364
- setAttributes={setAttributes}
365
- label={__("Select archive page to link to", "text-domain")}
366
- homeUrl={block_collections.home_url}
435
+ selectedSlug={selectedSlug}
436
+ label={__("Select Post Type", "post-blocks")}
437
+ homeUrl={post_blocks.home_url}
438
+ onChange={(postInfo) => {
439
+ setAttributes({ selectedSlug: postInfo.slug });
440
+ }}
441
+ />
442
+ ```
443
+
444
+ ### TermChoiceControl
445
+ 投稿タイプに紐づけられている全てのタクソノミー(カテゴリ、タグを含む。)に登録されたタームを選択できるチェックボックス表示し、コールバック関数に選択されたタームの情報を返します。
446
+ #### プロプス
447
+ - `selectedSlug` string
448
+ 選択済みの投稿タイプのスラッグ
449
+ - `choiceTerms` array
450
+ 選択済みのタームの情報。配列の要素は次の形式のオブジェクトであること。
451
+ { taxonomy: タクソノミーのスラッグ, term: タームのスラッグ }
452
+ - `type` string
453
+ 選択するデータのタイプ。将来の拡張のためにセットしている。現時点では"taxonomy"とセットすること。
454
+ - `label` string
455
+
456
+ - `onChange` func
457
+ チェックボックスの内容が変化したとき発生するコールバック関数。引数には{ taxonomy: タクソノミーのスラッグ, term: タームのスラッグ }という形式のオブジェクトを要素とする配列が入る。
458
+
459
+ ```
460
+ <TermChoiceControl
461
+ selectedSlug={selectedSlug}
462
+ choiceTerms={choiceTerms}
463
+ type="taxonomy"
464
+ label={__("Choice Taxsonomy", "post-blocks")}
465
+ onChange={(newChoiceTerms) =>
466
+ setAttributes({ choiceTerms: newChoiceTerms })
467
+ }
367
468
  />
368
469
  ```
369
470
 
@@ -486,4 +587,4 @@ Hslオブジェクトのlightnessの値
486
587
  16進数のRGB表記を受け取り、それを10進数のRGBオブジェクトに変換するためのユーティリティ関数です。
487
588
  #### 引数
488
589
  - `strRgb16` string
489
- #000000形式の16進数の文字列又はrgb(0,0,0) 形式の文字列
590
+ #000000形式の16進数の文字列又はrgb(0,0,0) 形式の文字列
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '2d2b7a2ad307b5f2f288');
1
+ <?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '8e2fa17e0d428f714701');
@@ -0,0 +1 @@
1
+ .block-editor-block-inspector .tax_section{margin:10px 0 20px}.block-editor-block-inspector .term_section{margin-top:20px}.block-editor-block-inspector .term_section:nth-child(2){margin-top:10px}.block-editor-block-inspector .tax_label{border-bottom:1px solid #000;border-top:1px solid #000;padding:2px 0}.block-editor-block-inspector .term_check{margin-bottom:5px}