itmar-block-packages 1.2.3 → 1.3.1

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