itmar-block-packages 1.2.3 → 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
@@ -13,6 +13,13 @@ import {関数名又はコンポーネント名} from "itmar-block-packages"
13
13
 
14
14
  npm i @wordpress/scripts@^27.6.0 --save-dev
15
15
 
16
+ ## 更新履歴
17
+ = 1.3.0 =
18
+ - WordPressのデータをRest APIを通して取得する関数等に、次の関数とReactコンポーネントを追加した
19
+ - restTaxonomies
20
+ - TermChoiceControl
21
+ - edit.scssおよびstyle.scssを配置し、これをトランスパイルして、複数のプラグインから共通のスタイルとして使用できるようにした
22
+
16
23
 
17
24
  # 各コンポーネント・関数の機能
18
25
  ## カスタムフック
@@ -350,27 +357,114 @@ WordPressのブロックエディタのサイドバーにTypographyを設定す
350
357
 
351
358
  ## WordPressのデータをRest APIを通して取得する関数等
352
359
  ### fetchPagesOptions
353
- 固定ページの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
+
354
372
  ### fetchArchiveOptions
355
- 投稿タイプのアーカイブの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
+
356
398
  ### PageSelectControl
357
- 固定ページのタイトルを表示し、そのリンクを返すセレクトコントロールを表示させます。
399
+ 固定ページを選択できるコンボボックス表示し、固定ページの情報を返します。
400
+ #### プロプス
401
+ - `selectedSlug` string
402
+ 選択済みの固定ページのスラッグ
403
+ - `label` string
404
+ コンボボックスのラベル
405
+ - `homeUrl` string
406
+ サイトのホームURL
407
+ - `onChange` func
408
+ コンボボックスの内容が変化したとき発生するコールバック関数。引数には`fetchPagesOptions`の戻り値が入る。
409
+
358
410
  ```
359
411
  <PageSelectControl
360
- attributes={attributes}
361
- setAttributes={setAttributes}
362
- label={__("Select a fixed page to link to", "text-domain")}
363
- 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
+ }}
364
418
  />
365
419
  ```
420
+
366
421
  ### ArchiveSelectControl
367
- 投稿タイプ名を表示し、そのアーカイブのURLを返すセレクトコントロールを表示させます。
422
+ 投稿タイプ名を選択できるコンボボックス表示し、投稿タイプの情報を返します。
423
+ #### プロプス
424
+ - `selectedSlug` string
425
+ 選択済みの投稿タイプのスラッグ
426
+ - `label` string
427
+ コンボボックスのラベル
428
+ - `homeUrl` string
429
+ サイトのホームURL
430
+ - `onChange` func
431
+ コンボボックスの内容が変化したとき発生するコールバック関数。引数には`fetchArchiveOptions`の戻り値が入る。
432
+
368
433
  ```
369
434
  <ArchiveSelectControl
370
- attributes={attributes}
371
- setAttributes={setAttributes}
372
- label={__("Select archive page to link to", "text-domain")}
373
- 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
+ }
374
468
  />
375
469
  ```
376
470
 
@@ -493,4 +587,4 @@ Hslオブジェクトのlightnessの値
493
587
  16進数のRGB表記を受け取り、それを10進数のRGBオブジェクトに変換するためのユーティリティ関数です。
494
588
  #### 引数
495
589
  - `strRgb16` string
496
- #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}